-
Notifications
You must be signed in to change notification settings - Fork 15.5k
WIP: cache trace mvp for Anthropic #1370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Added an opt‑in “cache trace” debugger to capture exactly what context is sent to Anthropic on each inference. It’s a standalone module (src/ Enable via env:
|
Added a standalone cache tracing module and wired it into the embedded
runner so you can capture message flow and the exact context sent to
Anthropic in a separate JSONL file.
What changed
- New tracing module: src/agents/cache-trace.ts (self‑contained,
env‑gated, writes JSONL, computes per‑message digests).
- Hook points in src/agents/pi-embedded-runner/run/attempt.ts: logs
stage snapshots (loaded/sanitized/limited/prompt/stream/after) and wraps
the
stream fn to record the real context.messages at send time.
How to enable
- CLAWDBOT_CACHE_TRACE=1 enables tracing.
- CLAWDBOT_CACHE_TRACE_FILE=~/.clawdbot/logs/cache-trace.jsonl
overrides output (default is
$CLAWDBOT_STATE_DIR/logs/cache-trace.jsonl).
- Optional filters:
- CLAWDBOT_CACHE_TRACE_MESSAGES=0 to omit full messages (still
logs digests).
- CLAWDBOT_CACHE_TRACE_PROMPT=0 to omit prompt text.
- CLAWDBOT_CACHE_TRACE_SYSTEM=0 to omit system prompt.
What you’ll see
- One JSON object per line with stage, messagesDigest, per‑message
messageFingerprints, and the actual messages if enabled.
- The most important line is stage: "stream:context" — that is the
exact payload pi‑mono is sending. If this diverges from earlier stages,
you’ve
found the mutation point.
5704b33 to
97e8f9d
Compare
|
Here’s the full‑file analysis (all 67 lines, 9 runs), plus a Python script you can reuse. Findings (from this trace only)
Cache behavior timeline (from session:after usage)
Interpretation
|
|
based on the cache‑trace you gave me, the only history changes between runs are on toolResult entries for the read tool, and those Why I’m confident:
So: not clawdbot logic, it’s pi‑mono session save/load shape drift. It likely doesn’t change the actual Anthropic payload (tool result text is the If you want to be 100% sure, I can:
|
|
Root cause (confirmed)
Fields dropped on disk
Fix options
Net: the mutation is not semantic, it’s a serialization artifact (undefined vs missing). |
Added a standalone cache tracing module and wired it into the embedded runner so you can capture message flow and the exact context sent to
Anthropic in a separate JSONL file.
What changed
stream fn to record the real context.messages at send time.
How to enable
$CLAWDBOT_STATE_DIR/logs/cache-trace.jsonl).
What you’ll see
found the mutation point.