From 1d20cfc679270ab0186c537728f35bed8711f8fc Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 19 Mar 2026 08:59:46 +0000 Subject: [PATCH] story-kit: create 296_story_track_per_agent_token_usage_for_cost_visibility_and_optimisation --- ...ge_for_cost_visibility_and_optimisation.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .story_kit/work/1_backlog/296_story_track_per_agent_token_usage_for_cost_visibility_and_optimisation.md diff --git a/.story_kit/work/1_backlog/296_story_track_per_agent_token_usage_for_cost_visibility_and_optimisation.md b/.story_kit/work/1_backlog/296_story_track_per_agent_token_usage_for_cost_visibility_and_optimisation.md new file mode 100644 index 0000000..34101fb --- /dev/null +++ b/.story_kit/work/1_backlog/296_story_track_per_agent_token_usage_for_cost_visibility_and_optimisation.md @@ -0,0 +1,22 @@ +--- +name: "Track per-agent token usage for cost visibility and optimisation" +--- + +# Story 296: Track per-agent token usage for cost visibility and optimisation + +## User Story + +As a project owner, I want to see how many tokens each agent consumes per story, so that I can identify expensive operations and optimise token usage across the pipeline. + +## Acceptance Criteria + +- [ ] Research existing libraries/APIs for monitoring Claude API token usage per session (check Claude Code output, Anthropic SDK usage events, or third-party tools) +- [ ] Implement per-agent token tracking that captures input tokens, output tokens, and cache tokens for each agent run +- [ ] Token usage is recorded per story and per agent (e.g. coder-1 on story 293 used X tokens) +- [ ] Running totals are visible — either via MCP tool, web UI, or both +- [ ] Historical token usage is persisted so it survives server restarts (e.g. in story files or a separate log) +- [ ] Data is structured to support later analysis (e.g. which agent types are most expensive, which stories cost the most) + +## Out of Scope + +- TBD