Skip to content

Wire burn hook-based Claude Code ingest + retire CostTracker #786

@willwashburn

Description

@willwashburn

Follow-up from burn#7 (shipped in @relayburn/*@0.8.0).

What to do

A. Wire buildClaudeHookSettings into the two spawn sites

Burn now exports a pure spawner primitive from @relayburn/ledger:

import { buildClaudeHookSettings, stamp } from '@relayburn/ledger';

const { sessionId, settings } = buildClaudeHookSettings();
await stamp({ sessionId }, { workflowId, agentId, persona, tier });

spawn('claude', [
  '--session-id', sessionId,
  '--settings', settings,
  ...existingArgs,
]);

Apply the same pattern at both spawn sites:

  • packages/sdk/src/workflows/process-spawner.ts:68 (non-interactive agent steps)
  • packages/sdk/src/workflows/runner.ts:5887 (interactive agents via relay.spawnPty)

Relay's existing env-var threading (AGENT_NAME, RELAY_API_KEY, AGENT_CHANNELS at runner.ts:5863-5868) is orthogonal — leave it alone.

B. Retire CostTracker

src/cost/tracker.ts writes a wall-clock-based token estimate to ~/.agent-relay/usage.jsonl. Once (A) is in place, burn's hook-fed ledger at ~/.relayburn/ledger.jsonl is the authoritative source for the same data (exact, not estimated). Delete CostTracker and any call sites.

Acceptance

  • Both spawn sites pass --session-id + --settings when spawning claude.
  • Stamp metadata (workflow, agent, persona, tier) is applied against the pre-assigned UUID before spawn so all turns inherit it.
  • CostTracker and ~/.agent-relay/usage.jsonl are removed; any UI that reads the old file now reads from burn.
  • End-to-end: spawn an interactive agent, run one tool call, verify a TurnRecord with the stamped enrichment shows up in burn query --session <id>.

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