Skip to content

core/app-server: preflight image modality mismatch with typed error#10697

Closed
ccy-oai wants to merge 1 commit intomainfrom
ccy/input-modality-preflight-error
Closed

core/app-server: preflight image modality mismatch with typed error#10697
ccy-oai wants to merge 1 commit intomainfrom
ccy/input-modality-preflight-error

Conversation

@ccy-oai
Copy link
Collaborator

@ccy-oai ccy-oai commented Feb 5, 2026

Summary
  • Add an authoritative core preflight that blocks turns when the selected model is text-only and the final outgoing payload contains image inputs (including history/tool outputs).
  • Introduce a typed non-retryable modality error surface (unsupportedInputModality) through protocol and app-server v2.
  • Regenerate app-server protocol schema/TS fixtures for downstream clients.
  • Update docs/model-update.md with the implemented contract and client handoff details.
Rationale (from spec findings)
  • UI-only gating cannot reliably predict final payload after history normalization/compaction/tool outputs.
  • Core has authoritative visibility into what is actually sent, so correctness should be enforced there.
  • Typed errors let clients handle this path explicitly instead of generic retries/fallbacks.
Scope
  • codex-rs/core: preflight check + error mapping.
  • codex-rs/protocol: image detection helpers + new error variant.
  • codex-rs/app-server-protocol: v2 error variant + generated schema/types.
  • docs/model-update.md: implementation-focused spec notes for consumer clients.
Trade-offs
  • Added schema fixture churn from the new error variant in protocol exports.
  • Preflight currently checks the assembled outgoing payload; future optimization can cache modality summary state, but this keeps behavior correct today.
Client follow-up
  • Consumers should treat codexErrorInfo.unsupportedInputModality as non-retryable.
  • Show remediation UX (switch to image-capable model or fork/reset context).
  • Keep existing composer gating as best-effort UX; rely on server preflight for source-of-truth enforcement.
Testing
  • cargo fmt --all
  • cargo check -p codex-protocol -p codex-core -p codex-app-server-protocol -p codex-app-server
  • cargo test -p codex-app-server-protocol unsupported_input_modality -- --nocapture

@ccy-oai ccy-oai force-pushed the ccy/input-modality-preflight-error branch from f9af4d9 to 0e2d752 Compare February 5, 2026 01:46
Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9af4d9576

ℹ️ 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".

Comment on lines 3884 to +3886
) -> CodexResult<SamplingRequestResult> {
preflight_validate_sampling_input_modalities(turn_context.as_ref(), &input)?;

Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Badge Apply modality preflight beyond sampling requests

This new preflight only runs in run_sampling_request, so any other model calls that build a Prompt directly (e.g., compaction via run_compact_task_inner/drain_to_completed in core/src/compact.rs) still send image-bearing history to text-only models. In practice, a thread with images that triggers auto‑compaction (or a manual compact) will bypass the new typed error and still hit provider 400s. If the goal is an authoritative guard for all outgoing payloads, the same check needs to be enforced in the compaction path (or centralized before any prompt is streamed).

Useful? React with 👍 / 👎.

@etraut-openai etraut-openai added the oai PRs contributed by OpenAI employees label Feb 9, 2026
@ccy-oai ccy-oai closed this Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai PRs contributed by OpenAI employees

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants