Skip to content

fix(codex): warn on Claude model ids in compiled Codex agents (supersedes #3481, closes #3477) - #3650

Merged
Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
lanef/supersede-3481
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
lanef/supersede-3481

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

TL;DR

When an agent is compiled for Codex and its model is a Claude alias (opus, sonnet, haiku, inherit) or a claude-* id, APM now emits a names-only lossy-compilation warning naming the agent. The value is still written to the Codex TOML exactly as declared, as OpenAPM req-tg-015 requires. Mixed Claude/Codex packages learn the Codex agent will not work as written instead of failing silently.

Closes #3477

Note

Rebuilt from #3481 by JohnnyXu (@xubenqiang) to ship in 0.36.0; original authorship credited via Co-authored-by. The contributor's CLA stayed pending for 6+ days, so this branch carries the same reviewed change (panel ship_now on #3481 head 07c5d5e) on fresh main.

Problem (WHY)

Approach (WHAT)

# Fix
1 Keep model verbatim in the Codex TOML (byte-identical to today for every input).
2 When the value is a Claude alias or claude-* id (case-insensitive), emit one lossy_agent_compilation diagnostic naming the agent file and the model field.
3 The warning is names-only: it never echoes the model value or any other frontmatter value.

Implementation (HOW)

  • src/apm_cli/integration/agent_integrator.py -- adds _is_claude_model() and _warn_codex_claude_model(); _write_codex_agent() calls the warning only after the string value is already stored, so output is unchanged. Reuses the existing lossy-compilation channel used for non-string model and user-invocable.
  • tests/unit/integration/test_agent_integrator.py -- each alias, mixed case and claude-* ids keep a byte-identical TOML and warn once; non-Claude strings (gpt-5-codex, claude, my-claude-proxy, ...) do not warn; names-only guarantee.
  • tests/spec_conformance/test_manifest_reqs.py + CONFORMANCE.{json,md} -- req-tg-015 cases pinning verbatim preservation of Claude model strings (test_count 1 -> 6).
  • Docs + apm-guide -- instructions-and-agents.md and package-authoring.md qualify the "no model validation" claim with this one name-only check and its remediation, and the per-harness model sections no longer call the warning future work.
  • tests/integration/test_codex_agent_tool_scope_contract.py -- real-binary e2e: the warning reaches apm install output, the model stays verbatim, the value is never echoed.
  • CHANGELOG.md -- Fixed entry.

Trade-offs

Benefits

  1. Authors see one actionable warning per affected agent at apm install time.
  2. Generated Codex TOML stays byte-identical for all inputs (asserted in tests).
  3. No model or frontmatter value is echoed into diagnostics (asserted in tests).

Issue and approved scope

Issue: Closes #3477

Human scope-approval comment: #3477 (comment) (apm-scope:v1, Decision: approve, Daniel Meppiel (@danielmeppiel))

This PR completes the issue's approved scope. Out of scope per the record: per-target model values / codex: block (#3324), dropping or translating model values, model validation for other targets, model_reasoning_effort handling.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Local validation (targeted; CI is the authority)
$ pytest -q -p no:xdist tests/unit/integration/test_agent_integrator.py -k codex
56 passed, 64 deselected in 5.67s

$ pytest -q -p no:xdist tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim \
    tests/spec_conformance/test_manifest_reqs.py::test_codex_native_model_settings_preserved_and_dropped_metadata_bounded
6 passed in 1.75s

# mutation-break: removed the _warn_codex_claude_model call
$ pytest -q -p no:xdist tests/unit/integration/test_agent_integrator.py -k claude_model
8 failed, 6 passed, 106 deselected     # guard removed
14 passed, 106 deselected              # guard restored

$ ruff check / ruff format --check (src/ tests/ + architecture linter scripts)
All checks passed! / 2164 files already formatted
$ pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 ...
Your code has been rated at 10.00/10
$ bash scripts/lint-auth-signals.sh
[+] auth-signal lint clean

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 "My shared agent says model: sonnet; installing for Codex tells me it will not work there." Multi-harness, DevX tests/unit/integration/test_agent_integrator.py::TestCodexAgentIntegration::test_codex_agent_keeps_claude_model_verbatim_and_warns unit
2 "A Codex model id compiles with no noise." Multi-harness, DevX tests/unit/integration/test_agent_integrator.py::TestCodexAgentIntegration::test_codex_agent_non_claude_model_does_not_warn unit
3 "The model I declared is what lands in the Codex TOML." Portability by manifest tests/spec_conformance/test_manifest_reqs.py::test_codex_claude_model_value_preserved_verbatim conformance
4 "Warnings never leak my frontmatter values." Secure by default tests/unit/integration/test_agent_integrator.py::TestCodexAgentIntegration::test_codex_claude_model_warning_is_names_only unit
5 "apm install shows the warning and keeps model: sonnet in the Codex TOML." Multi-harness, DevX tests/integration/test_codex_agent_tool_scope_contract.py::test_codex_agent_claude_model_warning_reaches_cli_output e2e

How to test

  • Create an agent with model: sonnet, run apm install --target codex -> one [!] lossy-compilation warning naming the agent; .codex/agents/<name>.toml has model = "sonnet".
  • Change to model: gpt-5-codex and reinstall -> no warning; TOML keeps the value.

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml updated
  • Test edit: a @pytest.mark.req("req-tg-015") test under tests/spec_conformance/ added (no normative change; the warning is non-normative)
  • CONFORMANCE.{md,json} regenerated and committed (req-tg-015 test_count 1 -> 6)
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: xubenqiang [email protected]
Co-authored-by: Copilot [email protected]

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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.36.0 milestone Nov 12, 2026
Copilot AI balanced review requested due to automatic review settings November 12, 2026 19:02
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]>

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.

🟢 Approval recommended

No active review issues are recorded for the Claude-model warning change.

No open issues 🎉

What changed in this PR

This PR addresses #3477 by warning when APM compiles Claude model names into Codex agents, while preserving the declared model value as required by OpenAPM req-tg-015.

Changes:

  • Adds case-insensitive detection of Claude aliases and claude-* IDs, with actionable warnings that do not expose frontmatter values.
  • Adds regression and conformance coverage for unchanged TOML output, warning behavior, and diagnostic privacy.
  • Updates authoring guidance, conformance records, and the changelog; per-target model overrides remain out of scope.
File Description
tests/​unit/​integration/​test_agent_integrator.py Tests model preservation, warning selection, and names-only diagnostics.
tests/​spec_conformance/​test_manifest_reqs.py Adds five Claude-model preservation cases for req-tg-015.
src/​apm_cli/​integration/​agent_integrator.py Detects Claude model names and emits warnings without changing output values.
packages/​apm-guide/​.apm/​skills/​apm-usage/​package-authoring.md Documents the warning and supported remedies.
docs/​src/​content/​docs/​producer/​author-primitives/​instructions-and-agents.md Clarifies the name-based check and unchanged model preservation.
CONFORMANCE.md Updates req-tg-015 coverage from one to six tests.
CONFORMANCE.json Records the five additional conformance cases.
CHANGELOG.md Records the fix and credits the original contribution.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Ships a Claude-model lossy-compilation warning for Codex agents, crediting community contributor JohnnyXu (@xubenqiang), closing #3477 for 0.36.0.

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

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

All three panelists converge with zero dissent. The cli-logging-expert gave a clean bill: the new warning reuses the established lossy-compilation channel, follows the Message Writing Rules, and introduces no output-UX concerns. The doc-writer caught a real factual contradiction -- both doc pages still describe the Claude-model warning as future work "tracked in #3477" while this PR closes #3477 and ships the feature. The test-coverage-expert confirmed 21 unit and conformance cases with mutation-break verification, and recommended one e2e variant to prove the new _is_claude_model branch is reachable from the real binary (risk is LOW because the same channel is already proven end-to-end with a non-Claude model). Both follow-ups are inside the approved #3477 scope and are being folded into this PR before the terminal delta pass.

Strategically this is a clean community-credit rebuild: Co-authored-by on every commit, the CHANGELOG credit to JohnnyXu (@xubenqiang), and scope discipline (warning only, model kept verbatim per req-tg-015).

Aligned with: portable by manifest (model value preserved byte-identical per req-tg-015; conformance tests 1 -> 6); multi-harness (warning scoped to Codex only and names the agent); OSS community-driven (contributor credited on every commit and in CHANGELOG); pragmatic as npm (warning-only, identical TOML output, no new failure).

Panel summary

Persona B R N Takeaway
Test Coverage Expert 0 1 0 Unit and conformance tests are thorough (21 cases, mutation-break verified); one e2e variant would close the tier-floor gap.
Doc Writer 0 1 0 New warning text is accurate, but both pages still say the warning is only tracked in #3477, which this PR closes.
Cli Logging Expert 0 0 0 New Claude-model warning follows the established lossy-compilation pattern, channel, rendering, and Message Writing Rules.

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

Top 2 follow-ups

  1. [Doc Writer] Remove stale "Codex agent compile copies Claude model aliases verbatim (model: opus -> model = "opus") #3477 tracked as future work" lines from both doc pages that now contradict the shipped feature. -- Factual contradiction; two-line in-scope fix, being folded.
  2. [Test Coverage Expert] Add an e2e variant in test_codex_agent_tool_scope_contract.py with a Claude-model alias to prove the warning reaches CLI output through the real binary. -- The new branch has no end-to-end assertion; in-scope, being folded.

Recommendation

Panel signals are clean and unanimous. The two recommended follow-ups are inside the approved #3477 scope and are being folded into this PR before the terminal delta pass. No strategic, naming, or breaking-change concerns. Ship for 0.36.0.

Copilot signals reviewed

  • Review 5880410434 -- no inline comments; overview recommends approval. Nothing to fold.

Full per-persona findings

Test Coverage Expert

  • [recommended] No e2e test verifies the Claude-model warning reaches CLI output through apm install; the existing e2e test uses a non-Claude model only. at tests/integration/test_codex_agent_tool_scope_contract.py:129
    test_codex_agent_native_models_and_dropped_metadata_reach_cli_output uses model='gpt-5.6-sol', which never triggers _is_claude_model. Unit tests call _write_codex_agent directly.
    Suggested: sibling test with metadata={'model': 'sonnet'} asserting the warning in output and the TOML model unchanged.
    Proof (missing at): tests/integration/test_codex_agent_tool_scope_contract.py::test_codex_agent_claude_model_warning_reaches_cli_output -- proves: the warning reaches CLI output and the model value is preserved [multi-harness-support,devx]

Doc Writer

Cli Logging Expert

No findings.

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-review-worker. This comment is AI-generated and may contain errors.

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]>
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]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Delta fold verified: both recommended follow-ups from the lean pass (stale doc refs, missing e2e test) are resolved; no new findings.

panel-mode=delta; personas=doc-writer,test-coverage-expert,apm-ceo (cli-logging-expert not re-run: agent_integrator.py unchanged since the last panel head)

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

The lean advisory on 6497ea8 raised two in-scope recommended follow-ups. Both landed: the stale "tracked in #3477" lines are gone from both per-harness model sections (b58d66a), and a real-binary e2e test now proves the Claude-model warning reaches apm install output with the model kept verbatim and never echoed (254f7ca). The doc-writer confirms the replacement prose is accurate and consistent across both pages; the test-coverage-expert confirms the new e2e assertions are meaningful and mutation-resistant. The only main merge since the last panel head brought #3651 (unrelated apm view summary), with no conflict.

Aligned with: portable by manifest (req-tg-015: model written exactly as declared, warning is advisory only); multi-harness (Codex-only diagnostic on the existing lossy-compilation channel); OSS community-driven (JohnnyXu (@xubenqiang) credited via Co-authored-by on every commit and in CHANGELOG; CLA-stalled PR rebuilt promptly).

Panel summary

Persona B R N Takeaway
Doc Writer 0 0 0 Prior finding resolved: the stale "tracked in #3477" lines are gone from both sections; the fold adds no new doc issue.
Test Coverage Expert 0 0 0 Prior finding resolved: e2e test proves the warning reaches CLI with meaningful, mutation-resistant assertions; names-only contract defended.

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

Recommendation

Both follow-ups from the lean pass are verified resolved with no regressions and no new findings. Ready for maintainer merge at discretion.

Folded in this run

Copilot signals reviewed

  • Review 5880410434 -- no inline comments; overview recommends approval. Nothing to fold.

Regression-trap evidence (mutation-break gate)

  • test_codex_agent_keeps_claude_model_verbatim_and_warns / test_codex_claude_model_warning_is_names_only -- deleted the _warn_codex_claude_model call; 8 tests FAILED as expected; guard restored.
  • test_codex_agent_claude_model_warning_reaches_cli_output (e2e) -- deleted the same call; test 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

26/26 checks green on 62493e0 (incl. Spec conformance gate, Lint, both Build & Test shards, Windows gates, license/cla SUCCESS) after 0 CI fix iterations; the earlier Shard 2 red was main's apm view help truncation, fixed on main by #3651 and merged in.

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3650 62493e0 ship_now 2 2 0 1 green MERGEABLE BLOCKED awaiting required review

Convergence

2 outer iterations; 1 Copilot round. Final panel stance: ship_now. Ready for maintainer review.

Full per-persona findings

Doc Writer

No findings.

Test Coverage Expert

No findings.

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.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 3c3017c into main Nov 12, 2026
27 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the lanef/supersede-3481 branch November 12, 2026 20:37
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Clean merge of #3599, #3647, #3650, #2933; no lockfile or autopilot
package conflicts.

Co-authored-by: sergio-sisternes-epam <[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")

2 participants