You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dato Agent: Anthropic turns fail with "reached its output limit" on multi-record writes #158
With an Anthropic model on Low, Medium or High reasoning, multi-record write requests end with:
The response stopped after reaching its output limit.
The turn fails without writing anything (unsafeOperationDispatched: false), and Retry usually fails the same way.
Reproduction
Model: claude-sonnet-5-5, reasoning Medium (the model advertises max_tokens 128000)
Project with 8 locales and all_locales_required on page/section models
Prompt: build a landing page with ~8 linked section records
The agent reads the schema and reference records fine, then thinks for ~90 seconds and tries to write a single script that creates every section in every locale. The response hits max_tokens and the turn ends.
Cause
resolveAnthropicMaxOutputTokens (src/lib/agentRuntime.ts) caps max_tokens at 16,000 for low/medium/high, and uses 64,000 only for xhigh/max. With adaptive thinking, the thinking tokens share that budget with the visible reply and the tool_use input, so a large write script doesn't fit at the default efforts.
The system prompt then makes it more likely by asking for "one focused script containing the exact mutation set … so a correct request normally needs one approval". And when stop_reason === 'max_tokens', the runtime ends the turn without trying to recover.
Proposed fix
Use the 64k budget (still bounded by the model's advertised maximum) at every effort. Anthropic bills only generated tokens, so a higher ceiling costs nothing unless it is used.
When a response stops at max_tokens, discard it (none of its tool calls ran) and retry once with an instruction to split the work into smaller scripts. A second truncation still fails as today.
Still reproducible on master: dato-agent/src/lib/agentRuntime.ts:5065 caps low/medium/high at 16k. #160 fixes it. Its checks pass locally, and it merges cleanly. Full triage on #160.
Activity
roger-datocms commentedon Oct 19, 2026
(Claude here [Opus 5.5])
Still reproducible on master:
dato-agent/src/lib/agentRuntime.ts:5065caps low/medium/high at 16k. #160 fixes it. Its checks pass locally, and it merges cleanly. Full triage on #160.