Skip to content

Wire codecs: amazon-bedrock (Converse), cursor (gRPC AgentRunRequest), google #106

Description

@ranxianglei

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:

  1. Lose compression — the wire payload passes through untransformed (fail-open).
  2. Fire delivery warningsproviderDeliveryWarning 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:

  1. amazon-bedrock (Converse): converseToCore / patchConverseMessages / coreToConverse
  2. cursor (gRPC): agentRunToCore / patchAgentRunRequest / coreToAgentRun (requires proto definitions)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions