responses: the tool protocol has no seam in the request path — no per-attempt preparation, response restore or stream adaptation

Author: hrygoCreated Sep 29, 2026Updated Sep 29, 2026

Is it a request payload issue? [x] Yes, this is a request payload issue. I am using a client/cURL to send a request payload, but I received an unexpected error. [ ] No, it's another issue.

If it's a request payload issue, you MUST know Compare the request your client sent with the request that reached the upstream, using request-log: true in config.yaml. Today they are identical on every route, which is the defect: the proxy has no point in the request path where the tool protocol could be applied, so no configuration can turn it on.

Describe the bug

Summary

Even with a correct protocol implementation and a correct policy, there is nowhere in the request path to apply them. The request flows from the handler through the auth manager, the conductor, the executor, the translators, and back out through the response and stream paths — and no layer owns a per-attempt tool-protocol object. Preparation has to happen after auth resolution (because the policy depends on the selected credential) and before the executor call; restoration has to happen on the way back, on both the response and the stream path. No such seam exists.

Observed behavior

  • There is no place to hang a per-request attempt, so nothing can be prepared, budgeted, or torn down.
  • The credential-selection loop retries across accounts. A protocol adaptation that is built once and carried across a retry is wrong: the retry may land on a different credential with a different route and therefore a different policy.
  • Token counting runs on the request path too, and would otherwise count the un-prepared body — so a client would be billed for a body that was never sent.
  • Stream errors have a hard ordering constraint: a preparation failure must surface before the first chunk, because after the first chunk the HTTP status is already committed and the only remaining signal is an in-band stream error.

CLI Type All.

Model Name All.

LLM Client Codex-style clients, streaming and non-streaming.

Request Information

N/A — the missing seam is structural, not payload-specific.

Expected behavior

  • One seam in the auth manager that wraps an actual executor call. The sequence is fixed: after-auth interceptor output, then route resolution against the real credential and format, then preparation against the same config snapshot, then the normalized executor call, then output restore or a typed error.
  • Every credential refresh, credential rotation, or model change rebuilds from the original client contract with a fresh preparation. A normalized body is never re-wrapped, and an attempt is never shared across requests.
  • Executor capabilities are preserved: the original executor instance is never wrapped or replaced, and the executor-aware call form is used where the format conversion capability must survive.
  • The attempt is closed before returning on success. On a bridge error it is closed and the error takes the request-scoped stop branch, regardless of user-configured error regex rules.
  • Token counting applies preparation and the declaration budget without building response stream state, and executors that cannot count keep their original error behavior. Counts are never faked.
  • Streaming: preparation errors surface before the first chunk, so callers return real HTTP errors through bootstrap. After the first chunk, a failure travels exactly once through the Responses stream error shape and the stream terminates cleanly.
  • The shared per-provider execution glue lives in the executor helper layer, not inside an executor. The executors themselves stay executors plus their unit tests.

Screenshots N/A.

OS Type

  • OS: macOS
  • Version: 26.x / arm64 (not platform specific)

Additional context

Scope in this issue

  • The auth-manager wrapper: call, executor-aware call, call-to-format, count, and stream-call forms.
  • The route identity builder, reading only the selected credential and the executor format, plus a check that both the client input and the downstream target are Responses-family before the protocol is considered at all.
  • The manager-held state: the compiled policy snapshot and the long-lived limiter, created on first use and refreshed on config update.
  • The shared execution glue in the executor helper layer: contract application, budget accounting, and the per-provider tool surface.
  • Per-executor call sites for the providers that can be bridged, and the meta executor's multi-agent v2 rewrite for executors that translate to Codex themselves (that rewrite is explicit about compatibility mode, because the segment those executors serve carries no is-compat flag and without it the rewrite leaves author and recipient on converted messages).
  • Stopping SSE field: lines at the producer so frames are self-terminating downstream, instead of relying on every consumer to add them.

Out of scope

The protocol logic itself, the policy surface, and the capability declaration.

Invariants

  • An attempt belongs to exactly one executor call and is never shared.
  • A retry always starts from the original client contract.
  • No timeout is introduced anywhere in this path. Timeouts remain confined to credential acquisition; once an upstream connection is established, no subsequent network behaviour is time-bounded.

Related issues

This is the integration seam for the whole series. It depends on the contract, the policy surface, the bridges, the budgets, and the outbound guard; the capability declaration depends on it.

Source: router-for-me/CLIProxyAPI