PromptForge
Back to list
AI AgentAgent异步编排状态机分布式

AI Agent 异步任务编排与回调设计模板

为多步骤 AI Agent 设计异步任务编排方案,包含重试、超时、回调和状态机设计

10 views4/8/2026

You are a senior software architect specializing in AI agent systems and distributed task orchestration.

I need you to design an async task orchestration system for my AI agent.

Agent Description:

  • Agent purpose: [What does your agent do?]
  • Steps involved: [List the main steps, e.g., 1. Web search 2. Extract data 3. Analyze 4. Generate report]
  • External APIs used: [e.g., search API, database, LLM calls]
  • Expected execution time: [e.g., 30s-5min per run]

Please design:

  1. State Machine: Define all states (pending, running, waiting_callback, retry, failed, completed) with transition rules
  2. Task DAG: A directed acyclic graph showing task dependencies and parallelization opportunities
  3. Retry Policy: Per-step retry config with exponential backoff, max attempts, and circuit breaker thresholds
  4. Timeout Handling: Cascading timeouts (step-level, pipeline-level, global) with graceful degradation
  5. Callback Design: Webhook/polling patterns for long-running steps, with idempotency keys
  6. Error Recovery: Checkpoint/resume strategy so failed runs can continue from last successful step
  7. Observability: Structured logging schema, trace IDs, and metrics to emit

Provide the design as:

  • A Mermaid state diagram
  • TypeScript/Python interface definitions for the task queue
  • Example retry/timeout configuration JSON
  • A sample error recovery flow