mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 12:22:14 +03:00
* fix(compression): skip CCR on tool outputs to preserve agent loop
When OmniRoute is used as a chat-completion PROVIDER (not as an MCP server),
the upstream LLM cannot call `omniroute_ccr_retrieve` to expand CCR markers
on demand. Replacing tool outputs with `[CCR retrieve hash=… chars=…]`
placeholders therefore makes the LLM stall — it sees an opaque marker
where the actual tool result should be and has no way to recover the
verbatim content.
Scope:
- OpenAI format: `{ role: "tool", tool_call_id, content }`
- Anthropic format: `{ role: "user", content: [{ type: "tool_result", … }] }`
Fix: extend `processMessages` in the CCR engine to skip both shapes
verbatim. The engine still applies to plain user / assistant text blocks,
which is where compression yields token savings AND the LLM can reason
about the marker.
Tests:
- New `tests/unit/compression/ccr-skip-tool-outputs.test.ts` covers both
formats (4 cases) plus a regression guard that plain user text is still
compressed.
- All 57 pre-existing CCR tests still pass.
Reported-by: herjarsa
Refs: AGENTS.md agent feedback — agent loop stalled on bash/read/grep
outputs after CCR collapsed them to markers.
* fix(compression): guard CCR against null / non-object parts
Apply gemini-code-assist review feedback on PR #7869:
- Use optional chaining when reading `part["type"]` so malformed
client payloads (null entries, non-object entries in the parts
array) cannot throw `TypeError: Cannot read properties of null`.
- The skip rule (this branch) and the existing text-part compression
path (the next branch) both get the guard, since both dereference
`part["type"]` directly.
Test:
- New defensive case: a user message whose content array contains a
`null` entry alongside a `tool_result` must not crash the engine.
Refs: gemini-code-assist review on #7869 (PRR_kwDORPf6ys8AAAABGj5G7Q)
---------
Co-authored-by: herjarsa <herjarsa@users.noreply.github.com>