Skip to content

🤖 fix: preserve optional MCP arguments and surface tool errors - #3821

Open
ethanndickson wants to merge 2 commits into
mainfrom
linear-mcp-k6kx
Open

🤖 fix: preserve optional MCP arguments and surface tool errors#3821
ethanndickson wants to merge 2 commits into
mainfrom
linear-mcp-k6kx

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

Adapt MCP tool schemas at the client boundary so models can omit optional non-nullable arguments under OpenAI Responses constrained decoding. MCP application failures now use the normal tool-error path instead of appearing as successful output.

Background

OpenAI Responses can normalise third-party tool schemas into strict mode. Strict mode requires every declared property, which makes an optional non-nullable MCP argument impossible to omit. This produced synthetic null values or fabricated values. Linear then rejected invalid combinations such as statusUpdateType without statusUpdateId.

Mux also treated MCP results with isError: true as successful tool results. The model could not reliably correct the failed call, and application error text such as not connected could incorrectly recycle a healthy MCP client.

Implementation

  • Widen optional properties that deterministically reject null for the provider-facing schema.
  • Remove only those synthetic null values before tools/call and workflow report validation.
  • Preserve required values, source-nullable values, false, zero, empty strings, dictionaries, nested arrays, unions, composition branches, and schema annotations.
  • Keep schemas with $ref, $dynamicRef, or $recursiveRef unchanged and set strict: false. This avoids incomplete reference resolution.
  • Convert MCP application failures into MCPToolCallError while preserving useful text and resource content.
  • Keep the existing binary payload size guard and exclude application failures from client recycling.

The adapter stays at the MCP boundary. It does not add provider-route or schema-dialect configuration.

Validation

The regression coverage includes Linear-shaped optional arguments, required fields declared through composition, union restoration, dictionary schemas, reference fallbacks, schema sanitizer behavior, binary error payloads, and application errors that resemble transport failures.

Risks

The main risk is changing arguments before MCP execution. Restoration is conservative: it removes only optional null values whose source schema deterministically rejects null. Referenced schemas use the non-strict fallback instead of speculative transformation.


Generated with mux • Model: openai:gpt-5.6-sol • Thinking: xhigh

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

Copy link
Copy Markdown

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: 8208bf62df

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
Comment thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed both strict-schema findings in 937e7cdc8 and added regression coverage.

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

Copy link
Copy Markdown

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: 937e7cdc8a

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the constrained optional-schema finding in ac8fa476e and added regression coverage.

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

Copy link
Copy Markdown

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: ac8fa476e9

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the implicit free-form object finding in 85d7a7240 and added regression coverage.

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

Copy link
Copy Markdown

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: 85d7a72400

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the partially open object finding in 0d13ac2ac and added regression coverage.

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

Copy link
Copy Markdown

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: 0d13ac2ac2

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the strict-schema depth finding in 852d9d6af and added boundary coverage.

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

Copy link
Copy Markdown

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: 74eed9af74

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
Comment thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed both strict-schema compatibility findings in 13a98d8f5 and added boundary coverage.

@ethanndickson

Copy link
Copy Markdown
Member Author

Correction: the strict-schema compatibility fixes are in 177b746cf.

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

Copy link
Copy Markdown

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: 177b746cff

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
Comment thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the enum and string-budget findings in a674583db. I also completed an independent audit and fixed type-less schemas, nullable object type arrays, empty unions, multi-type declarations, and workflow fallback strictness.

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

Copy link
Copy Markdown

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: a674583dbe

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
Comment thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the draft-marker and nullable-enum findings in 176baec19 and added regression coverage.

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

Copy link
Copy Markdown

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: 176baec195

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the schema identifier finding in 11db635f4 and added regression coverage for standard and unknown metadata keywords.

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

Copy link
Copy Markdown

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: 11db635f45

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed the unsupported-keyword finding in 18d600514. Every schema node now uses an explicit strict-subset keyword allowlist, with regression coverage for unsupported keywords and non-scalar enum or const values.

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

Copy link
Copy Markdown

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: 18d600514f

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
Comment thread src/node/services/providerModelFactory.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I addressed both findings in 9d80b32b5. Union restoration now preserves raw-valid explicit nulls, and request-level OpenAI wire-format overrides survive provider default merging.

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

Copy link
Copy Markdown

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: 9d80b32b5e

ℹ️ 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 thread src/common/utils/tools/strictToolSchema.ts Outdated
Comment thread src/common/utils/tools/strictToolSchema.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

The latest commit fixes array-union omission restoration and boolean-schema null preservation. Focused tests and make static-check pass.

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

Copy link
Copy Markdown

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: 44190636e7

ℹ️ 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 thread src/node/services/tools/agent_report.ts Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

The latest commit gates workflow omission restoration on successful strict projection across provider validation, tool execution, and terminal finalization. Focused regressions and make static-check pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 8f35de70ee

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

Widen optional MCP properties to nullable model inputs, then strip synthetic nulls before execution. Route MCP application failures through the tool error channel.

Generated with mux • Model: openai:gpt-5.6-sol • Thinking: xhigh
@ethanndickson ethanndickson changed the title 🤖 fix: preserve optional MCP tool arguments 🤖 fix: preserve omitted optional MCP arguments Aug 10, 2026
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

I replaced the previous route-aware strict-schema projection with the MCP boundary adapter in 4b5051847. I also completed a differential audit and fixed required propagation through composition branches, union restoration order, schema annotation preservation, and binary-only error size guards. Focused tests and make static-check pass.

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

Copy link
Copy Markdown

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: 4b50518471

ℹ️ 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 thread src/common/utils/tools/optionalNullSchema.ts
Comment thread src/node/services/mcpServerManager.ts
Generated with mux • Model: openai:gpt-5.6-sol • Thinking: xhigh
@ethanndickson

Copy link
Copy Markdown
Member Author

Addressed both review findings:

  • Reference-based schemas now keep the source contract and set strict: false. This avoids incomplete $ref resolution and prevents OpenAI strict normalisation from forcing optional referenced arguments.
  • MCPToolCallError now bypasses client recycling, even when the application error text resembles a transport failure.

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 39dcaf98cc

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

@ethanndickson ethanndickson changed the title 🤖 fix: preserve omitted optional MCP arguments 🤖 fix: preserve optional MCP arguments and surface tool errors Aug 10, 2026
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.

1 participant