Skip to content

docs: explain what max_total_tokens counts - #237

Merged
yuanhao merged 2 commits into
mainfrom
docs/max-total-tokens
Oct 5, 2026
Merged

yuanhao merged 2 commits into
mainfrom
docs/max-total-tokens

Conversation

@yuanhao

@yuanhao yuanhao commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #226 by documenting the behaviour. The behaviour itself is unchanged.

What's documented: each turn adds its whole prompt (cached tokens included) plus its output. The prompt resends the conversation, so the total grows much faster than the conversation does: the 1M default is reached around turn 16 at a 60K-token context.

Where:

  • ExecutionLimits::max_total_tokens and with_max_total_tokens rustdoc: what is counted, why it grows fast, and to raise it or set usize::MAX for long sessions.
  • max_duration rustdoc: the 10-minute default also ends long interactive sessions.
  • docs/concepts/context-management.md: a new "What max_total_tokens counts" section, with a context-size → turns table and a long-session example.
  • CHANGELOG.

Counting the conversation's growth instead is tracked as a low-priority follow-up issue.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG

Each turn adds its whole prompt (cached tokens included) plus output, so
the total grows much faster than the conversation: the 1M default is
reached around turn 16 at a 60K context. Documented in the rustdoc and the
context guide, with a table and the settings for long sessions (raise or
usize::MAX, and max_duration). Behaviour unchanged; counting conversation
growth instead is tracked as a low-priority follow-up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
… caps (review of #237)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
@yuanhao
yuanhao merged commit 6d4cced into main Oct 5, 2026
14 checks passed
@yuanhao
yuanhao deleted the docs/max-total-tokens branch October 5, 2026 22:13
@yuanhao yuanhao mentioned this pull request Oct 5, 2026
yuanhao added a commit that referenced this pull request Oct 5, 2026
Reliability fixes from the October codebase review (#232-#235, #237, #238).


Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

max_total_tokens counts the cached prefix every turn (decision needed)

1 participant