Repository navigation
fix(agent): give cloud models a 32K output-token cap - #4368
Conversation
Cloud reasoning models count their thinking against the agent's per-reply output cap, and the fixed 8,192-token cap (sized for a local 32K context) was cutting their replies off mid-thought. Lemonade cloud models now get 32,768; local models keep 8,192. - The cap is resolved per call from the current model, so a mid-session model switch takes effect. Cloud detection uses cloud_model_provider(), including Lemonade catalog metadata once discovered. - New optional max_output_tokens on Agent and ChatAgentConfig overrides the policy; an invalid value raises. Claude and OpenAI keep their 8,192 default and honor an explicit value.
…eads The truncated-tool-call error message now names the live output-token budget, so the code path reads self.max_output_tokens. The bare-agent stub in this file is built with __new__ on purpose and never ran __init__, so that attribute was missing and formatting the message raised AttributeError instead of the ValueError the test asserts. Set it on the stub like the other attributes it already primes.
# Conflicts: # src/gaia/agents/base/agent.py
main removed the openai/litellm providers (#3899), so use_chatgpt now raises a migration error at construction. The OpenAI request-cap test exercised that removed provider and the cloud-cap expression still carried a use_chatgpt term that can never be True.
|
Verdict: Approve with suggestions Cloud reasoning models like Two carried-over gaps worth a follow-up issue: 🟡 Streaming call sites have no test coverage. The four call sites with 🟡 🔍 Technical detailsStreaming test gap: Double-computation: Minor nit (~50 words): The |
Replicates #4063 (kovtcharov/gaia fork, push access blocked) onto a branch this session can push to.
Cloud reasoning models such as
fireworks.deepseek-v4p1-flashcount their thinking against the agent's per-reply output cap. That cap was fixed at 8,192 tokens, which was sized for a local 32K context. On TheRock coding tasks, all three failed runs ended with a reply at exactly 8,192 tokens. Lemonade cloud models now get 32,768 output tokens, the same default Claude Code uses. Local models keep 8,192. Callers can set their own cap with a new optionalmax_output_tokenson the agent.One change beyond the original:
mainremoved the openai/litellm providers (#3899), souse_chatgptnow raises a migration error at construction. The original PR's OpenAI request-cap test exercised that removed provider and has been dropped, along with ause_chatgptterm in the cap expression that can never be True. No other content changes beyond conflict resolution against current main.Test plan
pytest tests/unit/test_agent_max_output_tokens.py tests/unit/test_tool_call_priority.py— 43 passed. These check the JSON body sent to Lemonade and expectmax_completion_tokens32768 for a cloud model and 8192 for a local model, plus an explicit override, a model switch mid-session, a custom provider flagged by catalog metadata, and the Claude request kwargs.pytest tests/unit/agents— 1422 passed, 50 skipped; identical on unmodifiedmain.python util/lint.py --black --isortclean.gaia eval agent --category tool_selectionCarried over from the review on #4063, not addressed here: the cap is computed twice (once into
AgentConfig.max_tokensat init, once per call in_max_output_tokens()), so memory-distillation and builder paths can disagree with the main loop for a catalog-flagged custom provider; and the streaming call sites have no test.