Skip to content

Show conversation context usage in V2 and log plan and summary token usage (0.261.483) - #1979

Open
Paul Lizer (paullizer) wants to merge 2 commits into
Developmentfrom
claude/context-usage-tracking-ec38f3
Open

Paul Lizer (paullizer) wants to merge 2 commits into
Developmentfrom
claude/context-usage-tracking-ec38f3

Conversation

@paullizer

Copy link
Copy Markdown
Contributor

What this adds

Context usage in V2 chat

  • Each chat reply records how the request it sent was made up (messages, summary of older messages, attached files, workspace results, web results, memory, instructions) together with the selected model's limits, on metadata.history_context.context_usage.
  • A ring in the composer and the chat header shows how full the model's input is (amber at 75%, red at 90%). A new Context tab in the conversation drawer breaks it down by type and by turn.
  • The total is the provider's own prompt count when the reply was a single request; otherwise the server's estimate.
  • Each model in the picker carries its limits, so choosing another model re-bases the ring immediately.
  • The limits are worked out once, where the request already resolves its model, and reused. No extra endpoint, user settings or governance lookups.

Orchestration plans

  • A plan is reported as spend per model, not as context, because its requests do not accumulate in the conversation window.
  • Each step records the models that served it and its largest single request against that model's limit; the Plan tab shows it under the step.
  • Agent steps count under the agent's own model.

Activity logs and Control Center

  • Plan token usage is written to the activity logs, one row per model, with an idempotent row id so a redelivered run is not counted twice.
  • The request that summarizes older messages now logs its own usage.
  • The dashboard token filters and the activity log filters gain Source (Chat, Plan, Workflow), sent as token_source.

Details: docs/explanation/features/V2_CONTEXT_USAGE.md.

Testing

  • New: test_context_usage_measurement.py, test_orchestration_plan_token_usage_logging.py, test_token_usage_source_filter.py (26 tests) and test_v2_context_usage_logic.mjs all pass.
  • npx tsc -b --noEmit passes in application/v2_ui.
  • After merging Development: the orchestration scheduler, routes and external results suites give 435 passed, 12 failed, and the same 12 fail on an untouched Development checkout.

Not done

  • Not exercised in a running deployment. The ring and Context tab were checked in a temporary harness; the plan rows, the Plan tab line and the Control Center filters have not been seen rendered.
  • Release notes are not updated.
  • Known limits (listed in the feature doc): requests a plan step makes through its planner client are not counted, agent steps show no largest request, replies and plans from before this version are not backfilled, and the classic UI is unchanged.

🤖 Generated with Claude Code

…usage (0.261.483)

Each chat reply now records how the request it sent was made up (messages,
summary, files, workspace and web results, memory, instructions) and the
selected model's limits. V2 shows this as a ring in the composer and a Context
tab in the conversation drawer, re-based when another model is picked.

Orchestration plans are reported as spend per model rather than as context,
each step records its largest single request against its model's limit, and
plan usage and the older-message summary request are written to the activity
logs. The Control Center dashboard and activity logs can filter token usage by
source (chat, plan, workflow).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-usage-tracking-ec38f3

# Conflicts:
#	application/single_app/config.py
Comment on lines +167 to +169
assert plan_usage.log_plan_token_usage(
_record(), rows, status="waiting", message_id="m", log_token_usage=lambda **kwargs: calls.append(kwargs),
) == 0
Comment on lines +170 to +172
assert plan_usage.log_plan_token_usage(
_record(), [], status="completed", message_id="m", log_token_usage=lambda **kwargs: calls.append(kwargs),
) == 0

This branch has not been deployed

No deployments
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.

2 participants