Request Flow
This page traces the complete lifecycle of a request, from HTTP entry to SSE-encoded response.
Full Request Lifecycle
Key Steps
Request parsing:
parseResponseRequest()validates the JSON envelope and returns a structured body or an error response.Context creation:
createResponsesContext()resolves the model, validates the provider config, optionally resolves the session chain, and resolves theProviderEdgefrom the registrar.Model resolution:
ModelResolver.resolve()parses the model string. If it contains a/, it is treated as an explicitprovider/modelselector. Otherwise, the bare name is looked up in themodels.aliasesmap (exact match, then*wildcard, thendefault_providerfallback).Session chain resolution: When
previous_response_idis present,SessionStore.resolveChain()walks the parent pointer chain, collecting turns in chronological order.Provider lookup:
Registrar.resolve()returns the builtProviderEdgefor the resolved provider name.Request building:
buildChatCompletionRequest()in the bridge kernel plans compatibility, tools, and output contracts, then normalizes messages.Response reconstruction: The sync pipeline reconstructs a
ResponseObjectviareconstructResponseObject(). The stream pipeline maps deltas throughResponseStreamStateMachine.