- Home
- Skills
- Agents & Orchestration
- AI Agent State Machine Designer
Works with the AI Agents you already use
AI Agent State Machine Designer
Design explicit, testable state machines for AI agent workflows with failure recovery and human-in-the-loop gates.
$24.99
AI Agent State Machine Designer
Example session with this skill installed
Design a failure-first state machine for an automated refund agent. It needs to call a Stripe API, handle rate limits, and require human approval for amounts over $100.
- Read your context and instructions
- Compiled the ai agent state
I have designed the state machine for the automated refund agent, focusing on idempotency and failure recovery.
AI Agent State Machine Design Specification
1. State Catalogue
| State ID | Purpose | Entry Criteria | Key Actions | Terminal / Resumable |
|---|---|---|---|---|
RECEIVED | Initial intake | Refund request event | Validate schema | Resumable |
CHECKING_LIMITS | Risk assessment | Validated data | Evaluate amount > $100 | Resumable |
PENDING_APPROVAL | Human gate | Amount exceeds limit | Notify admin | Resumable |
EXECUTING_STRIPE | API Integration | Approved or < $100 | Call stripe.refunds.create | Resumable |
RETRY_BACKOFF | Error handling | Transient API error | Increment counter | Resumable |
COMPLETED | Success state | Stripe 200 OK | Send confirmation | Terminal |
2. Transition Table
| Source State | Event | Guard | Action | Destination |
|---|---|---|---|---|
CHECKING_LIMITS | EVALUATED | amount <= 100 | None | EXECUTING_STRIPE |
CHECKING_LIMITS | EVALUATED | amount > 100 | Request Approval | PENDING_APPROVAL |
EXECUTING_STRIPE | STRIPE_ERROR | is_transient == true | Start Backoff | RETRY_BACKOFF |
RETRY_BACKOFF | TIMER_READY | retries < 3 | Retry Call | EXECUTING_STRIPE |
3. Workflow Diagram
stateDiagram-v2
[*] --> RECEIVED
RECEIVED --> CHECKING_LIMITS: VALIDATED
CHECKING_LIMITS --> EXECUTING_STRIPE: [amount <= 100]
CHECKING_LIMITS --> PENDING_APPROVAL: [amount > 100]
PENDING_APPROVAL --> EXECUTING_STRIPE: ADMIN_APPROVED
PENDING_APPROVAL --> FAILED: ADMIN_REJECTED
EXECUTING_STRIPE --> COMPLETED: STRIPE_SUCCESS
EXECUTING_STRIPE --> RETRY_BACKOFF: STRIPE_TRANSIENT_ERR
RETRY_BACKOFF --> EXECUTING_STRIPE: [retries < 3]
RETRY_BACKOFF --> FAILED: [retries >= 3]
COMPLETED --> [*]
FAILED --> [*]
4. Failure and Recovery Matrix
- Failure Mode: Stripe Rate Limit (429).
- Detection: Catch HTTP 429 response.
- Retry Policy: Exponential backoff, max 3 attempts.
- Idempotency: Must pass
idempotency_key(refund_id) to Stripe to prevent double refunds.
Next steps
- Implement the
CHECKING_LIMITSlogic as a deterministic predicate function. - Configure a persistent message queue to handle the
PENDING_APPROVALdurable pause. - Integrate the Stripe idempotency key using the unique Refund ID from the
RECEIVEDstate.
Connects securely to your tools. The creator never sees your data.
About this skill
Building reliable AI agents requires moving beyond vague prompts to explicit, testable logic. This skill helps developers design structured state machines for agentic workflows, replacing black-box behavior with observable states, transitions, and recovery paths. It eliminates the guesswork of how an agent handles tool failures, timeouts, or human approval gates.
What it does
- State mapping defines stable identifiers, entry/exit conditions, and responsibilities for every stage of a workflow.
- Transition logic specifies triggering events, guards, and side effects to ensure deterministic movement between states.
- Failure recovery designs retry policies, backoff strategies, and compensation actions for API errors or invalid model outputs.
- Safety gating implements explicit human-in-the-loop checkpoints for sensitive operations like payments or data deletion.
- Mermaid diagramming generates
stateDiagram-v2syntax to visualize complex branching and hierarchical logic.
How it works
- Intake involves providing a plain-language workflow, existing code, or sequence diagram for analysis.
- Modeling selects the best structure, such as a finite state machine, hierarchical model, or directed dependency graph.
- Specification generates a comprehensive document covering state catalogues, event handling, and conditional predicates.
- Testing delivers a plan for normal paths, edge cases, timeouts, and state resumption after process restarts.
Frameworks & tools
This skill is framework-neutral and works with LangGraph, XState, PydanticAI, Temporal, or custom Python/TypeScript state implementations.
Why this beats prompting it yourself
Generic prompts often ignore failure modes, leading to agents that loop infinitely on API errors or bypass approval gates. This skill enforces architectural rigor by requiring explicit guards, bounded loops, and auditable transitions.
Use cases
- Designing a multi-step research agent that requires human sign-off before final publication.
- Mapping out a customer support bot that needs to handle intermittent API timeouts and rate limits.
- Architecting a coding agent that loops through execution, testing, and debugging states.
- Auditing existing agent code to find dead ends, missing transitions, or unsafe retries.
Known limitations
Does not execute the agent, guarantee runtime correctness, or provide production-ready code for specific proprietary agent frameworks. Requires manual translation of the spec into your codebase.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
Does not execute code or guarantee runtime correctness. Framework-neutral spec requires manual implementation. Limitations on simulating real-time concurrency or network latency.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 17 days ago
Permissions
No special permissions declared or detected