Agents: prefer runtime-resolved metadata for explicit codex gpt-5.4#62694
Agents: prefer runtime-resolved metadata for explicit codex gpt-5.4#62694obviyus merged 6 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR makes Confidence Score: 5/5Safe to merge — both findings are non-blocking style suggestions with no present runtime defect. Both findings are P2: one is an architectural style concern about hardcoded provider/model names in core, and the other is a minor performance note about an unconditional hook call whose result is discarded for most callers. Neither affects correctness. src/agents/pi-embedded-runner/model.ts — the unconditional plugin-dynamic-model resolution (line 570) and the hardcoded provider/model check (lines 529–534). Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-runner/model.ts
Line: 529-534
Comment:
**Hardcoded provider/model special case in core**
This function names `openai-codex` and `gpt-5.4` directly in core model resolution. The project's architecture rules prohibit hardcoded provider/model special cases in core when a manifest, capability, or plugin-owned contract can express the same behavior. A manifest-level flag such as `preferRuntimeContextWindow: true` or a plugin-owned hook would let the openai-codex plugin own this preference rather than requiring a named core carve-out for each model variant.
**Context Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/model.ts
Line: 570-573
Comment:
**Plugin dynamic hook fires for every explicitly-resolved model**
`resolvePluginDynamicModelWithRegistry` is called unconditionally before the `if (explicitModel?.kind === "resolved")` guard at line 571. For every provider whose model has an explicit registry entry but is not `openai-codex/gpt-5.4`, the hook fires and its result is immediately discarded. Guarding the call avoids the wasted `runProviderDynamicModel` invocation for all other providers.
```suggestion
const pluginDynamicModel = shouldCompareOpenAICodexRuntimeResolvedModel(normalizedParams)
? resolvePluginDynamicModelWithRegistry(normalizedParams)
: explicitModel?.kind === "resolved"
? undefined
: resolvePluginDynamicModelWithRegistry(normalizedParams);
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Agents: prefer runtime codex gpt-5.4 met..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2084593780
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2c53002 to
794570f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 794570ffb9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49ef268816
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Follow-up pass complete: I addressed the later Codex review note in 467fc20a28, resolved the remaining review thread, and pushed the update to the PR branch. |
e44f4e2 to
78dfce3
Compare
obviyus
left a comment
There was a problem hiding this comment.
Reviewed latest changes; landing now.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78dfce34d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) { | ||
| return explicitModel.model; | ||
| } | ||
| const pluginDynamicModel = resolvePluginDynamicModelWithRegistry(normalizedParams); |
There was a problem hiding this comment.
Pass workspaceDir into runtime model lookup
The new explicit-model runtime-comparison path calls resolvePluginDynamicModelWithRegistry(...) without propagating the workspace that was just used by shouldCompareProviderRuntimeResolvedModel(...). In this flow, shouldPreferProviderRuntimeResolvedModel is evaluated against cfg.agents.defaults.workspace, but runProviderDynamicModel still resolves provider plugins from the active global registry workspace when workspaceDir is omitted, so a workspace-installed provider can opt in to comparison and then have dynamic resolution run in a different workspace (or not run at all). Fresh evidence here is that this mismatch is now reachable from the new explicit branch at resolveModelWithRegistry, so explicit model comparisons can silently fall back to stale metadata in multi-workspace setups.
Useful? React with 👍 / 👎.
* Agents: prefer runtime codex gpt-5.4 metadata * Agents: move codex gpt-5.4 override into provider hook * fix: repair codex runtime preference hooks * fix: use workspace dir for codex runtime preference * test: cover codex workspace dir hook * fix: prefer codex gpt-5.4 runtime metadata (#62694) (thanks @ruclaw7) --------- Co-authored-by: Rudi Cilibrasi <cilibrar@gmail.com> Co-authored-by: Rudi Cilibrasi <rudi@metagood.com> Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…ruclaw7) * Agents: prefer runtime codex gpt-5.4 metadata * Agents: move codex gpt-5.4 override into provider hook * fix: repair codex runtime preference hooks * fix: use workspace dir for codex runtime preference * test: cover codex workspace dir hook * fix: prefer codex gpt-5.4 runtime metadata (openclaw#62694) (thanks @ruclaw7) --------- Co-authored-by: Rudi Cilibrasi <cilibrar@gmail.com> Co-authored-by: Rudi Cilibrasi <rudi@metagood.com> Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…ruclaw7) * Agents: prefer runtime codex gpt-5.4 metadata * Agents: move codex gpt-5.4 override into provider hook * fix: repair codex runtime preference hooks * fix: use workspace dir for codex runtime preference * test: cover codex workspace dir hook * fix: prefer codex gpt-5.4 runtime metadata (openclaw#62694) (thanks @ruclaw7) --------- Co-authored-by: Rudi Cilibrasi <cilibrar@gmail.com> Co-authored-by: Rudi Cilibrasi <rudi@metagood.com> Co-authored-by: Ayaan Zaidi <hi@obviy.us>
…ruclaw7) * Agents: prefer runtime codex gpt-5.4 metadata * Agents: move codex gpt-5.4 override into provider hook * fix: repair codex runtime preference hooks * fix: use workspace dir for codex runtime preference * test: cover codex workspace dir hook * fix: prefer codex gpt-5.4 runtime metadata (openclaw#62694) (thanks @ruclaw7) --------- Co-authored-by: Rudi Cilibrasi <cilibrar@gmail.com> Co-authored-by: Rudi Cilibrasi <rudi@metagood.com> Co-authored-by: Ayaan Zaidi <hi@obviy.us>
Summary
Fixes
openai-codex/gpt-5.4resolution so an explicit model selection can still prefer provider runtime metadata when the provider reports a larger context window than the static registry entry.This PR now:
openai-codexplugin opt into runtime-preferred resolution via a provider-ownedpreferRuntimeResolvedModelhook instead of a hardcoded core special caseworkspaceDirwhile keepingagentDiravailable separately in contextgpt-5.4runtime-preference pathTesting
pnpm exec vitest run src/agents/pi-embedded-runner/model.test.tspnpm buildFixes #55461
Thanks to Rudi Cilibrasi and Metagood.com for building and funding this fix.