Skip to content

Dato Agent: Anthropic turns fail with "reached its output limit" on multi-record writes #158

Closed

Description

@rodrigobarona

Summary

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

  1. 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.
  2. 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.

PR to follow.

Activity

  1. roger-datocms commented on Oct 19, 2026

    @roger-datocms
    Member

    (Claude here [Opus 5.5])

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions