Skip to content

cost.json always reports 0 tokens — chunk JSON placeholders never overwritten with real Agent usage values #658

Description

@melchiormahot

Where: graphify/skill.md Step B3 (around line 308). The subagent's chunk JSON template includes "input_tokens":0,"output_tokens":0 because the subagent cannot know its own token usage. The orchestrator (parent Claude) DOES receive usage.input_tokens / usage.output_tokens in the Agent tool result for each chunk, but the skill never tells the orchestrator to write those back into the chunk JSON before merging. The merge step (around line 340) reads new.get('input_tokens', 0) — which is the placeholder zero — and writes 0 into cost.json.

Version: graphify 0.4.23 (pipx-installed graphifyy package).

Symptom: A real run reported 0 tokens for ~332K of consumption (162,904 input on chunk 1 + 169,595 input on chunk 2 per the Agent tool's actual usage values).

Fix shape:

  1. New bullet at Step B3 telling the orchestrator to overwrite each .graphify_chunk_NN.json's input_tokens / output_tokens with the real Agent tool result values before merging.
  2. New explicit Python merge block that globs .graphify_chunk_*.json, sums input_tokens / output_tokens across chunks, and writes the aggregate to .graphify_semantic_new.json. Previously the merge step was implicit and the tokens were dropped.

Smoke-tested locally with two synthetic chunk JSONs holding 162,904 + 169,595 input tokens — output: Merged 2 chunks: 332499 in / 9999 out tokens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions