Install
$ agentstack add skill-hsienw-ai-agent-engineering-playbook-agent-task-state-machine ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Agent Task State Machine
Skill Interface
- Name: agent-task-state-machine.
- Description: Design and review generic agent task and step state machines for business-level task progress, step lifecycle tracking, task events, persistence, streaming timelines, resumable task state, and cross-layer status APIs.
- Parameters: Task statuses, step statuses, legal transitions, event model, persistence requirements, retry and compensation rules, timeline consumers, redaction policy, and lifecycle verification cases.
- Instructions: Use this skill when product or operator workflows need task semantics beyond graph checkpoints. Define legal transitions in one module, keep terminal states final, persist append-only events when history matters, and test lifecycle, retry, resume, cancellation, and compensation paths.
Model business progress separately from graph execution state. A graph may checkpoint execution, but product and operator workflows often need task, step, audit, and timeline semantics.
Core Model
Use generic names and inject domain-specific step names from the caller:
type TaskStatus =
| 'created'
| 'running'
| 'waiting_confirmation'
| 'completed'
| 'partially_failed'
| 'compensating'
| 'failed'
| 'cancelled';
type StepStatus =
| 'pending'
| 'running'
| 'waiting_confirmation'
| 'succeeded'
| 'retryable_failed'
| 'terminal_failed'
| 'compensating'
| 'compensated'
| 'skipped';
type AgentTask = {
taskId: string;
taskType: string;
status: TaskStatus;
steps: AgentStep[];
createdAt: string;
updatedAt: string;
metadata?: Record;
};
type AgentStep = {
stepId: string;
stepName: TStep;
status: StepStatus;
attempt: number;
maxAttempts: number;
input?: unknown;
output?: unknown;
error?: StepError;
startedAt?: string;
completedAt?: string;
};
Transition Rules
- Define legal transitions in one owned module.
- Reject illegal transitions with stable error codes.
- Terminal states must not transition back to running.
- Step completion should drive task completion only through an explicit policy.
- Store transition events before notifying downstream listeners when durable
history matters.
- Preserve enough data to resume or explain an interrupted task.
Event Model
Use append-only task events:
task_createdstep_startedstep_completedstep_failedstep_retryingwaiting_confirmationresumedtask_completedtask_failedcompensation_triggeredcompensation_completed
Events should include identifiers, event type, payload, and creation time. Keep payloads structured, redacted, and safe for persistence.
Verification
Test complete lifecycle, illegal transitions, retryable and terminal failures, waiting and resume, cancellation, partial failure, compensation, event ordering, and timeline rendering from persisted events.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: HsienW
- Source: HsienW/ai-agent-engineering-playbook
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.