Agent State Machine Mapper
Convert a loosely described agent workflow into explicit states, transitions, guards, retries, timeouts, and terminal outcomes.
Engineers turning agent prototypes into durable workflows that can resume safely, handle asynchronous events, and avoid duplicate side effects.
You are an AI workflow engineer who specializes in deterministic state management around probabilistic agent behavior.
Inputs:
1. Agent goal and workflow narrative: {{workflow_narrative}}
2. Events, tools, approvals, and external systems: {{events_and_dependencies}}
3. Business rules and prohibited transitions: {{business_rules}}
4. Retry, timeout, cancellation, and recovery expectations: {{recovery_requirements}}
5. Persistence, orchestration, and audit constraints: {{technical_constraints}}
Do the following:
1. Identify stable states, transient processing states, waiting states, and terminal outcomes; distinguish state from data attributes and UI labels.
2. Define every transition with its triggering event, guard conditions, side effects, idempotency behavior, owner, and audit record.
3. Add explicit paths for validation failure, tool outage, partial success, human rejection, timeout, cancellation, duplicate events, and resumed execution.
4. Detect unreachable states, ambiguous ownership, unsafe loops, missing terminal states, and transitions that allow the agent to bypass authorization or verification.
5. Produce a state table, Mermaid-compatible state diagram text, transition contract examples, invariants, and test cases covering happy paths and recovery paths.How to use
- Describe events and external side effects separately.
- List every approval and prohibited transition.
- Specify retry, timeout, and cancellation behavior.
- Validate the map against event replay and duplicate delivery.
Example input
Workflow: A contract-intake agent receives an uploaded agreement, validates required fields, extracts terms, requests legal review for risky clauses, collects business approval, and stores the signed record. Events: file upload, extraction result, reviewer decision, approval webhook, and document-system confirmation. Rules: no business approval before legal clearance when risk is high; storage only after both approvals. Recovery: tools retry twice, reviews expire after five business days, and users may cancel before storage. Technical constraints: durable workflow engine, event replay, and seven-year audit retention.
Example output
The map defines Received, Validating, ExtractionPending, ReviewRequired, AwaitingLegal, AwaitingBusiness, ReadyToStore, Storing, Completed, Rejected, Cancelled, and ManualRecovery states. Every external write uses a contract ID plus operation key for idempotency. High-risk contracts cannot enter AwaitingBusiness without legal approval. Expired reviews move to ManualRecovery rather than silently restarting. Duplicate webhooks are acknowledged without repeating side effects, and cancellation is blocked once immutable storage is confirmed.
Customization tips
- — Use states for durable conditions, not every internal step.
- — Add guard conditions for authorization and verification.
- — Give external writes idempotency keys.
- — Define terminal outcomes for rejection, cancellation, and recovery.
Tags
FAQ
What is this prompt for?
How should I customize it?
Are there any limitations?
How is it different from a basic prompt?
Related Prompts
All AI Agents prompts →Agent Handoff Contract Designer
Define reliable handoffs between agents or from agents to people, with clear payloads, acceptance rules, ownership, and recovery paths.
Agent Evaluation Benchmark Builder
Create a representative benchmark that tests an AI agent's task success, tool use, safety, recovery, and efficiency before release.
Agent Task Decomposition Planner
Breaks a broad goal into a structured set of sub-tasks an AI agent can execute step by step, with clear success criteria and handoff points for human review.
Related Skills
Webhook Contract and Replay Safety Architect
Design reliable webhook integrations with signatures, schemas, idempotency, ordering, retries, replay protection, and reconciliation.
Agent Tool Failure and Recovery Orchestrator
Design agent recovery for unavailable tools, bad responses, timeouts, partial actions, duplicates, permission errors, and human escalation.
Multi Agent Collaboration Orchestrator
Design multi-agent workflows with roles, task decomposition, shared state, handoffs, verification, budgets, conflict handling, and human control.