Skip to content

fix(codex): drop Claude model ids from compiled Codex agents - #3481

Closed
JohnnyXu (xubenqiang) wants to merge 5 commits into
microsoft:mainfrom
xubenqiang:fix/codex-drop-claude-model-alias
Closed

JohnnyXu (xubenqiang) wants to merge 5 commits into
microsoft:mainfrom
xubenqiang:fix/codex-drop-claude-model-alias

Conversation

@xubenqiang

Copy link
Copy Markdown
Contributor

Fixes #3477

Problem

apm install with targets claude,codex compiles one source agent for both harnesses, and _write_codex_agent() copied the model frontmatter value into the Codex TOML verbatim:

name = "ks-agent"
description = "probe agent"
model = "sonnet"            # not a Codex model, copied with no warning

Claude aliases (opus, sonnet, haiku, inherit) and claude-* ids are not valid Codex models, so the generated .codex/agents/<name>.toml is unusable while the Claude side needs the pin.

Fix

When compiling for Codex, a model that names a Claude alias or claude-* id is dropped, and the drop is reported through the existing lossy-compilation diagnostic (the same channel used for a non-string model and for user-invocable):

    _CLAUDE_MODEL_ALIASES = frozenset({"opus", "sonnet", "haiku", "inherit"})

    @staticmethod
    def _is_claude_model(value: str) -> bool:
        normalized = value.strip().lower()
        return normalized in AgentIntegrator._CLAUDE_MODEL_ALIASES or normalized.startswith(
            "claude-"
        )

The diagnostic tells the user to add a codex: block with a Codex model or to drop model from the shared source, then rerun apm install. A Codex model id (gpt-5-codex) is preserved unchanged, and model_reasoning_effort is untouched.

Verification

Two tests are added to tests/unit/integration/test_agent_integrator.py:

  • test_codex_agent_drops_claude_model_alias: model: sonnet produces a TOML without a model key and exactly one lossy warning mentioning the Claude model.
  • test_codex_agent_keeps_codex_model: model: gpt-5-codex stays in the TOML and produces no warning.

Before the fix (production file reverted, tests kept):

drops_claude_model_alias: AssertionError: assert "model" not in parsed

After:

drops_claude_model_alias: PASS
keeps_codex_model: PASS

ruff check and ruff format --check pass on both changed files.

Notes

  • This implements the issue's "minimum" option; the fuller per-target codex: override block in agent frontmatter is a separate, larger feature and is not included.
  • The codex: block is mentioned in the diagnostic as the intended workaround, but the parser does not read it yet, so the working mitigation today is to drop model from the shared source or ship separate agents.

`_write_codex_agent()` copied the `model` frontmatter value verbatim into the
Codex TOML, so a shared agent source with `model: sonnet` produced an invalid
`.codex/agents/<name>.toml` while Claude kept its pin.

Drop a Claude alias (`opus`, `sonnet`, `haiku`, `inherit`) or `claude-*` id
when compiling for Codex and report it through the existing lossy-compilation
diagnostic, pointing at the `codex:` override.

Fixes microsoft#3477

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Thanks JohnnyXu (@xubenqiang) for the fix and for flagging the Claude-alias problem. Daniel approved a narrower scope on #3477 (see the apm-scope:v1 record there), so this PR is not accepted as-is: OpenAPM req-tg-015 and the accepted #3126 scope require the Codex agent compile to keep a declared model value exactly as written, and this PR drops it. The suggested codex: block is the separate open question in #3324.

What would fit the approved scope: keep the generated TOML byte-identical and emit a lossy-compilation warning naming the agent when the model is a Claude alias (opus, sonnet, haiku, inherit) or a claude-* id, without including other frontmatter values in the warning. Add tests for each alias and a claude-* id, and keep the req-tg-015 conformance tests passing. If you are happy to rework this PR along those lines, please update it and link the record.


Generated by autopilot-issue-triage-worker. This comment is AI-generated and may contain errors.

