Skip to content

feat(zoom-ai): add Zoom Decisions DecisionModel - #8776

Open
cdliao wants to merge 1 commit into
livekit:mainfrom
cdliao:chenda/zoom-ai-decisions
Open

cdliao wants to merge 1 commit into
livekit:mainfrom
cdliao:chenda/zoom-ai-decisions

Conversation

@cdliao

@cdliao cdliao commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a DecisionModel to the Zoom AI plugin: zoom_ai.DecisionModel(), built on the Zoom AI Services Decisions API.

  • One request (POST /v2/aiservices/decisions/decide) answers the whole batch. Probability, Choice and Score map to Zoom's predicate, choice and score questions, each named by its decision key, and answers are paired back by name.
  • model is zoom-decisions (default) or zoom-decisions-pro. zoom-guardrails classifies against fixed safety categories and takes no questions, so it's rejected at construction.
  • Zoom returns score probabilities by level index without labels; the result carries the levels that were sent. An option or level Zoom leaves out of a distribution counts as 0.
  • A question Zoom declines (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.
  • Errors carry Zoom's reason (for example Zoom Decisions error (HTTP 400): unsupported model "nope" ...), with the request's x-zm-trackingid as request_id. A 4xx isn't retried. After a 429 or 503, the next request waits for the Retry-After Zoom gave (the header, or metadata.retry_after_seconds in a 503 body); a wait as long as the attempt timeout fails without retrying.
  • input_tokens comes from usage.input_units. output_units counts decisions rather than tokens, so output_tokens is left unset.
  • The README gets a Decisions section and an options table.

Usage:

model = zoom_ai.DecisionModel()
response = await model.evaluate(
    input=chat_ctx,
    decisions={
        "handoff": llm.Probability("The caller asks for a human."),
        "frustration": llm.Score("How frustrated is the caller?", levels=["Calm", "Annoyed", "Angry"]),
    },
)

Testing

  • uv run pytest tests/test_plugin_zoom_ai_decisions.py: 15 passed, against a local aiohttp server:
    • request body and headers, and extra headers;
    • the transcript sent for a ChatContext;
    • all three kinds decoded, with distributions and usage;
    • missing probabilities counted as 0;
    • a refusal and a missing answer reported per decision;
    • an unknown answer rejecting the batch;
    • a non-JSON response and a 400 not retried;
    • a 429 retried only after its Retry-After, and a long Retry-After failing fast.
  • tests/test_plugin_zoom_ai_stt.py still passes.
  • ruff check, ruff format, mypy: clean.
  • Against production Zoom Decisions, with a conversation as input and one decision of each kind:
    • zoom-decisions and zoom-decisions-pro both answered the whole batch;
    • an unknown model raised APIStatusError 400 with Zoom's message, not retried.

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.
@cdliao
cdliao requested a review from a team as a code owner November 25, 2026 05:01

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +160 to +167
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

Comment on lines +132 to +136
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟨 Plaintext credentials on remote HTTP

When an operator configures a remote HTTP endpoint, _evaluate_impl sends the Zoom bearer key and conversation without encryption. A network observer can read both.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@tinalenguyen tinalenguyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, thanks for the PR! few notes:

  • could you resolve the merge conflicts? #8456 just landed and touches the readme, __init__.py and pyproject.toml
  • left a reply on the devin thread about the Retry-After wait, and a small nit on its test

assert len(fake.requests) == 1


async def test_retry_waits_for_retry_after(server, http) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants