Files
OmniRoute/tests/unit/compression
Hernan Javier Ardila Sanchez fca82af737 fix(compression): skip CCR on tool outputs to preserve agent loop (#7869)
* 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>
2026-07-20 15:56:27 -03:00
..
2026-06-30 06:54:29 -03:00
2026-06-15 03:32:11 -03:00
2026-06-20 07:09:43 -03:00
2026-06-09 22:57:12 -03:00
2026-06-28 06:58:29 -03:00
2026-06-28 06:58:29 -03:00
2026-06-27 09:07:12 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-21 08:56:51 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-23 17:06:18 -03:00
2026-06-27 09:07:12 -03:00
2026-06-27 09:07:12 -03:00
2026-06-27 09:07:12 -03:00
2026-06-19 06:49:01 -03:00
2026-06-29 08:40:06 -03:00
2026-06-19 06:49:01 -03:00
2026-06-29 08:40:06 -03:00
2026-06-27 09:07:12 -03:00
2026-06-27 09:07:12 -03:00
2026-06-07 07:20:02 -03:00
2026-06-09 15:56:24 -03:00
2026-07-02 10:47:13 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-07-02 10:47:13 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-27 09:07:12 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-20 07:09:43 -03:00
2026-07-02 10:47:13 -03:00
2026-06-19 06:49:01 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-29 08:40:06 -03:00
2026-06-19 06:49:01 -03:00
2026-06-29 08:40:06 -03:00
2026-06-30 06:54:29 -03:00
2026-06-28 06:58:29 -03:00
2026-06-23 17:06:18 -03:00
2026-06-19 06:49:01 -03:00