Skip to content

feat(wire): add wire-format detection and transform-channel policy - #84

Merged
ranxianglei merged 1 commit into
masterfrom
2026-08-16_wire-format-detection
Aug 16, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-08-16_wire-format-detection

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Two small, pure additions that let adapters stop hard-coding per-host tables:

acp-kernel/wire — WIRE_FORMATS / detectWireFormat
Classify a provider request body by the codec that can parse it (anthropic / openai / responses). undefined means no codec handles the body — the caller must pass it through untransformed. Detection semantics are ported from the field-proven billion-context-omp wire bridge (issue #52/#66 lineage), extended with the responses input shape the kernel codec already supports but no detector covered.

resolveTransformChannel
The shared channel-selection policy: an explicit preference always wins; the default is the wire channel only when the caller reports it viable (body parseable AND the host applies the payload replacement). Keeps the policy in one place as more adapters adopt wire-level surgery.

Both are host-agnostic (no pi-ai / omp / proxy imports), zero runtime dependencies, pure functions.

Context

ranxianglei/billion-context-omp issue #79: with provider-mode as the blanket default, models on APIs whose host drops the wire-payload replacement (openai-completions & friends) received no compression injections and never compressed. The omp-side fix (PR ranxianglei/billion-context-omp#80) resolves the channel per API; this PR moves the capability half of that decision — which wire bodies the kernel can actually parse — into the kernel so all consumers (omp, proxy, future hosts) query one source. The host-side root fix is can1357/oh-my-pi#8717.

Verification

  • npm run typecheck clean
  • npm test — 348 pass / 0 fail (12 new: detection routing incl. anthropic/openai/responses markers, unknown-shape rejection, channel policy truth table)
  • npm run build clean
  • No version bump (release branch per AGENTS.md after merge)

- acp-kernel/wire: WIRE_FORMATS + detectWireFormat classify a provider request
  body by the codec that can parse it (anthropic / openai / responses);
  undefined means the body is unparseable and must pass through
  untransformed. Detection semantics ported from the field-proven
  billion-context-omp bridge, extended with the responses input-array shape.
- resolveTransformChannel: the shared channel-selection policy - an explicit
  preference always wins; the default is the wire channel only when the
  caller reports it viable (body parseable AND the host applies the
  payload replacement). Adapters decide surgery at message level vs wire
  level from kernel data instead of hard-coding per-host tables (see
  ranxianglei/billion-context-omp issue #79).
@ranxianglei
ranxianglei force-pushed the 2026-08-16_wire-format-detection branch from c35a517 to 19e6043 Compare August 16, 2026 11:27
@ranxianglei
ranxianglei merged commit 5f02ef0 into master Aug 16, 2026
3 checks passed
@ranxianglei ranxianglei mentioned this pull request Aug 16, 2026
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