The approved scope on microsoft#3477 (apm-scope:v1, comment 6772353800) and
OpenAPM req-tg-015 require the Codex agent compile to preserve a
source-declared model string exactly as written. Reshape the change
from dropping a Claude alias (opus, sonnet, haiku, inherit) or claude-*
id to keeping it and emitting a names-only lossy-compilation warning
that names the agent and the field, never the model value or other
frontmatter values. Drop the 'codex:' block suggestion, which belongs
to the separate microsoft#3324 question and is not read by the parser.

Tests cover every alias plus claude-* ids (TOML byte-identical to the
pre-change rendering, one warning), non-Claude strings (no warning), and
the names-only guarantee. Docs, apm-guide and CHANGELOG updated.

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>
The no-validation sentence read as contradicting the new Claude-model
warning. State that the warning is the one name-only model check, that
the value is still kept as written, and add the remediation clause to
the apm-guide resource. Addresses panel doc-writer follow-up on microsoft#3481.

Co-authored-by: Copilot App <[email protected]>
The Claude-model warning added for microsoft#3477 sits in the req-tg-015 Codex
conversion path. Add a req-tg-015 conformance test proving opus, sonnet,
haiku, inherit and a claude-* id are still written verbatim and never
echoed in a diagnostic, so the reshape cannot regress to dropping the
value. Regenerate CONFORMANCE.{json,md} from the full suite. Cites the
spec for the Mode B silent-extension gate.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_now

Delta clean: doc fold verified, req-tg-015 conformance tests pinned. Ship once CLA clears.

panel-mode=delta; personas=doc-writer,test-coverage-expert,apm-ceo (earlier lean pass this run: test-coverage-expert, doc-writer, cli-logging-expert [ad hoc: the only user-visible change is a new warning], apm-ceo)

cc JohnnyXu (@xubenqiang) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

Thanks JohnnyXu (@xubenqiang) for the fix. Per the approved apm-scope:v1 record on #3477, this PR was reshaped on your branch (maintainer edits; your commit is kept and credited): the Codex agent compile now keeps a declared model exactly as written (OpenAPM req-tg-015) and emits a names-only lossy-compilation warning, naming the agent, when the value is a Claude alias (opus, sonnet, haiku, inherit) or a claude-* id. The value is no longer dropped, and the codex: block suggestion was removed because that is the separate #3324 question.

Both delta panelists confirm the lean-pass follow-up is resolved. The doc-writer finds the no-validation claim now qualified in both the docs page and apm-guide. The test-coverage-expert confirms the new req-tg-015 conformance cases defend verbatim preservation, with a guard against the value leaking into diagnostics. That conformance test was added to satisfy CI's Spec conformance Mode B gate, which required a spec citation for the changed behaviour.

Aligned with: portable by manifest (req-tg-015 verbatim preservation of model ids is now conformance-tested); secure by default (names-only warning, no frontmatter values echoed); governed by policy (CONFORMANCE.json/md regenerated from the full suite).

Panel summary

Persona B R N Takeaway
Doc Writer 0 0 0 The fold resolves the prior finding in the docs page and apm-guide; no new doc issues.
Test Coverage Expert 0 0 0 5 parametrized req-tg-015 cases defend the preservation MUST without over-claiming the non-normative warning.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

All lean-pass follow-ups are folded and verified. CI: 23 pass, 3 skipping, 0 fail; lint clean; canonical-owner gate passed. The contributor CLA is not signed yet (license/cla pending): JohnnyXu (@xubenqiang), please reply with @microsoft-github-policy-service agree as described above. Once signed, this needs no further code changes.

Folded in this run

  • (panel) Approved-scope reshape: keep the Codex model verbatim and warn, names-only; drop removed; tests, docs, apm-guide and CHANGELOG updated -- resolved in e850547.
  • (panel) doc-writer: qualify the no-validation docs claim as the one name-only check and add the remediation clause to apm-guide -- resolved in 9a2f630.
  • (panel) CI Mode B gate: req-tg-015 conformance test pinning verbatim preservation of Claude model ids; CONFORMANCE.{json,md} regenerated -- resolved in 07c5d5e.

Copilot signals reviewed

  • Review 5785478526 -- NOT-LEGIT: only reports insufficient quota; zero inline comments across 2 fetch rounds.

Regression-trap evidence (mutation-break gate)

  • test_codex_agent_keeps_claude_model_verbatim_and_warns -- deleted the _warn_codex_claude_model call; 8 tests FAILED as expected; guard restored.
  • test_codex_agent_keeps_claude_model_verbatim_and_warns -- re-added the model drop; 8 tests FAILED as expected; guard restored.

Lint contract

ruff check and ruff format --check (src/, tests/, architecture linter scripts) silent; pylint R0801 clean; auth-signal and architecture-boundary lints clean.

CI

23 pass, 3 skipping, 0 fail on 07c5d5e; license/cla pending (after 1 CI fix iteration: Spec conformance Mode B).

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3481 07c5d5e ship_now 1 3 0 2 yellow MERGEABLE BLOCKED CLA unsigned (license/cla pending)

Convergence

1 outer iteration; 2 Copilot rounds. Final panel stance: ship_now. Ready for maintainer review once the CLA is signed.

Full per-persona findings

Doc Writer

No findings (delta). Lean pass: one recommended finding (no-validation claim read as contradictory next to the new warning), folded in 9a2f630.

Test Coverage Expert

No findings.

CLI Logging Expert (lean pass only)

No findings: wording follows sibling Codex diagnostics, correct category, ASCII-safe, names-only, actionable.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Adds the Fixed entry for #3650, crediting @xubenqiang for the original
#3481 change.

Refs #3477

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator

Thank you JohnnyXu (@xubenqiang) for this fix and for flagging the Claude-alias problem in #3477.

To ship it in 0.36.0 we rebuilt the same reviewed change (warning-only, model kept verbatim per the approved scope on #3477) on fresh main as #3650. We did this because the CLA on this PR has stayed pending for 6+ days and the CLA check blocks merge. Your authorship is credited via Co-authored-by on every commit of #3650, the PR body links back here, and the CHANGELOG entry credits you.

Closing this PR in favor of #3650. If anything there diverges from your intent, please comment on #3650 -- we would welcome your review.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
…edes #3481, closes #3477) (#3650)

* fix(codex): warn on Claude model ids in compiled Codex agents

A shared Claude/Codex agent source with `model: sonnet` (or another
Claude alias or claude-* id) compiles into a Codex TOML whose model
Codex does not recognize, with no signal to the author. Per the
approved #3477 scope and OpenAPM req-tg-015, keep the declared model
string exactly as written and emit a names-only lossy-compilation
warning naming the agent and the field, never the model value or any
other frontmatter value.

Tests cover each alias plus claude-* ids (TOML byte-identical, one
warning), non-Claude strings (no warning), the names-only guarantee,
and req-tg-015 verbatim preservation in the conformance suite.
CONFORMANCE.{json,md}, docs and apm-guide updated.

Rebuilt from #3481 by @xubenqiang to ship in 0.36.0.

Refs #3477

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* docs(changelog): note Codex Claude-model warning

Adds the Fixed entry for #3650, crediting @xubenqiang for the original
#3481 change.

Refs #3477

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* docs(codex): drop stale "#3477 tracked" model-warning lines

Both per-harness model sections still described the Claude-model
warning as future work tracked in #3477, contradicting the shipped
warning described a few paragraphs above. Point back to it instead.

Addresses panel doc-writer follow-up on #3650.

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* test(codex): prove Claude-model warning reaches apm install output

The unit tests call _write_codex_agent directly; add a real-binary
e2e variant so the new _is_claude_model branch is proven reachable
from apm install: model kept verbatim in the TOML, names-only warning
in CLI output, value never echoed. The native-model sibling now also
asserts no Claude-model warning for a Codex model.

Addresses panel test-coverage-expert follow-up on #3650.

Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: xubenqiang <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex agent compile copies Claude model aliases verbatim (model: opus -> model = "opus")

3 participants