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" // HeaderAccount is the ChatGPT account the request bills to. Only its // hash (Meta.Account) leaves the proxy; the raw value goes upstream only. HeaderAccount = "ChatGPT-Account-ID" )
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).
const ThreadSourceUser = "user"
ThreadSourceUser is the x-codex-turn-metadata thread_source of a thread the user started. Codex 0.162.1 runs side work in its own threads with another source: subagent, guardian_review, memory_consolidation, or a feature name such as thread_title (the footer's title, generated after the first prompt).
Variables ¶
This section is empty.
Functions ¶
func AccountHash ¶ added in v0.3.0
AccountHash is the first 12 hex of sha256(id), or "" for an empty id (plan M12). Engines and link frames see only this, never the raw id.
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).
func Classify ¶
Classify applies plan decision D5 as spike 1c settled it: only a main-thread turn request is a user step. Compaction, any other request kind, missing metadata, a missing turn ID, every subagent request and a thread of any source but the user's pass through. A missing thread source counts as the user's.
type Meta ¶
type Meta struct {
SessionID string
ThreadID string
TurnID string
RequestKind string
ThreadSource string
Subagent string
Account 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. ThreadSource says who started the thread. Account is AccountHash of the ChatGPT-Account-ID header, empty when it is missing.
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) Body ¶ added in v0.3.0
Body returns the raw body Parse read, 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.