feat: add cost and usage tracking to output directory per step and overall task#600
Merged
feat: add cost and usage tracking to output directory per step and overall task#600
Conversation
331a2f3 to
9588b17
Compare
9588b17 to
dc7e9ac
Compare
Angelmmiguel
approved these changes
Mar 25, 2026
Contributor
Angelmmiguel
left a comment
There was a problem hiding this comment.
LGTM! Amazing we are reporting and storing all this data. This is mandatory for autonomous systems 😄
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.
Add usage and cost tracking throughout the task lifecycle. Each iteration now records its usage (tokens, cost, model, agent) in
iteration.json, and the task description aggregates usage across all iterations. Theinspectcommand displays a new Usage section, and thelistcommand syncs usage on every refresh.Changes
Schemas (
packages/schemas)UsageReportSchemaandStepUsageReportSchemaZod schemas inpackages/schemas/src/usage/schema.tsUsageReportandStepUsageReporttypes are now inferred from Zod schemas (z.infer<typeof ...>) instead of manually defined interfacesIterationSchemato v1.2 with an optionalusagefieldTaskDescriptionSchemato v1.6 with an optionalusagefieldUsageReportSchema,StepUsageReportSchema, andStepUsageReportfrom the package indexCore (
packages/core)IterationManagergainsusagegetter andsetUsage()method; added migration from v1.1 → v1.2TaskDescriptionManager.updateStatusFromIteration()now catches missingstatus.jsongracefully and callssyncUsage()on terminal statesTaskDescriptionManager.syncUsage()that rebuilds task-level usage by summing iteration data viaaccumulateUsage()usagegetter toTaskDescriptionManageraccumulateUsage()helper that sums twoUsageReportvalues, resolvingagent/modelonly when all reports agreeaggregateUsageinWorkflowManagernow builds a per-stepStepUsageReport[]breakdown and resolves top-levelagent/modelonly when all steps agreeUsageTrackernow tracksagentalongsidemodel, with the same single-value-when-unanimous resolution strategyAgent (
packages/agent)runCommandpersistsworkflowUsagetoiteration.jsonviaIterationManager.setUsage()agent(tool name) to usage reports alongsidemodelruncommand displays Agent in usage properties outputCLI (
packages/cli)inspectcommand callstask.updateStatusFromIteration()before display, includesusagein output, and renders a new Usage section (cost, input/output/total tokens)listcommand comment updated to reflect usage sync on terminal statesusagefield toTaskInspectionOutputinterfaceNotes
1.5to1.6; iteration schema from1.1to1.2.agentandmodelon aggregated reports are intentionally set only when all contributing steps/iterations used the same value; otherwise they are left undefined.iteration.json(versioned);status.jsonis not modified with cost data.