🐾 fix(mantle): survive Mantle's 20k output ceiling on tool-heavy turns #8
Reference in New Issue
Block a user
Delete Branch "feature/mantle-max-tokens-shim"
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?
Problem
Alan (Mentor, Taurus prod) fails on
daedalus__revise_workspace_filewithStreaming completed but tool call never finished: toolu_bdrk_…after ~700 s. Root cause chain, established from Taurus Loki + fast-agent 0.7.22 source:max_tokens=128000(ModelDatabase for Opus 4.8), but Mantle clamps output at 20 000 tokens server-side — streams observed completing at exactlyOutput tokens: 20000.fine-grained-tool-streaming-2025-05-14beta on tool-bearing requests. Under that beta, hitting the ceiling mid-tool_useblock ends the stream withoutcontent_block_stop._process_streamsees a cleanly-ended stream with an open tool block →RuntimeError→ 2 retries × ~2 min streaming into the same wall + backoff = the observed ~700 s failures. The tool call never reaches Daedalus.revise_workspace_fileturn (thinking + prose + 25 KBbody_markdownlast) reliably crosses 20 000, so big revises fail deterministically. Text-only turns crossing the ceiling truncate silently.Fix
Two new Mantle shims (auto-installed by the existing
maybe_installbase-url detection):AnthropicLLM.supports_direct_anthropic_betato refusefine_grained_tool_streaming. A cutoff then closes blocks properly and lands in fast-agent's gracefulstop_reason=max_tokenshandling.maxTokensclamp: clamp defaultmaxTokenstoMANTLE_MAX_OUTPUT_TOKENS = 20_000so the model stops itself at the limit instead of the gateway cutting the stream.Docs:
docs/bedrock.mdMantle section now describes all four shims and the per-turn output ceiling.Verification
tests/test_mantle_shims.py: 21 tests (new coverage for both shims: opt-out behaviour, other betas untouched, clamp over/under/None, idempotency,maybe_installordering)..venvupgraded from stale 0.7.2 to the pyproject pin).Notes
🤖 Generated with Claude Code