Summary
The kernel's detectWireFormat (dist/wire/index.js) recognizes three wire formats:
- responses (
Array.isArray(input))
- anthropic (
messages array with tool_use/ blocks)
- openai (
messages array with tool_calls array)
Three additional provider wire bodies have no codec path and currently fail-open (pass through untransformed):
| API |
Wire body |
Why it's hard |
amazon-bedrock |
Converse API — untyped content blocks (content: [{text: ...}, {toolUse: ...}, {toolResult: ...}]) |
No stable schema; blocks are untyped unions |
cursor |
gRPC AgentRunRequest — protobuf-serialized |
Binary; requires proto definitions |
google (gemini) |
GenerateContent — contents: [{parts: [{text: ...}, {functionCall: ...}]}] |
Different shape from openai/anthropic |
Impact
In billion-context-omp, these APIs currently:
- Lose compression — the wire payload passes through untransformed (fail-open).
- Fire delivery warnings —
providerDeliveryWarning emits nodelivery: (bedrock/cursor: host drops the onPayload replacement fire-and-forget) or nocodec: (google/devin: no kernel codec).
This is tracked in billion-context-omp issue #83 (upstream fix for the dropped-replacement bug is merged in pi-ai 17.3.8, but the codec gap remains).
Proposal
Add wire codecs for the three formats:
- amazon-bedrock (Converse):
converseToCore / patchConverseMessages / coreToConverse
- cursor (gRPC):
agentRunToCore / patchAgentRunRequest / coreToAgentRun (requires proto definitions)
- google (gemini):
geminiToCore / patchGeminiContents / coreToGemini
Each codec should follow the existing pattern:
*ToCore(body) → BiliMessage[] (parse wire → core space)
patch*(projection, messages) → wire body (rebuild wire from core, layout-preserving)
coreTo*(messages) → wire body (core → wire for new messages)
Priority
Medium — these APIs are less common than anthropic/openai/responses, but the gap means users on these providers get no compression at all. The fail-open behavior is safe (no data loss), but the feature is missing.
References
Summary
The kernel's
detectWireFormat(dist/wire/index.js) recognizes three wire formats:Array.isArray(input))messagesarray withtool_use/ blocks)messagesarray withtool_callsarray)Three additional provider wire bodies have no codec path and currently fail-open (pass through untransformed):
amazon-bedrockcontent: [{text: ...}, {toolUse: ...}, {toolResult: ...}])cursorAgentRunRequest— protobuf-serializedgoogle(gemini)contents: [{parts: [{text: ...}, {functionCall: ...}]}]Impact
In billion-context-omp, these APIs currently:
providerDeliveryWarningemitsnodelivery:(bedrock/cursor: host drops the onPayload replacement fire-and-forget) ornocodec:(google/devin: no kernel codec).This is tracked in billion-context-omp issue #83 (upstream fix for the dropped-replacement bug is merged in pi-ai 17.3.8, but the codec gap remains).
Proposal
Add wire codecs for the three formats:
converseToCore/patchConverseMessages/coreToConverseagentRunToCore/patchAgentRunRequest/coreToAgentRun(requires proto definitions)geminiToCore/patchGeminiContents/coreToGeminiEach codec should follow the existing pattern:
*ToCore(body) → BiliMessage[](parse wire → core space)patch*(projection, messages) → wire body(rebuild wire from core, layout-preserving)coreTo*(messages) → wire body(core → wire for new messages)Priority
Medium — these APIs are less common than anthropic/openai/responses, but the gap means users on these providers get no compression at all. The fail-open behavior is safe (no data loss), but the feature is missing.
References