Skip to content

feat: fork Braintrust trace plugin to agentv-claude-trace with atomic cache writes #843

@christso

Description

@christso

Summary

The Braintrust trace-claude-code plugin's SessionStart hook has a race condition: set_cache_value() in common.sh performs a non-atomic read-modify-write on ~/.claude/state/braintrust_cache.json. Under concurrent eval runs, this corrupts the cache file and crashes claude -p after ~4 tests.

Current workaround

PR #840 sets TRACE_TO_BRAINTRUST=false in the spawned env to disable the plugin during eval runs. AgentV handles its own Braintrust tracing via braintrustSpanIds.

Proposed

Fork to plugins/agentv-claude-trace with:

  • Atomic cache writes (write to temp file, then mv)
  • File locking or per-session cache files to avoid concurrent access
  • Remove set -e from hooks (a cache miss shouldn't crash the session)
  • Remove the TRACE_TO_BRAINTRUST=false workaround from ClaudeCliProvider once the fork is stable

Non-goals

  • Changing the tracing protocol or span format
  • Replacing AgentV's own braintrustSpanIds mechanism

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions