Skip to content

feat: expose aggregate token usage at turn completion - #68

Merged
shaohaozhi286 merged 1 commit into
masterfrom
feat/acemodel-turn-usage-api
Sep 21, 2026
Merged

shaohaozhi286 merged 1 commit into
masterfrom
feat/acemodel-turn-usage-api

Conversation

@shaohaozhi286

Copy link
Copy Markdown
Collaborator

Summary

  • aggregate all accounted model-step token usage across one regular agent turn
  • expose the same turn summary and turn_id on terminal busy_changed and done session API events
  • preserve existing incremental usage and model_step_finish events
  • mark mixed provider-reported/estimated summaries with has_data: false while retaining estimated counts and complete context breakdowns
  • add OpenSpec proposal/design/spec/tasks plus daemon API documentation

API shape

{
  "type": "done",
  "payload": {
    "outcome": "completed",
    "turn_id": "...",
    "usage": {
      "prompt_tokens": 44100,
      "completion_tokens": 2100,
      "total_tokens": 46200,
      "cache_read_tokens": 32000,
      "cache_write_tokens": 0,
      "reasoning_tokens": 500,
      "has_data": true
    }
  }
}

Terminal usage is a whole-turn summary, not another delta to add to the preceding per-step usage events.

Verification

  • npx --yes @fission-ai/openspec@1.12.0 validate expose-turn-token-usage --strict
  • bash scripts/code_quality_check.sh
  • git diff --check
  • added regression coverage for multi-step aggregation and mixed reported/estimated usage

Per request, no C++ compilation/build was run locally; CI should execute the added unit tests.

@shaohaozhi286
shaohaozhi286 force-pushed the feat/acemodel-turn-usage-api branch from e5aab22 to 7e801e4 Compare September 21, 2026 10:09
@shaohaozhi286
shaohaozhi286 merged commit 6ff47bd into master Sep 21, 2026
3 checks passed
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.

1 participant