An Agent Execution Framework (EF) governs how an AI agent:
- Maintains awareness of its current situation (state)
- Responds to inputs (events)
- Takes appropriate actions
Think of this as the "operating system" for your ai agent.
A simple representation of a simple state.
Entry:
- What system state should be when entering this state (initialize, start timers, etc.)
Actions:
- What the agent does while in this state (no transitions)
Status:
- Current condition indicator
Exit:
- What triggers leaving this state → next state
Default:
- The state to return to when no other transition applies (typically IDLE)
---
### CODE_REVIEW
**Entry:**
- User has requested code review
- User has new pull requests
**Actions:**
- Speak naturally(not robotic, not scripted)
- Review pending pull requests sorted asc
- Keep responses practical, clear, and slightly conversational
- Don’t over-explain unless asked
**Tone Guidelines:**
- Avoid “assistant-like” phrasing (no: *“As an AI…”*)
- Use natural phrasing (like you would in a dev chat or Slack)
- Don’t force friendliness — be natural instead
**Exit:**
- User explicitly shifts into another pull request → handle it, but stay conversational
- Otherwise remain in CODE_REVIEW
---
$STATE_A --[event]--> $STATE_B
$STATE_A:
Entry: ...
Actions: ...
Status: ...
Exit: event --> $STATE_B
Default: $DEFAULT_STATE
These are typical states you might need. Pick what fits your use case.
| State | Purpose |
|---|---|
IDLE |
Waiting for input or new work |
PROCESSING |
Actively working on a task |
WAITING |
Blocked, awaiting external response |
ERROR |
Something went wrong |
PAUSED |
Temporarily halted, can resume |
COMPLETE |
Finished successfully |
AWAITING_INPUT |
Need more information from user |
Define specific events for your use case. Generic events like USER_INPUT should be specialized:
| Event | When it fires |
|---|---|
USER_SENDS_MESSAGE |
User sends a message |
USER_PROVIDES_TASK |
User adds a task |
USER_MARKS_DONE |
User marks task complete |
TIMER |
A timeout or scheduled trigger |
EXTERNAL_DATA |
Webhook, API response, file change |
ERROR_OCCURRED |
Something failed |
USER_CONFIRMS |
User approves something |
USER_DENIES |
User rejects something |
Each state should clearly define:
- What events can trigger a transition out of this state
- What conditions must be met (guards)
- What happens during the transition (actions)
Every state can have entry and exit actions defined in the state definition:
Entry actions — run when entering the state
- Initialize variables
- Start timers
- Send initial response
Exit actions — run when leaving the state
- Clean up resources
- Stop timers
- Log state changes
What can your agent be doing? Start with 3-5 main states.
For each state, define: "What can happen next?"
What must happen when entering/exiting each state?
- What if something fails?
- What if the user goes silent?
- What if input is unexpected?
- Example 1: Simple To-Do Assistant — Basic 3-state cycle
- Example 2: Multi-Step Task Handler — Workflow with external API calls
- Example 3: Context-Aware Assistant — Memory management and interruptions
An Execution Framework gives:
- Where the agent is (state)
- What triggered the move (event)
- What happens during transitions (action)