Deferred Execution
Queue long-running executions, get an immediate tracking ID, and finish with polling or webhooks
Fire an execution without waiting for the result. Come back later -- or let a webhook tell you when it finishes.
Request/response is the wrong abstraction for many AI workloads. Model latency varies, multi-agent chains compound it, and long-running work should not tie up an HTTP request.
This page covers deferred execution: POST /api/v1/execute/async/{target} queues work and returns immediately. Synchronous execution still exists at POST /api/v1/execute/{target} when you want the result inline.
AgentField's deferred execution model pushes work to a durable queue, returns a tracking ID immediately, and lets you finish with polling, batch status, or a webhook.
import asyncio
from agentfield import Agent
app = Agent(node_id="orchestrator", version="1.0.0")
@app.reasoner()
async def generate_quarterly_report(quarter: str) -> dict:
# Fire three analyses in parallel — async execution is automatic
financial, market, customer = await asyncio.gather(
app.call("finance.deep_analysis", quarter=quarter),
app.call("research.market_trends", quarter=quarter),
app.call("analytics.churn_report", quarter=quarter),
)
return {"sections": [financial, market, customer]}# Fire an async execution — returns 202 immediately with a tracking ID
curl -X POST http://localhost:8080/api/v1/execute/async/finance.deep_analysis \
-H "Content-Type: application/json" \
-d '{
"input": { "quarter": "Q1-2026" },
"webhook": {
"url": "https://your-api.com/hooks/done",
"secret": "whsec_your_hmac_secret"
}
}'
# → {"execution_id":"exec_a1b2c3","status":"queued","webhook_registered":true}
# No polling needed — the webhook fires on completion.
# But if you want to check manually:
curl http://localhost:8080/api/v1/executions/exec_a1b2c3
# → {"status":"succeeded","result":{...},"duration_ms":14200}
# Batch status — check hundreds of executions in one round trip
curl -X POST http://localhost:8080/api/v1/executions/batch-status \
-H "Content-Type: application/json" \
-d '{"execution_ids": ["exec_a1b2c3", "exec_d4e5f6", "exec_g7h8i9"]}'What just happened
- Three long-running sub-tasks were queued immediately instead of blocking the request
- The caller got stable tracking IDs for later inspection
- Completion could be handled by polling, batch waiting, or webhook delivery
Example lifecycle:
{ "execution_id": "exec_a1b2c3", "status": "queued" }
{ "execution_id": "exec_a1b2c3", "status": "running" }
{ "execution_id": "exec_a1b2c3", "status": "succeeded", "duration_ms": 14200 }