Imported from borsepri/Apache-Airflow (
.venv/Lib/site-packages/airflow/api_fastapi/execution_api/AGENTS.md). Install upstream withnpx skills add borsepri/Apache-Airflow --skill execution_api. Copyright stays with the author.
Execution API — Agent Instructions
Versioning
This API uses Cadwyn with CalVer (vYYYY_MM_DD.py).
Workers and API servers deploy independently, so backward compatibility is critical — older clients must work with newer servers.
When Making Changes
- Check the latest version file in
versions/. If its date is in the future (unreleased), add yourVersionChangeclass to that file. Otherwise create a newvYYYY_MM_DD.py. - Update the version bundle in
versions/__init__.pyonly when creating a new file. - Regenerate Task SDK models:
cd task-sdk && python dev/generate_task_sdk_models.py
- Add tests for both the new and previous API versions.
Common Patterns
- New schema field:
schema(Model).field("name").didnt_exist - New endpoint:
endpoint("/path", ["GET"]).didnt_exist - Response changes: implement
@convert_response_to_previous_version_for(Model)and check field existence before popping.
Pitfalls
- Don't use keyword arguments with
endpoint()— use positional:endpoint("/path", ["GET"]). - Don't add changes to already-released version files.
- Don't forget response converters for new fields in nested objects.
Adding a New Feature End-to-End
Adding a new Execution API feature touches multiple packages. All of these must stay in sync:
- Datamodels — add request/response schemas in
datamodels/. - Route — add the endpoint in
routes/. - Version migration — add Cadwyn
VersionChange(see above). - Task SDK message types — add request/response to
task-sdk/src/airflow/sdk/execution_time/comms.py. - Task SDK client — add the client method in
task-sdk/src/airflow/sdk/api/client.py. - Supervisor — handle the new message in
task-sdk/src/airflow/sdk/execution_time/supervisor.py. - Dag processor & triggerer exclusions — these use
InProcessExecutionAPIand have explicit message type unions. Add new types to their handler or exclusion lists inairflow/dag_processing/processor.pyandairflow/jobs/triggerer_job_runner.py. - Regenerate models —
cd task-sdk && python dev/generate_task_sdk_models.py. - Tests — if the new message type requires an API endpoint, add tests in all of these:
airflow-core/tests/unit/api_fastapi/execution_api/— endpoint teststask-sdk/tests/task_sdk/api/test_client.py— client method teststask-sdk/tests/task_sdk/execution_time/test_supervisor.py— add aRequestTestCaseentry toREQUEST_TEST_CASESlisttask-sdk/tests/task_sdk/execution_time/test_task_runner.py— task runner integration tests
Key Paths
- Models:
datamodels/ - Routes:
routes/ - Versions:
versions/ - Message types:
task-sdk/src/airflow/sdk/execution_time/comms.py - Client:
task-sdk/src/airflow/sdk/api/client.py - Supervisor:
task-sdk/src/airflow/sdk/execution_time/supervisor.py - Dag processor handler:
airflow-core/src/airflow/dag_processing/processor.py - Triggerer handler:
airflow-core/src/airflow/jobs/triggerer_job_runner.py - Task SDK generated models:
task-sdk/src/airflow/sdk/api/datamodels/_generated.py - Full versioning guide:
contributing-docs/19_execution_api_versioning.rst
Token Scope Infrastructure
Token types ("execution", "workload"), route-level enforcement via ExecutionAPIRoute + require_auth, and the ti:self path-parameter validation are documented in the module docstring of security.py.