traces: turn-level local spans — model calls (tokens/cache/errors) + tool calls, per-session JSONL - #106
Open
Rchari1 wants to merge 1 commit into
Open
traces: turn-level local spans — model calls (tokens/cache/errors) + tool calls, per-session JSONL#106Rchari1 wants to merge 1 commit into
Rchari1 wants to merge 1 commit into
Conversation
…ery model call (tokens/cache/duration/error) and tool call (name/args/duration, secret-scrubbed, bounded) as OTel-shaped spans in ~/.amico/amicode/traces/<session>.jsonl; AMICODE_TRACES=0 kill switch, AMICODE_TRACE_DIR test seam + tests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 28, 2026
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.
Turn-level traces, local-first (writer half; pairs with harmoniqs/opencode
rchari/traces— the reader endpoint).What
The amicode plugin now records every model call (provider/model, duration, tokens incl. cache read/write, error) and every tool call (name, args, duration, output size) as OTel-shaped spans, one JSONL per session in
~/.amico/amicode/traces/. Sources: the plugineventhook (assistantmessage.updated, deduped, emitted once on completion),chat.message(turn opens), and thetool.execute.before/afterpair (real durations via callID pairing).Privacy & safety
Local-only by design (chats are research IP). Secrets scrubbed at record time (same
SECRET_REdiscipline as the onboarding stream), attrs bounded (2KB strings, 32-entry collections), tool output stored as a length, not content.AMICODE_TRACES=0kill switch;AMICODE_TRACE_DIRseam for tests. Recording is fully best-effort — telemetry can never break a session.Envelope (the cross-repo contract — reader mirrors it)
{v:1, ts, session, span:"model"|"tool"|"turn", id, name, dur_ms|null, attrs, error|null}— append-only; readers skip malformed lines.Day-zero finding (from the live verification)
One "hi" to the pulse-designer = 3 model calls (5.2s + 3.2s + 1.5s) + 2 tool calls — including a tool call named
invalid(the model attempted a malformed call). Also corrected our own perf diagnosis: the zen DeepSeek tier DOES prompt-cache — call 1 pays the ~26k prefill, calls 2–3 read ~26k each from cache. The slow feel is first-call prefill × 3 round-trips × free-tier pace, not "no caching ever." This is exactly the class of insight the feature exists for.Verification
7 new tests (writer, scrub, message-event mapping incl. the error-carrying case, tool pairing); full suite 443 green; live-verified end-to-end (chat turn → spans on disk → served by the fork endpoint).
🤖 Generated with Claude Code