Expand description
Wire-protocol translation for LLM providers.
causa-protocol renders ContextFrame → provider wire bodies and
parses wire responses → kernel ModelOutput.
translation::context_frame is the shared policy walk; the three
renderers (translation::anthropic, openai_chat,
openai_responses) are thin emitters over it. The crate serves the
causa_kernel::ModelGateway seam and is consumed by causa-provider’s
gateways. It is transport-free.
translation::streaming::StreamDecoder incrementally decodes raw SSE bytes
into kernel observations and a complete terminal output. SseParser is
the lower-level bounded byte framer. Neither owns HTTP, execution control,
retries, event history or a background task.
Layering:
causa-kernel (facts, ModelGateway seam)
<- causa-protocol (render/parse) <- causa-providercausa-protocol must not depend on reqwest, Axum, or any concrete
provider SDK.
§Protocol options and wire rendering
- Generation options: OpenAI Chat renders
max_tokensasmax_completion_tokens, Responses renders it asmax_output_tokens, and Anthropic renders it asmax_tokens.Noneomits the limit on the two OpenAI wires; Anthropic requires the field, so that renderer rejects a missing value before any HTTP. - Reasoning effort: a string, written as the host gave it to OpenAI
Chat
reasoning_effort, Responsesreasoning.effortand Anthropicoutput_config.effort. No value is refused, mapped or combined with another field; which values a model accepts is the host’s knowledge. - Extra request fields:
causa_kernel::GenerationOptions::extra_bodyis merged into the body. Objects merge key by key with what the renderer wrote, soreasoning.summaryjoinsreasoning.effort; any other value the renderer wrote is kept, and arrays are never merged. The rule goes by key name, andoutput_schemais kept whole: a key beside the schema is merged, a key inside it is not. An Anthropicthinkingobject is sent this way. - Structured outputs:
output_schemarenders asresponse_formaton Chat andtext.formaton Responses; the Anthropic adapter rejects it. - Prompt cache directives:
causa_kernel::CacheDirective::StablePrefixrenders explicitcache_controlbreakpoints on Anthropic; OpenAI-family providers cache automatically server-side, treating the directive as a no-op. - Stop values: Anthropic maps wire
stop_reason, Chat mapsfinish_reason, and Responses mapsstatus(orstatus.reasonwhen status isincompleteand carries a reason).
Re-exports§
pub use protocol::Protocol;pub use translation::sse_parser::SseEvent;pub use translation::sse_parser::SseParser;
Modules§
- protocol
- Wire-protocol discriminator for provider adapters.
- translation
- Translation between kernel DTOs and provider-native DTOs.