Documentation
¶
Overview ¶
Package responses models the Codex Responses request as the proxy sees it: the body fields the router reads or rewrites (model, reasoning.effort, input items), the turn metadata header, the request kind, and the usage reported in the response.completed SSE event. Every other byte passes through.
Index ¶
Constants ¶
const ( TypeMessage = "message" TypeFunctionCall = "function_call" TypeFunctionCallOutput = "function_call_output" TypeCustomToolCall = "custom_tool_call" TypeCustomToolCallOutput = "custom_tool_call_output" TypeLocalShellCall = "local_shell_call" TypeReasoning = "reasoning" )
Input item types the router decodes. Other types keep only Type.
const ( HeaderTurnMetadata = "X-Codex-Turn-Metadata" HeaderSubagent = "X-Openai-Subagent" )
Request headers the proxy reads.
const ( HeaderModel = "Openai-Model" HeaderXModel = "X-Openai-Model" )
Response headers the proxy strips: Codex reads them as the served model and warns on a mismatch (research §3.1).
const RequestKindTurn = "turn"
RequestKindTurn is the x-codex-turn-metadata request_kind of a user step. Compaction (local and remote v2) sends "compaction" (research §9, spike 1c).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
Type string
Role string
ID string
Name string
CallID string
Text string
Output string
Arguments string
}
Item is one input item, flattened. Fields not used by a type stay empty; unknown types keep only Type.
type Kind ¶
type Kind string
Kind says whether a request is a routable user step or must pass through unchanged (compaction, subagent, any other or unknown request kind).
type Meta ¶
type Meta struct {
SessionID string
ThreadID string
TurnID string
RequestKind string
Subagent string
}
Meta is the parsed x-codex-turn-metadata header plus the subagent header. RequestKind is "turn" for a user step, "compaction" for a compaction request.
type Request ¶
type Request struct {
Model string
Effort config.Effort
Input []Item
Bytes int
// contains filtered or unexported fields
}
Request is the parsed body. Bytes is the raw body length; the raw body is kept inside for Apply.
func Parse ¶
Parse reads model, reasoning.effort and input items from a Responses request body. The body must be a JSON object with a string model.
func (*Request) Apply ¶
Apply returns the body with model and reasoning.effort set from rw. Only those values change; every other byte, including key order and whitespace, stays as Codex sent it. An absent reasoning object is added with the effort only. A no-op rewrite returns the original body, which the caller must not modify.
func (*Request) Fingerprint ¶
Fingerprint identifies one request of a turn. Retries of a request resend the same body, so they share it; each later step of the turn appends items, so it changes. It hashes the original model, not a rewrite.
type Rewrite ¶
Rewrite is what the router changes: model and reasoning.effort. An empty Effort keeps the effort Codex sent.