You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the upstream response contains a sole tool_use for omc_proxy_expand_ref,
the proxy now:
1. Pulls the hash_str from the tool_use input
2. Looks it up in the MemoryStore cache
3. Builds a follow-up request: original messages + assistant response +
synthetic user turn with tool_result containing the expanded text
4. Re-calls upstream (bounded to 8 rounds to prevent runaway)
5. Returns the final non-expand-call response to the client
The client never sees the omc_proxy_expand_ref round-trip. Solves the
v0.14.0-alpha sharp edge where Claude Code would otherwise see the
unknown expand tool and error.
End-to-end smoke test with a mock upstream that simulates the LLM asking
to expand: client sends 7KB request, proxy rewrites to 908 bytes upstream,
mock emits expand tool_use, proxy resolves from cache, mock sees 6.8KB
tool_result, mock emits final text, client receives a single clean
assistant message. Round-trip lossless.
Mixed tool_use (expand alongside another tool) still passes through —
v0.14.3 follow-up will handle that case. Streaming still v0.14.2.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: omnimcode-apiproxy/README.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Substrate-rewriting reverse proxy for `api.anthropic.com`. Compresses large content blocks in the LLM's context window by replacing them with content-addressed `<omc:ref/>` markers, exposing a lossless expansion path via an injected tool.
4
4
5
-
Status: **v0.14.0-alpha** — proof of concept. Measured 6.64× compression on a single 6.8 KB content block in smoke test. Known sharp edges below.
5
+
Status: **v0.14.1** — request rewriting + transparent expand-tool resolution. Measured 6.64× wire-bandwidth compression on a single 6.8 KB content block; expand-tool round-trips are invisible to the client. Streaming + tool_use-block content + image content are still v0.14.2+ work.
6
6
7
7
## What it does
8
8
@@ -52,13 +52,14 @@ Smoke test against a mock upstream:
52
52
53
53
Real-world LLM-token savings depend on how often the LLM resists calling `omc_proxy_expand_ref`. The tool's description tells the LLM to only expand when the preview isn't enough; in practice this should hold ~70-90% of the time on long contexts where most prior turns aren't load-bearing for the current response.
54
54
55
-
## Known limitations (v0.14.0-alpha)
55
+
## Known limitations (v0.14.1)
56
56
57
-
1.**No streaming.** Requests with `"stream": true` pass through unchanged (no SSE rewriting yet).
58
-
2.**The injected `omc_proxy_expand_ref` tool is not yet served by the proxy.**If the LLM actually emits a `tool_use` block calling it, the response flows back through Claude Code, which doesn't know the tool and will error. This means: in this alpha, the proxy works best in a "fire and forget" mode where the LLM responds without expanding markers. A v0.14.1 follow-up will catch tool_use for `omc_proxy_expand_ref` in the response stream, execute it locally from the cache, and inject the tool_result before returning to the client.
59
-
3.**No image / tool_use / citation block rewriting.** Only `text` blocks and the `content` field of `tool_result` blocks (string or text-array form) are rewritten.
60
-
4.**Response is forwarded unmodified.** Cache only fills on the request side, so the savings kick in on subsequent turns where prior big content reappears in conversation history.
57
+
1.**No streaming.** Requests with `"stream": true` pass through unchanged (no SSE rewriting yet — v0.14.2 work).
58
+
2.**Mixed tool_use passes through unchanged.**When the LLM emits the expand call alongside another tool call in the same response, the proxy doesn't intercept — it forwards the full response to the client (which will see the unknown expand tool). The auto-resolution only triggers when expand is the sole tool_use.
59
+
3.**No image / `tool_use`-block / citation block rewriting.** Only `text` blocks and the `content` field of `tool_result` blocks (string or text-array form) are rewritten.
60
+
4.**Response body is not cached for next-turn rewriting.** Cache only fills on the request side, so the savings kick in on subsequent turns where prior big content reappears in conversation history. A v0.15 follow-up will also index large assistant `text` blocks.
61
61
5.**No batching API support.**`/v1/messages/batches` falls through to the generic passthrough.
62
+
6.**Expand-loop bound at 8 rounds.** If the LLM keeps requesting expansion, the proxy gives up and returns 502 — protects against runaway tool-loop costs.
62
63
63
64
## Threat model
64
65
@@ -84,7 +85,8 @@ The proxy is a thin axum HTTP server. State lives in the existing OMC MemoryStor
84
85
85
86
## Roadmap
86
87
87
-
-**v0.14.1**: catch `omc_proxy_expand_ref` tool_use in responses, execute locally
88
+
-~~**v0.14.1**: catch `omc_proxy_expand_ref` tool_use in responses, execute locally~~ ✅ shipped
88
89
-**v0.14.2**: streaming SSE response rewriting
89
-
-**v0.15.0**: tool_use / citation / image content support; batching API
90
+
-**v0.14.3**: handle mixed tool_use (expand + other in same assistant turn)
0 commit comments