← Back to Pull requests

fix(agents): send maxOutputTokens for prompt agents #11007

Open
unknown opened this pull request with 247 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 19, 2026 15:47 UTC
Author

Summary

  • A kind: prompt service with maxOutputTokens set deployed with max_output_tokens: null, because PromptAgent had no field for it and CreatePromptAgentAPIRequest never copied it into the prompt definition.

  • Add MaxOutputTokens *int to PromptAgent (authored as maxOutputTokens, like topP) and to ManagedAgentDefinition (sent as max_output_tokens), and map it next to temperature and top_p.

  • Reject values below 1 for prompt agents in ValidateAgentDefinition, and narrow the schema's kind: prompt branch to an integer from 1 to 2147483647. The voice-only "inf" value stays valid for prompt-voice agents only. I also updated the shared property description, which said the field was voice-only.
  • Fixes #10924.

    Validation

  • Go 1.26 (GOTOOLCHAIN=auto): go test ./internal/pkg/agents/agent_yaml/ ./internal/pkg/agents/agent_api/ and go test ./internal/project/ -run "DocExample|Schema|Prompt" pass. go vet on the changed packages is clean, and the changed files are gofmt-clean.

  • New tests: TestPromptAgent_MaxOutputTokensReachesTheAPI (set and unset) and TestPromptAgent_MaxOutputTokensMustBePositive. With the source changes reverted and the tests kept, both fail. The set case shows the request body {"name":"capped-agent","definition":{"kind":"prompt","model":"gpt-4.1-mini","instructions":"You are helpful."}} with no max_output_tokens, which is the reported behavior.

  • I also checked the azure.yaml path from the issue with a throwaway test (not committed): the issue's service properties go through PromptAgentFromResolvedService and then CreatePromptAgentAPIRequest. On main the body has no max_output_tokens. With this change it has "max_output_tokens":4000.
  • No Azure deployment or interactive scenario was run.

    AI disclosure: I made this change with help from Claude Code, and I reviewed the diff and the test results myself.

    🤖 Generated with Claude Code

    Diff: 247 lines (+185 / -62) across 3 files Reviewer: 1AbdullahButt Review duration: 12440m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.62) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.62 · 247 lines diff across 3 files
    0.62
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.330
    Sensitive Paths sensitive_paths
    0.062
    Real PR Conversation Timeline
    1 comments
    "Review active on #11007"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 62.1% (MEDIUM) · Higher = larger blast radius
    62.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 33.1% · Safe to merge
    33.1%