Skip to Content
Recodocs

Airflow AI

Can Airflow Common AI 1.0 classify, query and pause on real Codex calls?

6 min read

What question this set answers

Separate scheduling from judgment. Airflow owns when work runs and the durable task state; the model-led component decides only the reasoning permitted within a task.

Airflow schedules tasks, persists their states and holds work for review. PydanticAI performs model and tool reasoning. The Kit Codex transport supplies ChatGPT-plan inference and a receipt per call.

The notebooks drive Codex inference through the provider's native operators, and a missing grant leaves the task failed with no provider call. It reuses the provider rather than implementing a competing DAG, agent, retry, SQL-validation, approval or durable-state framework. The cited source is Airflow's Common AI 1.0 announcement.

The reader is someone who must show a typed ticket, a revenue figure, a refused call when the grant is missing, a paused draft, or a tool that has not written a file before approval. All business inputs are fictional fixtures. Every successful model experiment uses actual inference: there is no replay, canned answer or scripted judge fallback. Notebook review responses are automated test actions. No Slack, email or customer system is contacted.

How to run it

From the standalone recohut-kit root, with conda environment rs3:

conda activate rs3
python -m pip install --no-deps -e . -e packages/pydantic-ai
python -m pip install nbformat nbclient ipykernel requests
python -m ipykernel install --user --name kit-airflow-rs3 --display-name 'Kit Airflow (conda rs3)'
export KIT_CODEX_AUTH_DIRECTORY="$(cd ../travel-marketplace-agent/data/local/codex-auth && pwd)"
export AIRFLOW_UID="$(id -u)"
cd examples/airflow-ai
mkdir -p .runtime
docker compose up -d --build

The image installs Airflow 3.3.2, Common AI 1.0.0, SQLite provider 4.3.4, PydanticAI slim 2.57.0 and OpenAI SDK 3.35.1. It removes LiteLLM, unused here, because that package requires an OpenAI release below 3. python -m pip check verifies the image. Notebook Python stays in conda rs3 on the host. Docker Python is Airflow's runtime. Leave Airflow out of the shared conda environment.

Open http://127.0.0.1:18083. Metadata is SQLite in a named volume, with all-admin access on loopback. The README says not to publish that service. The auth directory is mounted writable. No token is copied into DAGs, notebooks, images or connections.

Select kernel Kit Airflow (conda rs3) and run from examples/airflow-ai in table order. A repeat creates another run; stop after one result. Codex is the selected route. If it is unavailable, point llm_conn_id at a real Ollama or DeepSeek pydanticai connection only after recording the failure. No alternate was necessary when Codex acceptance succeeded. This lab does not enable an automatic fallback chain.

docker compose stop keeps evidence. docker compose down removes the container and network and retains the named metadata volume and local files. Import errors: docker exec recohut-kit-airflow-ai airflow dags list-import-errors -o json. Dependencies: docker exec recohut-kit-airflow-ai python -m pip check.

Notebook 10 needs the optional OpenSandbox service, with conda rs3 active in this directory. Leave start running, then register from another terminal:

python sandbox_service.py init
python sandbox_service.py start
python sandbox_service.py register

init uses the OpenSandbox 1.1.1 example and will not overwrite an existing configuration. register creates only connection kit_sandbox, after Airflow is up. The service binds loopback port 18084; the connection allows a 180-second request deadline, and each sandbox expires after 300 seconds. Stop it with Ctrl-C.

Notebooks

NotebookWhat it doesRecorded output
01-ticket-classification.ipynbClassifies fictional ticket T-101 with LLMOperator, a typed XCom and an independent checkeryes
02-revenue-investigation.ipynbExplains an EUR 2,400 net drop with AgentOperator and an allowlisted SQLToolsetyes
03-routing-and-visible-failure.ipynbRoutes with LLMBranchOperator, then fails a DAG that has no grantyes
04-files-sql-and-schema.ipynbExtracts invoice INV-42, generates read-only SQL and reports schema driftyes
05-durable-and-retry-policies.ipynbLooks up shipment SH-42 with durable=True and classifies a bad amount with both retry policiesyes
06-output-approval-pause-and-resume.ipynbPauses a finance draft on the scheduler, REST API and triggerer, then approves and rejectsyes
07-tool-approval-before-effect.ipynbDefers a HookToolset tool before it writes a local outbox fileyes
08-mcp-and-object-storage.ipynbReviews a late return with stdio MCP and a rooted object-storage toolsetyes
09-scheduler-recovery-and-durable-replay.ipynbRecovers a shipment task after an injected exception, using the scheduler and the durable journalyes
10-sandboxed-refund-calculation.ipynbAdds two fictional refunds in an optional OpenSandbox containeryes

What the recorded outputs show

Notebooks 01 to 05 and 08 print Apache Airflow 3.3.2, Common AI 1.0.0, pydantic-ai-slim 2.57.0, openai 3.35.1 and recohut-kit 0.6.14.

Notebook 01, kit_ai_ticket, exits 0. classify and verify succeed on try 1. The check line says T-101 is billing/urgent with evidence and that a Codex receipt was recorded. The execution field is real Airflow DAG test, persisted SQLite task metadata.

Notebook 02, kit_ai_revenue, exits 0. investigate, seed and verify succeed on try 1. The check line reads 11800 -> 9400 = 2400 drop, with evidence limited to orders and refunds.

Notebook 03 records two runs. kit_ai_route exits 0: route and urgent_billing succeed, technical is skipped, and the check line records a Codex receipt. kit_ai_missing_auth exits 1: must_fail is failed, validated_results is empty, and the check line says there was no answer and no provider call.

Notebook 04 records three successes. INV-42 is EUR 1800 and overdue. Read-only SQL returned 2400. The schema is incompatible because amount_eur is missing from invoice_target, and the migration was not executed.

Notebook 05 records two successes. The durable check line says the analyst looked up SH-42 through the real tool and reported the 6-hour port delay. The retry check line says both model-backed policies classified the malformed amount as a data error (FAIL, no retry), with no fallback and at least two Codex receipts. Later notebook text quotes a reason that names the amount banana, and a classifier reason with confidence=n/a.

Notebook 06 prints kit_ai_approval and two awaiting_input checkpoints whose options are Approve and Reject. Run manual__2026-10-21T07:04:11.175610+00:00 approves: run and released are success. Run manual__2026-10-21T07:04:56.023823+00:00 rejects: the run is failed and released is upstream_failed.

Notebook 07 prints kit_ai_tool_approval. Both runs report effect_before_approval false. Reject on manual__2026-10-21T07:05:35.799930+00:00 leaves tool_effect_present false. Approve on manual__2026-10-21T07:06:02.842695+00:00 leaves it true. Both runs stay success.

Notebook 08, kit_ai_reference_tools, succeeds for seed, review and verify. The check line says the MCP policy is 14 days, the CSV total is EUR 3400, manual review is required, and no refund was issued.

Notebook 09 queues recovery_fc4af1857d4e48c4832eead9fa5817f0. Observed states are null, running, up_for_retry, running and success on recover_shipment. run_after is 2026-10-21T07:02:01.744106Z.

Notebook 10 queues sandbox_9d8d330e21e04285ab2a4796623653db. The proof answer contains {"total_eur": 3400} and {"credentials_absent": true}. command_calls names run_command.

What is not shown

CLI experiments use real airflow dags test with persisted task metadata. The README says that does not prove scheduled operation. Approval notebooks use the scheduler, REST API and triggerer. SQLite fits this local sequential set. Do not infer production concurrency, tenant isolation or secure warehouse authorization.

Notebook 01 is one ticket and sends no customer message. Notebook 02's allowlist is an application guardrail, not a database security boundary. Notebook 04 does not run the suggested migration. Notebook 05's opening says the durable run is not crash or restart replay, and the policy run is not scheduler-driven retry timing. Notebooks 06 and 07 are automated reviews. Release only prints locally. Notebook 08 does not establish a remote merchant, cloud storage or authority to issue a refund.

Notebook 09 verifies a scheduler retry and one tool lookup after a post-model exception. That does not establish process-kill recovery, a classifier-selected retry delay, or exactly-once behavior for arbitrary external effects. Notebook 10's text says the stored outputs do not show the sandbox closing. The credential check is narrow. Isolation is a Docker container, not a microVM, and the host has no sbx binary. Logged dollar estimates are not Codex-credit charges. The llamaindex extra is omitted. The Codex connection is a Responses route, not a batch service.

A verification note dated 2026-10-21 says notebooks 05 to 09 executed clean that day (0 error cells, 0 unexecuted cells each). Notebook 07 failed once on "servers are currently overloaded" and passed on re-run. That note says notebook 10 was not run in that pass and remains unvalidated. The notebook 10 file still holds two recorded outputs.

Where it fits in the kit

Notebooks 01–05 and 08 import lab and call inspect_runtime, run_dag, usage_count and require_tasks; notebook 05 also uses lab.STATE, and notebooks 09 and 10 import STATE from lab. Shown notebook cells also import json, ast, pathlib, subprocess, time, uuid, urllib.parse and requests. No shown cell imports airflow, pydantic_ai or recohut_kit.

The optional extra is recohut-kit[airflow-ai]. The kit core stays standard-library-only and imports Airflow only when the integration is selected. The apache_airflow_provider entry point registers pydanticai_codex. Native operators dispatch that connection through PydanticAIHook.get_hook. integrations.airflow_ai.policies.LLMRetryPolicy and ClassifierRetryPolicy extend only _hook. The experiment requires live receipts and rejects fallback reasons.

How is this page?

Last updated on