Skip to content

Add persona cost attribution using Burn SDK 2.x tags #45

@willwashburn

Description

@willwashburn

Context

Follow-up to AgentWorkforce/burn#373.

AgentWorkforce should provide default-on persona cost attribution without requiring users to install burn separately and without routing launches through burn run. Burn remains domain-neutral; AgentWorkforce writes generic enrichment tags and burn reports on tags.

Blocked by

Desired changes

  • Depend on @relayburn/sdk 2.x only. Do not use deprecated TS 1.x burn packages.
  • Keep AgentWorkforce as the direct launcher for claude, codex, and opencode; do not use burn run.
  • Preserve persona source metadata during resolution so launches can stamp personaSource and, for local personas, enough debug context to identify the source layer.
  • Compute personaVersion from the effective resolved persona spec after cascade/extends merge and before runtime input substitution:
    • stable-key canonical JSON
    • SHA-256 full hex hash
    • optional 12-character short form for display only
  • Wrap existing harness launch with burn bookkeeping:
    • before spawn, call sdk.writePendingStamp(...) with generic enrichment tags
    • while child runs, periodically call sdk.ingest({ harness })
    • after exit/error, stop polling and run one final ingest
    • preserve the harness exit code exactly
  • Stamp at least these tags:
    • agentworkforce=1
    • persona=<id>
    • personaTier=<tier>
    • personaVersion=<full sha256>
    • personaSource=<cwd|user|dir:n|library>
  • Add opt-out controls:
    • agentworkforce agent --no-burn <persona>[@tier]
    • AGENTWORKFORCE_BURN=0
  • Update docs to show generic burn queries after burn#373 lands, e.g. burn summary --tag persona=code-reviewer and burn summary --group-by-tag persona.

Acceptance criteria

  • A normal persona launch writes burn attribution tags by default once burn#373 is available.
  • Users do not need a separately installed burn binary for this attribution path.
  • --no-burn and AGENTWORKFORCE_BURN=0 skip stamp writing, periodic ingest, final ingest, and burn summary output.
  • Periodic/final ingest is attempted on success, nonzero exit, and spawn error; child exit code is preserved.
  • Persona hash is stable under object key reordering and changes when effective persona content changes.
  • Unit tests cover default tracking, opt-out, tag payload, version hashing, and exit-code preservation.

Notes

The burn side should stay generic. Do not add burn summary --persona; use tag filtering/grouping from burn#373.

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