Skip to content

Commit 44433cf

Browse files
committed
Docs: document centralized model registry
Add a documentation menu and refresh the architecture and API guides\nto reflect the shared core-owned model registry contract.\n\nDocument the resolved payload flow, removed local policy ownership,\nand current model-selection entrypoints for Codex consumers.
1 parent a7579f1 commit 44433cf

3 files changed

Lines changed: 101 additions & 2 deletions

File tree

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313

1414
An idiomatic Elixir SDK for embedding OpenAI's Codex agent in your workflows and applications. This SDK wraps the `codex-rs` executable, providing a complete, production-ready interface with streaming support and comprehensive event handling.
1515

16+
## Documentation Menu
17+
18+
- `README.md` - installation, quick start, and runtime boundaries
19+
- `guides/01-getting-started.md` - first threads, turns, and sessions
20+
- `guides/02-architecture.md` - transport layering and ownership boundaries
21+
- `guides/03-api-guide.md` - public modules and common call patterns
22+
- `guides/07-models-and-reasoning.md` - shared catalog projections and reasoning controls
23+
- `guides/08-configuration-defaults.md` - config precedence and default resolution
24+
1625
## Features
1726

1827
- **End-to-End Codex Lifecycle**: Spawn, resume, and manage full Codex threads with rich turn instrumentation.
@@ -115,9 +124,35 @@ Custom trust roots use `CODEX_CA_CERTIFICATE` first and `SSL_CERT_FILE` second.
115124
ignored. The same PEM bundle is applied consistently to Codex CLI subprocesses, direct HTTP
116125
clients, remote model fetches, MCP HTTP/OAuth, realtime websockets, and voice HTTP requests.
117126

118-
Default model: `Codex.Models.default_model/0` currently resolves to `gpt-5.4` with the bundled catalog unless `CODEX_MODEL`, `OPENAI_DEFAULT_MODEL`, `CODEX_MODEL_DEFAULT`, or a fresher ChatGPT `/models` cache overrides it.
127+
## Centralized Model Selection
128+
129+
`codex_sdk` no longer owns the active model catalog, fallback rules, or default
130+
selection policy. That authority now lives in `cli_subprocess_core`.
131+
132+
The authoritative path is:
133+
134+
- `CliSubprocessCore.ModelRegistry.resolve/3`
135+
- `CliSubprocessCore.ModelRegistry.validate/2`
136+
- `CliSubprocessCore.ModelRegistry.default_model/2`
137+
- `CliSubprocessCore.ModelRegistry.build_arg_payload/3`
138+
139+
`Codex.Options.new/1` resolves a shared `model_payload`, then projects the
140+
current `model` and `reasoning_effort` from that payload. `Codex.Models` is now
141+
a read-only projection of the shared core catalog. It no longer owns a separate
142+
catalog or a separate fallback/defaulting path.
143+
144+
Operationally, that means:
145+
146+
- explicit request wins first
147+
- environment override comes next
148+
- provider default and remote default are core-owned, not SDK-owned
149+
- missing provider, missing model, placeholder model input, and invalid
150+
reasoning effort all fail through the core error contract
151+
- CLI argument rendering only emits `--model` from a non-empty resolved value
119152

120-
The SDK always loads the bundled upstream model catalog from `priv/models.json`, which is synced from the vendored upstream catalog in `codex/codex-rs/core/models.json`. When ChatGPT auth tokens are available it can still refresh `/models` and cache the result, but the old `features.remote_models` flag is no longer required for current catalog/default behavior. See `guides/07-models-and-reasoning.md` for the current bundled snapshot and how to inspect the effective runtime list.
153+
Use `Codex.Models.default_model/0`, `Codex.Models.list_visible/1`, and
154+
`Codex.Models.default_reasoning_effort/1` as convenience readers over that
155+
shared contract.
121156

122157
See the [OpenAI Codex documentation](https://github.com/openai/codex) for more authentication options.
123158

guides/02-architecture.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,33 @@ The publication boundary on that split is now:
7474
- optional ASM integration may exist only as an explicit bridge above the
7575
normalized kernel; it does not re-home these families or widen the core
7676

77+
## Centralized Model Selection
78+
79+
`cli_subprocess_core` is the only model-policy owner in the Codex stack.
80+
`codex_sdk` consumes the resolved selection payload and never implements a
81+
second defaulting or fallback path.
82+
83+
Resolution ownership:
84+
85+
- `CliSubprocessCore.ModelRegistry.resolve/3`
86+
- `CliSubprocessCore.ModelRegistry.validate/2`
87+
- `CliSubprocessCore.ModelRegistry.default_model/2`
88+
- `CliSubprocessCore.ModelRegistry.build_arg_payload/3`
89+
90+
Codex-side consumption points:
91+
92+
- `Codex.Options.new/1` resolves `model_payload`, `model`, and
93+
`reasoning_effort`
94+
- `Codex.Models` projects visible models and defaults from the shared catalog
95+
- `Codex.Runtime.Exec` renders CLI args from the current resolved options state
96+
97+
Contract rules:
98+
99+
- no repo-local model catalog owns policy
100+
- no implicit provider fallback exists outside the core registry
101+
- no silent acceptance of blank, placeholder, or invalid model requests
102+
- no `--model nil`, `--model null`, or blank `--model` emission
103+
77104
## Component Architecture
78105

79106
### High-Level Component Diagram

guides/03-api-guide.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,43 @@ Complete API documentation for all modules in the Elixir Codex SDK.
3636

3737
---
3838

39+
## Model Selection APIs
40+
41+
Model policy is centralized in `cli_subprocess_core`. In `codex_sdk`, the
42+
public API surfaces are projections and consumers of that shared contract.
43+
44+
Primary entrypoints:
45+
46+
- `Codex.Options.new/1` resolves the shared `model_payload` via
47+
`CliSubprocessCore.ModelRegistry.build_arg_payload/3`
48+
- `Codex.Models.default_model/0` returns the current shared core default
49+
- `Codex.Models.list_visible/1` returns the shared visible Codex catalog
50+
- `Codex.Models.default_reasoning_effort/1` projects reasoning defaults from
51+
the shared catalog
52+
53+
Operational notes:
54+
55+
- `codex_sdk` does not own a separate bundled policy layer anymore
56+
- unknown model, invalid reasoning effort, and unavailable model errors come
57+
from the core registry contract
58+
- runtime CLI rendering consumes resolved state and does not invent fallback
59+
models locally
60+
61+
Example:
62+
63+
```elixir
64+
{:ok, opts} =
65+
Codex.Options.new(%{
66+
model: "gpt-5.4-mini",
67+
reasoning_effort: :medium
68+
})
69+
70+
opts.model_payload.resolved_model
71+
# => "gpt-5.4-mini"
72+
```
73+
74+
---
75+
3976
## Codex.CLI and Codex.CLI.Session
4077

4178
Use `Codex.CLI` when you need the upstream command surface directly rather than

0 commit comments

Comments
 (0)