Agent cancellation
%%{init: {'look': 'handDrawn', 'theme': 'base', 'themeVariables': {'primaryColor': '#eef2ff', 'primaryBorderColor': '#1e40af', 'primaryTextColor': '#1e293b', 'lineColor': '#1e3a8a', 'edgeLabelBackground': '#ffffff', 'clusterBkg': '#fbfcff', 'clusterBorder': '#2563eb', 'fontFamily': '-apple-system, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif', 'fontSize': '15px'}, 'flowchart': {'nodeSpacing': 50, 'rankSpacing': 58, 'padding': 14, 'htmlLabels': true, 'curve': 'basis'}}}%%
flowchart LR
P(["Prompt"]) --> A("A long-running<br/>agent starts work")
A --> T("The parent workflow<br/>is terminated")
T --> C(["The agent run<br/>stops too"])Outcome: terminate the parent workflow and propagate cancellation to a long-running deployed Conductor Agent.
Start the local MCP Testkit server and deploy the cookbook agents before running this fixture. The deployed agent uses gpt-4o and exposes the complete Testkit catalog only for local demonstration; production deployments must use a scoped allowlist and per-tool policy.
Runnable definition
Save this as conductor-agent-cancellation.json:
{
"name": "conductor_agent_cancellation",
"version": 1,
"schemaVersion": 2,
"description": "Derived from ai/examples/34-conductor-agent-cancel.json. A FORK_JOIN races a long-running deployed agent task against a control branch that terminates the workflow.",
"tasks": [
{
"name": "fork_cancel",
"taskReferenceName": "fork_cancel_ref",
"type": "FORK_JOIN",
"forkTasks": [
[
{
"name": "run_long_agent",
"taskReferenceName": "run_long_agent_ref",
"type": "AGENT",
"inputParameters": {
"agentType": "conductor",
"name": "guarded-incident-planner",
"prompt": "${workflow.input.prompt}",
"maxDurationSeconds": 86400
}
}
],
[
{
"name": "cancel_run",
"taskReferenceName": "cancel_run_ref",
"type": "TERMINATE",
"inputParameters": {
"terminationStatus": "TERMINATED",
"terminationReason": "Cancelling the in-flight conductor agent run"
}
}
]
]
},
{
"name": "join_cancel",
"taskReferenceName": "join_cancel_ref",
"type": "JOIN",
"joinOn": [
"run_long_agent_ref",
"cancel_run_ref"
]
}
]
}
Register and run
Download deploy_local_cookbook_agents.py into the same directory, then:
python3 deploy_local_cookbook_agents.py deploy
python3 deploy_local_cookbook_agents.py serve
conductor workflow create conductor-agent-cancellation.json
conductor workflow start -w conductor_agent_cancellation -i '{"prompt":"Investigate a long-running incident."}'
The TERMINATE branch is intentionally part of the copied source graph. Confirm the parent is TERMINATED and inspect the agent execution record to verify cancellation propagation; do not count this negative-path execution as a successful agent action.