Custom/local model provider: ChatGPT app connector tools inlined in first request (~80K tokens) instead of deferred
What version of Codex CLI is running?
codex-cli 0.164.0 (macOS) and 0.163.0 (Linux); same result on both.
What subscription do you have?
ChatGPT sign-in (connected apps enabled).
Which model were you using?
Any model name Codex has no metadata for, served by a custom model_providers entry with wire_api = "responses" (a local Qwen model in our case). With gpt-6.1-sol the problem does not occur.
What platform is your computer?
macOS 27 (arm64) and Arch Linux (x86_64).
What terminal emulator and version are you using (if applicable)?
Not terminal-specific; reproduced with codex exec.
Codex doctor report
N/A
What issue are you seeing?
When the Codex home is signed in to ChatGPT and the model is unknown to Codex, the opening POST /v1/responses inlines the full schema of every ChatGPT app connector tool. Codex does not defer them behind tool search as it does for OpenAI models. On the first turn of say hi, that is about 315K characters of tools, roughly 80K tokens, before any user content. The largest entries:
| tool | JSON chars |
|---|---|
mcp__codex_apps__github |
78,355 |
mcp__codex_apps__chatgpt_space |
77,719 |
mcp__codex_apps__sites |
41,908 |
mcp__codex_apps__gmail |
33,552 |
mcp__codex_apps__google_calendar |
18,581 |
mcp__codex_apps__search_service, plugin_management, pets, … |
~35K |
The whole request is about 91K tokens, larger than the context window of most local models. The provider then rejects the first turn outright: context_length_exceeded: prompt (92550 tokens) leaves no room to answer in the context (32768). The connector tools cannot work against a non-OpenAI provider anyway.
Same home and prompt, varying only the model or features:
| setup | opening request |
|---|---|
-m gpt-6.1-sol |
~22.5K tokens (apps deferred) |
-m <unknown local model> |
~91K tokens |
unknown model + features.apps=false |
~19K tokens |
What steps can reproduce the bug?
- Sign in to Codex with ChatGPT, with some connected apps enabled.
- Run a local server that records the body of
POST /v1/responsesand returns a 400 (any small HTTP server will do). codex exec --skip-git-repo-check -c model_provider=cap -c model_providers.cap.name=cap -c model_providers.cap.base_url=http://127.0.0.1:18199/v1 -c model_providers.cap.wire_api=responses -m some-local-model "say hi" < /dev/null- Inspect the captured body.
toolsholds everymcp__codex_apps__*schema inline. - Repeat with
-m gpt-6.1-sol. The app tools are absent or deferred.
What is the expected behavior?
For a custom (non-OpenAI) provider, ChatGPT app connector tools should not be sent at all. At minimum, they should be deferred the same way as for OpenAI models. They should never be inlined just because model metadata is missing.
Additional information
Workaround: a separate CODEX_HOME without a ChatGPT login, or [features] apps = false (we also turn off plugins, memories and multi_agent for local models). That brings the opening request to about 8K tokens.
Additional reproduction from Codex Desktop on Windows (2026-11-18), comparing GPT-6.2 Sol and GPT-6.1 Sol.
With fresh conversations and the same greeting prompt, the context usage indicator after the first turn showed approximately:
| Selected model | Context used / displayed limit |
|---|---|
| GPT-6.2 Sol | 113K / 258K |
| GPT-6.1 Sol | 27K / 828K |
These are approximate UI readings, not an exact per-field token attribution. The difference in used context is about 86K tokens.
Local diagnostic findings:
- Both of the two inspected GPT-6.2 Sol conversations triggered model-metadata fallback.
- The GPT-6.2 Sol conversations preloaded a large set of complete tool definitions on the first turn, whereas GPT-6.1 Sol used deferred/on-demand tool loading.
- The local model cache contains a correct GPT-6.2 Sol entry, but why the runtime did not use it has not been established.
The tool-loading difference is the leading explanation for the approximately 86K-token gap; the greeting, memory, and skill directory do not explain that model-dependent difference. This appears closely related to the missing-metadata/eager-tool-loading behavior reported here, although this reproduction selects GPT-6.2 Sol in Desktop rather than the original report's unknown local model.
Model-list refresh timeouts also appear in the local logs. They are a diagnostic lead, not proof that timeout-driven cache invalidation caused this reproduction. #54878 describes a related timeout/fallback/tool-change sequence with an explicit custom-provider catalog, but equivalence to this case has not been established.
Could maintainers investigate why GPT-6.2 Sol resolves to fallback metadata despite a matching local cache entry, and whether that fallback changes tool-search/deferred-loading capabilities and produces the 258K displayed context limit?
No exact Desktop/runtime build number or raw log excerpts are included in this follow-up; this comment should not be read as a claim of reproduction on a particular build or as a confirmed root cause.
I observed a similar GPT‑6.2 Sol metadata fallback in Codex Desktop on macOS on November 18, 2026.
Environment: macOS 26.6.2 (arm64), ChatGPT Desktop 26.1111.21308 (build 27194), bundled Codex 0.169.0-alpha.11.1, ChatGPT sign-in, model_context_window = 750000.
| Same conversation | Effective context window | First request input tokens |
|---|---|---|
| Turn 1 | 258,400 | 100,135 |
| Turn 2 | 712,500 | 40,588 |
Both turns used gpt-6.2-sol with ultra reasoning effort. On turn 1, the client logged Unknown model gpt-6.2-sol is used. This will use fallback model metadata. The 100,135 input tokens were reported before the first tool result. On turn 2, the client logged reason="tools_changed" and returned to on-demand tool loading. There was no compaction event between the two turns. The logs don’t break down the input tokens by tool definition.
The installed desktop runtime’s bundled catalog contains gpt-6.1-sol but lacks gpt-6.2-sol. PR #62106 adds the missing entry, and CLI 0.169.1 includes it. The desktop updater still reports 26.1111.21308 as current on this machine, so I haven’t verified the fix in a newer desktop build.
Could the desktop runtime warn before sending the first request when missing model metadata would cause it to load the full tool catalog upfront?
Additional controlled reproduction on November 27, 2026: 147,169 input tokens on the first request of a fresh desktop chat, with an approximately 18-token user question. A local request-capture experiment isolates missing model metadata as the trigger for eager tool exposure.
Environment and scope
- macOS 27.0.1, arm64.
- Desktop app bundle version
26.1111.71025, build28661. - Bundled
codex-cli 0.169.0-alpha.11.1. - ChatGPT-connected apps enabled; Responses requests routed through a local compatible bridge.
- Selected model:
gpt-6.1-sol. An explicitmodel_catalog_jsonpoints to a custom catalog with 30 entries, but that selected slug is absent. The catalog includesgpt-6.2-solwithsupports_search_tool: trueandtool_mode: "code_mode_only".
This is a custom-catalog/provider configuration, not a claim that every stock installation has this startup cost. Unlike the original report's comparison, even gpt-6.1-sol reproduces the problem when it is missing from the effective catalog.
Observed desktop usage
The first provider-reported usage record, before any tool result:
{
"input_tokens": 147169,
"cached_input_tokens": 3712,
"output_tokens": 51,
"total_tokens": 147220
}
An early subsequent request reported 176465 input tokens. The startup log repeatedly states:
Unknown model gpt-6.1-sol is used. This will use fallback model metadata.
The same turn records:
feature.apps=true
feature.code_mode=false
feature.code_mode_only=false
feature.code_mode_host=true
feature.code_mode_tool_search=false
feature.tool_search=false
feature.search_tool=false
feature.tool_search_always_defer_mcp_tools=true
model_context_window_effective=258400
Controlled request-capture experiment
Using the bundled CLI, fresh codex exec --ephemeral requests were captured by a loopback-only HTTP listener. The listener intentionally returned HTTP 400 after recording the request, before model inference. No live model/plugin/configuration settings were changed.
| Isolated setup | Captured tool payload |
|---|---|
| Selected slug missing from the effective catalog | 436 callable tools; 154,532 tokens of serialized tool JSON |
| Same slug, with temporary metadata enabling tool search/code mode | 7,658 tokens of serialized tool JSON |
That is a 95.04% reduction in serialized tool-definition tokens. Both counts use tiktoken / o200k_base with the same measurement method. They are not provider-reported prompt-token counts and are not a reconstruction of the original desktop request, whose complete wire payload was not retained.
For isolation, the second test copied an existing catalog entry's capability metadata under the selected slug in a temporary catalog. This demonstrates the metadata/exposure-policy effect; it does not establish that the borrowed metadata is correct for the selected model or recommend aliasing models in production.
Reproduction
- Enable connected apps with a sizeable tool catalog.
- Configure a Responses-compatible provider and an explicit
model_catalog_jsonthat omits the selected model slug. - Start a fresh desktop chat or
codex exec --ephemeralwith a short prompt. - Observe the fallback-model warning, disabled search/code-mode capabilities, the 258,400 effective window, and eager exposure of the app tool catalog on the opening request.
- Repeat with isolated metadata enabling deferred/searchable exposure and compare captured
toolspayloads, without sending either request to a model.
Likely code path and requested safeguards
In codex-rs/models-manager/src/model_info.rs, model_info_from_slug creates fallback metadata with supports_search_tool: false and a 272,000-token context window. In codex-rs/core/src/tools/spec_plan.rs, apply_mcp_tool_exposure_policy removes deferred exposure when model metadata does not support tool search. The recorded tool_search_always_defer_mcp_tools=true does not prevent the large direct-tool payload in this case.
Please consider:
- A prominent, actionable warning when the selected model is missing from an explicit catalog, before sending a huge first request.
- Safe handling of unknown capabilities rather than silently preloading hundreds of schemas; do not simply assume tool-search support for an arbitrary model.
- A visible breakdown/budget for fixed instructions and tool schemas, distinct from user conversation history.
- A guard against unshrinkable tool prefixes causing repeated auto-compaction, as described in related issue #61679. An auto-compaction loop was not independently reproduced in this particular case.
This report intentionally excludes raw request bodies, complete logs, session identifiers, account details, private paths, and credentials.