Skip to content

feat(model): sticky Anthropic cache marks and prefix diagnostics - #366

Merged
github-actions[bot] merged 1 commit into
feat/prompt-cache-freezefrom
feat/prompt-cache-diagnostics
Aug 16, 2026
Merged

github-actions[bot] merged 1 commit into
feat/prompt-cache-freezefrom
feat/prompt-cache-diagnostics

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

Stacked on #365 (feat/prompt-cache-freeze). Adds provider cache-hint policy and debug-only prefix diagnostics.

Merge after #365.

Changes

  • OpenAI-compat (OpenAI, DeepSeek, Grok, Ollama): send no cache_control. Rely on automatic prefix cache.
  • Anthropic: sticky cache_control on last tool + last system block; slide only the last conversation mark. Attach tools before hints. Always emit message content as a block array so sliding the mark does not change earlier message shape.
  • Compared snapshot is tools + system + messages, minus cache_control, encoded as concatenated parts so a new message is a real byte prefix. model / effort / route are excluded.
  • Journal ModelRequest now stores prompt_wire_sha256, prompt_wire_bytes, cache_epoch, cache_transport.
  • Debug logs: CACHE PREFIX INVALIDATED (sizes, reuse %, first JSON pointer, hashes) or cache epoch reset: context_reset|transport. No TUI.

Tests

  • OpenAI-compat request body has no cache_control.
  • Anthropic slide + strip keeps the previous snapshot as a prefix.
  • Consecutive prepare_model_step calls preserve the stripped prefix.
  • Effort toggle does not change the compared snapshot.
  • First-diff pointer names the mutated field.
cargo test --package forge-model --package forge-core --package forge-durable --all-targets --locked

Out of scope

No compaction, no Gemini transport, no footer/status UI.

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
@github-actions
github-actions Bot merged commit 9af43bc into feat/prompt-cache-freeze Aug 16, 2026
4 checks passed
github-actions Bot pushed a commit that referenced this pull request Aug 16, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
mohitranka added a commit that referenced this pull request Aug 21, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* fix(core): freeze model-visible prefix for prompt cache

Stop rewriting already-sent context between requests: always list
view_image, snapshot images at insert, offload HITL tool output
before it enters history, and replay resume transcripts as they
were last sent.

* feat(model): sticky Anthropic cache marks and prefix diagnostics (#366)

Drop OpenAI-compat cache_control, mark Anthropic tools/system
stably and slide only the last conversation block, and journal a
stripped prompt-wire hash so unexpected prefix mutations show up
in debug logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant