🐾 fix(mantle): stop installing the unproven 20k max_tokens clamp #9
Reference in New Issue
Block a user
Delete Branch "fix/drop-unproven-max-tokens-clamp"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
install_all()now wires three Mantle shims, not four.install_max_tokens_clamp()is left in the file, unwired, so it can be re-enabled if the ceiling is ever confirmed.Why
Alan has been failing in Taurus with:
29 occurrences in 14 days on
proteus, each burning a full retry ladder (~3 min/attempt) against the same wall. Also seen onpublish_generated_document, and on Quentin.The beta opt-out (shim 3) is what fixes it, and it is kept. Under
fine-grained-tool-streaming-2025-05-14, an output cutoff mid-tool_useends the stream withoutcontent_block_stop; fast-agent's tool tracker leaves the block open (tool_tracking.py:128), and_raise_for_incomplete_anthropic_tools(llm_anthropic.py:1790) raises aRuntimeErrorthat bypasses the gracefulstop_reason=max_tokenspath. fast-agent 0.7.22 sends that beta unconditionally on every tool-bearing request — the base gate is hardcodedreturn True, no config knob. (Upstream's own Vertex subclass already overrides this method with an allowlist; this is the same move for Mantle.) The shim costs no output length — it only lets a cutoff close its blocks properly.The companion
max_tokensclamp (shim 4) is not kept. Its 20 000 ceiling was an empirical observation, never a documented Mantle limit, and re-investigation could not establish what enforces it:TASK_BUDGET_MIN_TOKENS = 20_000is a validation floor for a different feature, andtask_budget_tokensisNonefor Mentor.model: anthropic.claude-opus-4-8.ModelDatabasereportsmax_output_tokens=128000for opus-4-8, and that is what fast-agent requests.Installing it would cement a ceiling we cannot prove and silently truncate turns that might otherwise complete.
What the evidence does show
Across 14 days of
proteuslogs, no stream exceeded 20 000 output tokens, and two landed on exactly 20 000 with fast-agent'sMaximum output tokens reached. That pattern is real and unexplained — but "observed ceiling" is not "documented product limit", and this PR declines to hardcode the latter from the former.Verification
pytestwas unavailable in both the local env (nofast_agent) and the service venv (nopytest), so behaviour was verified directly against the real fast-agent 0.7.22 on proteus:⚠️ The full pytest suite was not run — please run it where pytest is available before merging.
Deploy note
Prod is running Pallas from before the shim-3/4 commit entirely: the deployed
mantle_shims.pyis the 5 819-byte two-shim version, and the running process (started Aug 3 20:51 UTC, the day beforeb5a3aa2) reportshas beta opt-out: False. Taurus needsmentor/stage.yml+mentor/deploy.ymlfrom fornax to pick this up.Scope
This stops the crash/retry loop. It does not make large single-turn documents land — if something is truncating at 20 000 they will now truncate cleanly rather than crash. The durable fix is steering agents toward
edit_workspace_file(changed passage only) overrevise_workspace_file/publish_generated_document(whole body competes with thinking + prose for one budget).