Repository navigation
v1.37.1
Highlights
This patch fixes prompt-cache misses on the first request of every turn that
follows a tool call. Dive recorded each tool-call input exactly as the model
wrote it, in the model's key order. An application that stores transcripts as
structured JSON, such as Postgres jsonb decoded into Go maps, replays those
inputs with sorted keys. The provider's cache is byte-exact, so the next turn
diverged at its first multi-key tool call and paid to rewrite everything after
it.
Dive now records tool-call inputs with sorted keys and no spacing, so the live
turn and a replayed one send the same bytes. Tools receive the same values as
before. Hooks, event callbacks and OutputMessages see the canonical bytes,
so any code that compares raw input text against the model's original output
will see a difference.
Upgrade to v1.37.1 if you persist and replay agent history. For an exact
match, decode stored inputs with json.Decoder.UseNumber. Decoding to
float64 still rewrites number literals such as 0.10, which OpenAI-style
providers compare byte for byte.
Pull requests
- fix(agent): record tool-call inputs in canonical JSON so replays hit the prompt cache (#334)
Changelog
Changed
- Tool-call inputs are recorded in canonical JSON. The agent sorts object
keys and removes spacing in eachtool_useandmcp_tool_useinput before
it records the assistant message. Tools, hooks, event callbacks and
OutputMessagessee the canonical bytes; the values are unchanged, number
text included. A transcript replayed from a store that sorts keys, such as
Postgresjsonbread into Go maps, now sends the same bytes as the live
turn when the store also keeps number text (decode withUseNumber), so
the provider's prompt cache reads it instead of rewriting it. Decoding to
float64still rewrites literals such as0.10and1.0.