Repository navigation
Add an OpenAI Codex adapter that lets Codex call common.ai toolsets - #76000
Merged
Merged
Conversation
Lee-W
force-pushed
the
common-ai-openai-codex
branch
2 times, most recently
from
November 2, 2026 04:49
18b4b43 to
427bd8a
Compare
Member
Lee-W
force-pushed
the
common-ai-openai-codex
branch
7 times, most recently
from
November 13, 2026 06:08
21f647b to
e2b436b
Compare
Lee-W
marked this pull request as ready for review
November 13, 2026 06:46
Lee-W
requested review from
amoghrajesh,
ashb,
gopidesupavan,
kaxil and
potiuk
as code owners
November 13, 2026 06:46
kaxil
reviewed
Nov 15, 2026
Lee-W
force-pushed
the
common-ai-openai-codex
branch
from
November 16, 2026 03:09
08cbad1 to
4815f4a
Compare
Member
Author
|
The Codex adapter now passes an MCP hint to |
Lee-W
force-pushed
the
common-ai-openai-codex
branch
from
November 17, 2026 07:58
4815f4a to
c4739a8
Compare
kaxil
reviewed
Nov 17, 2026
Lee-W
force-pushed
the
common-ai-openai-codex
branch
from
November 18, 2026 02:04
c4739a8 to
51f6ab3
Compare
Member
|
@Lee-W Would appreciate screenshots/gif/demo of a working dag |
Lee-W
force-pushed
the
common-ai-openai-codex
branch
2 times, most recently
from
November 18, 2026 06:26
0594d06 to
18573c4
Compare
Contributor
|
Quickest fix: git fetch upstream main && git rebase upstream/main
rm uv.lock && uv lock
git add uv.lock && git rebase --continue
git push --force-with-leaseAutomated nudge — ignore if you're not ready to rebase. This comment is updated in place on future |
Lee-W
force-pushed
the
common-ai-openai-codex
branch
from
November 18, 2026 23:59
18573c4 to
cb493a4
Compare
kaxil
reviewed
Nov 19, 2026
Member
Author
kaxil
approved these changes
Nov 19, 2026
Lee-W
force-pushed
the
common-ai-openai-codex
branch
from
November 19, 2026 02:32
cb493a4 to
94bdbc8
Compare
Codex runs as a separate harness process, so it can only reach Airflow tools through an MCP server. The adapter serves the tools from a loopback MCP server guarded by a per-run bearer token and starts Codex against an empty home and working directory, so it reads none of the worker's user-level Codex settings. A system-level config under /etc is still read. The adapter is experimental. Tool calls through MCP, removal of the built-in shell tool, the `deny_all` approval mode and `apply_patch` under the read-only sandbox have not been run against a model; the guide lists the manual checks for them.
…adapter - Pass an MCP hint to _collect_tools so the error names Codex's mcp_servers config - Add a test that an MCPToolset raises MCPToolsetNotSupportedError with that hint
The workspace resolves one mcp for every provider, so the lowest-direct resolution installed mcp 2.0.0 and broke the Databricks Unity MCP tests, which check a client error message mcp 2.2.0 added. The openai-codex extra and the dev group now floor mcp at 2.2.0.
…ases conflict with it
Cancelling run(), for example with asyncio.wait_for, now interrupts the turn before the stream is closed. The interrupt is skipped if the turn already completed or a tool-failure interrupt was already sent. The interrupt log message no longer says it follows a tool failure.
The tests' HTTP client relied on httpx2's default 5 second timeout. On the Compat 3.2.2 / Python 3.11 CI job, TestRealMcpServer::test_a_successful_tool_result_is_not_marked_isError hit a ReadTimeout after 5.39 seconds. The cause is not established; it is likely a stall on the shared event loop under load. The client now uses an explicit 60 second timeout. Only the test changes.
The in-process MCP server built its uvicorn.Config without log_config, so uvicorn applied its default logging dictConfig, which disables the task process's existing log handlers. The config now passes log_config=None, as the API server command does. A test pins the value.
The Codex example imported SQLToolset at module level, but it needs the sql extra, which is optional. Dag parsing would fail wherever that extra is not installed. The import now sits in the task next to AirflowTools, as in the Claude Agent SDK example, and the comment covers both extras.
The docs said the task log shows framework=openai_codex. The log shows a Tool call group, and the common_ai.tool_calls metric carries the tag. They also said hook calls run one at a time anyway. The adapter queues only sequential tools, so other tools rely on supports_parallel_tool_calls=false. The retry budget text now says that Codex sends calls one after another, so failed calls in one response each count, here and in the code comment. Only text changes.
…uarantees The retry budget counts failures of calls that run at the same time as one and calls one after another separately. The adapter asks Codex to send calls one at a time, but whether Codex honours that is not confirmed, so the comments and the guide now say "normally" instead of promising it. The comment on supports_parallel_tool_calls no longer cites the docs, and the uvicorn comment says what the default logging config does: it removes and closes the task process's log handlers. The example now tells users to install the sql extra too, since its task uses SQLToolset.
The supports_parallel_tool_calls row now says the flag asks Codex not to send calls in parallel, matching the note that Codex's compliance is not yet confirmed. The uvicorn log_config comment is wrapped to fit the line length limit.
The docs spelling check rejects "honours", which failed the documentation build. The same sentence in the adapter comment is changed to match.
…is passed build_thread_options() now rewrites a nested config["mcp_servers"] table into dotted mcp_servers.<name>.<key> keys. Codex replaces a nested table as a whole at thread level, so the adapter's own server and its required=true were dropped and the thread started without any Airflow tools. The same-name check now also covers dotted keys, and a server or setting name that cannot be written as a dotted key raises ValueError.
AirflowTools.run() now marks the run ended before it waits up to 10 s for the Codex turn interrupt on cancellation. A tool call that arrives in that window is answered with a "Not run" result instead of executing its hook. Cover both outcomes of a failing stream close: it propagates after a completed turn, and it is logged while the tool failure is raised.
The Codex guide said the adapter is tested with openai-codex 0.163.0 but did not say that Airflow's lock, and so CI, resolves 0.167.0. Say it was first tested with 0.163.0 and that the lock and CI have 0.167.0, as the guide already does for mcp. Set execution_timeout on the example task, as the guide advises, so the example cannot loop on model responses without limit. Move the note on draining connections from the start timeout to _SERVER_SHUTDOWN_TIMEOUT_SEC, which is what it describes.
The Codex docs no longer say which Codex version or environment the adapter was tested on, and the installation section no longer cites the versions Airflow's lock resolves to. The note on MCP server names keeps the fact that Codex rejects a quoted key segment. The example task now allows 30 minutes instead of 10. Ten minutes equals the adapter's default tool timeout, so one tool call that ran to its timeout would use up the whole task budget.
Lee-W
force-pushed
the
common-ai-openai-codex
branch
from
November 19, 2026 10:19
cd6a559 to
b8a7b7d
Compare
Lee-W
enabled auto-merge (squash)
November 19, 2026 11:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Why
Codex runs as a separate harness process, so it can only reach Airflow tools through an MCP server. This adds an adapter that serves the
common.aitoolsets to it, like the existing Strands, ADK, Anthropic, OpenAI Agents and Claude Agent SDK adapters. The adapter is experimental: tool calls through MCP, removal of the built-in shell tool,deny_allapproval andapply_patchunder the read-only sandbox have not been run against a model, and the guide lists the manual checks.What
AirflowTools(tools/openai_codex.py) serves toolsets to Codex from a loopback MCP server guarded by a per-run bearer token.CODEX_HOME,HOMEandcwd, its shell tool is turned off, and the thread defaults todeny_allapproval with aread_onlysandbox. A system-level config under/etcis still read. Known limits are in the guide.isErrorresult. Any other failure interrupts the turn andrun()raisesToolCallError.MCPToolsetis rejected withMCPToolsetNotSupportedError, and the message points to Codex'smcp_serversconfig.openai-codexextra and the dev group floormcpat 2.2.0. The workspace resolves onemcpfor every provider, and the lowest-direct resolution installed 2.0.0, which broke the Databricks Unity MCP tests that check an error message 2.2.0 added.docs/frameworks/openai_codex.rst), an example Dag, and theopenai_codexvalue for theframeworktag ofcommon_ai.tool_calls.Was generative AI tooling used to co-author this PR?
Generated-by: [Claude] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.