Repository navigation
Conversation
zoom_ai.DecisionModel() answers a batch of probability, choice and score decisions with the Zoom AI Services Decisions API, one request per batch: Probability, Choice and Score map to Zoom's predicate, choice and score questions. The model is zoom-decisions or zoom-decisions-pro. A declined question is a per-decision error, and a Retry-After from Zoom is waited out before the next request.
There was a problem hiding this comment.
Devin Review found 2 potential issues.
5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| if (wait := self._not_before - time.monotonic()) > 0: | ||
| if wait >= conn_options.timeout: | ||
| # longer than an attempt may take: stop the retries | ||
| raise APIConnectionError( | ||
| f"Zoom Decisions asked to wait {wait:.1f}s before the next request", | ||
| retryable=False, | ||
| ) | ||
| await asyncio.sleep(wait) |
There was a problem hiding this comment.
🟡 Rate-limit waits cut retries short
After rate limiting, _evaluate_impl spends part of the next request’s timeout waiting to send it. evaluate starts its timer before the wait. The last retry can fail even when Zoom responds within the configured request timeout.
Learn more
Zoom asks the client to delay its next request after a 429 or 503. The shared evaluate starts its per-attempt timeout before calling the provider, so the cooldown consumes time meant for the request. The HTTP call has its own full timeout, but the outer timer can cancel it first.
Example: With one retry and a five-second timeout, Zoom returns Retry-After: 4. The retry waits until the deadline Zoom specified, then starts a request that would take two seconds. The outer timer cancels it after roughly one second and the evaluation returns a timeout.
Recommended fix: Run the provider cooldown before starting the per-attempt timer, for example with a protected pre-attempt hook called by evaluate. Keep the fail-fast behavior for cooldowns at least as long as the configured timeout. Add a test where the cooldown and HTTP response time each fit the timeout, but their sum does not.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
i think this is valid, the wait runs inside core's per-attempt timeout. maybe we could drop the Retry-After wait and let core's retry loop handle it, like the other decision plugins (openai, google, perplexity)?
| if scheme.lower() == "http" and urlparse(base).hostname not in _LOOPBACK_HOSTS: | ||
| logger.warning( | ||
| "base_url is not encrypted (http://); the API key and text are sent in plaintext" | ||
| ) | ||
| self._url = base + "/decide" |
There was a problem hiding this comment.
tinalenguyen
left a comment
There was a problem hiding this comment.
hi, thanks for the PR! few notes:
- could you resolve the merge conflicts? #8456 just landed and touches the readme,
__init__.pyandpyproject.toml - left a reply on the devin thread about the
Retry-Afterwait, and a small nit on its test
| assert len(fake.requests) == 1 | ||
|
|
||
|
|
||
| async def test_retry_waits_for_retry_after(server, http) -> None: |
There was a problem hiding this comment.
small nit: if the Retry-After wait stays, could we mark this test virtual_time? it waits a real second, and unit tests should stay well under 0.2s (AGENTS.md)
Summary
Adds a
DecisionModelto the Zoom AI plugin:zoom_ai.DecisionModel(), built on the Zoom AI Services Decisions API.POST /v2/aiservices/decisions/decide) answers the whole batch.Probability,ChoiceandScoremap to Zoom'spredicate,choiceandscorequestions, each named by its decision key, and answers are paired back by name.modeliszoom-decisions(default) orzoom-decisions-pro.zoom-guardrailsclassifies against fixed safety categories and takes no questions, so it's rejected at construction.type: "refusal") is a per-decision error, and the rest of the batch still answers. An answer naming a decision that wasn't asked rejects the batch.Zoom Decisions error (HTTP 400): unsupported model "nope" ...), with the request'sx-zm-trackingidasrequest_id. A 4xx isn't retried. After a 429 or 503, the next request waits for theRetry-AfterZoom gave (the header, ormetadata.retry_after_secondsin a 503 body); a wait as long as the attempt timeout fails without retrying.input_tokenscomes fromusage.input_units.output_unitscounts decisions rather than tokens, sooutput_tokensis left unset.Usage:
Testing
uv run pytest tests/test_plugin_zoom_ai_decisions.py: 15 passed, against a local aiohttp server:ChatContext;Retry-After, and a longRetry-Afterfailing fast.tests/test_plugin_zoom_ai_stt.pystill passes.zoom-decisionsandzoom-decisions-proboth answered the whole batch;APIStatusError400 with Zoom's message, not retried.