feat: per-activity and per-workflow token use tracking and cost estimation (#232)#233
Open
m2ux wants to merge 4 commits into
Open
feat: per-activity and per-workflow token use tracking and cost estimation (#232)#233m2ux wants to merge 4 commits into
m2ux wants to merge 4 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Mike Clay <mike.clay@shielded.io>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Persist harness-relayed usage at the next_activity transition seam into session.json with optional cost estimation from a versioned price table. Includes schema, handler wiring, usage helpers, and unit/integration tests. Signed-off-by: Mike Clay <mike.clay@shielded.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-activity and per-workflow token use tracking and cost estimation to the workflow-server, persisting rolled-up usage in session.json with optional harness-relayed cost estimates from a versioned price table.
🐛 Issue 📐 Engineering 📋 Test plan
Motivation
Workflow sessions provide no visibility into the token consumption or monetary cost of executing a workflow. Token use cannot be attributed to individual activities, so operators cannot identify expensive activities, compare workflow efficiency across runs, or account for what a completed work package cost to execute.
Without a durable record, that information is lost the moment a session ends. Tracking usage per activity, aggregating it per workflow, and logging the results to the planning artifact gives every work package a permanent usage and cost record.
Changes
Tests — 17 cases across unit, integration, and e2e scopes mapping to SC-1..SC-6: schema round-trip, cost estimation, child roll-up, next_activity capture, graceful omission, and completion artifact rendering.
Key decisions: Declared usage param + config price table (not OTEL ingest or server-side re-tokenization); server-first build sequence; cost labelled as estimate with subscription caveat; server owns structured state, corpus owns human-readable artifacts.
🤖 AI Assistance
📌 Submission Checklist
🔱 Fork Strategy
🗹 TODO before merging