Files
codewhale/crates
Hu Qiantao d58613ab23 test(client): add plan mode toggle byte-stability invariant test
Add test plan_mode_toggle_preserves_catalog_byte_stability that verifies
three invariants critical for DeepSeek's KV prefix cache:

1. Building the tool catalog twice for the same mode produces identical
   JSON bytes. This catches any non-determinism in catalog construction
   (e.g., HashMap iteration order, timestamp-dependent logic).

2. Non-deferred tools common to Plan and Agent modes appear in the same
   order. Plan mode excludes execution tools, but the tools that are
   present in both modes must have stable byte positions so that toggling
   between modes doesn't shift byte offsets of shared tools.

3. Activating a deferred tool mid-session appends to the tail without
   reordering the catalog head. This is the existing invariant from #263,
   now covered by a dedicated byte-level assertion.

Also add a doc comment to build_model_tool_catalog documenting the
catalog-head stability invariant.
2026-06-01 21:15:12 -07:00
..