Skip to content

Data Model: Amelia Agentic Orchestrator

This document describes the core data structures used throughout the Amelia orchestrator.

Type Aliases

TypeDefinitionDescription
DriverType"claude" | "codex" | "api"LLM driver type.
TrackerType"jira" | "github" | "noop"Issue tracker type.
AgenticStatus"running" | "awaiting_approval" | "completed" | "failed" | "cancelled"Agentic execution status.
Severity"low" | "medium" | "high" | "critical"Review issue severity.

Configuration Entities

RetryConfig

Retry configuration for transient failures.

FieldTypeDefaultDescription
max_retriesint3Maximum number of retry attempts (range: 0-10).
base_delayfloat1.0Base delay in seconds for exponential backoff (range: 0.1-30.0).
max_delayfloat60.0Maximum delay cap in seconds (range: 1.0-300.0).

Location: amelia/core/types.py

Profile

Defines the runtime environment and constraints.

FieldTypeDefaultDescription
namestrProfile name (e.g., "work", "personal").
trackerTrackerType"noop"Issue tracker type.
repo_rootstrRoot directory of the repository this profile targets.
plan_output_dirstr"docs/plans"Directory for saving implementation plans.
plan_path_patternstr"docs/plans/{date}-{issue_key}.md"Path pattern for plan files with {date} and {issue_key} placeholders.
retryRetryConfigRetryConfig()Retry configuration for transient failures.
agentsdict[str, AgentConfig]{}Per-agent driver and model configuration.
sandboxSandboxConfigSandboxConfig()Sandbox execution configuration.

Location: amelia/core/types.py

Settings

Root configuration object.

FieldTypeDescription
active_profilestrName of the currently active profile.
profilesdict[str, Profile]Dictionary mapping profile names to Profile objects.

Location: amelia/core/types.py

Domain Entities

Issue

Issue or ticket to be worked on.

FieldTypeDefaultDescription
idstrUnique issue identifier (e.g., "JIRA-123", "GH-456").
titlestrIssue title or summary.
descriptionstrDetailed issue description.
statusstr"open"Current issue status.

Location: amelia/core/types.py

Design

Structured design from brainstorming output.

FieldTypeDefaultDescription
titlestrDesign title.
goalstrOverall goal or objective.
architecturestrArchitectural approach and patterns.
tech_stacklist[str]List of technologies to be used.
componentslist[str]List of components or modules.
data_flowstr | NoneNoneDescription of data flow.
error_handlingstr | NoneNoneError handling strategy.
testing_strategystr | NoneNoneTesting approach.
relevant_fileslist[str][]List of relevant files in the codebase.
conventionsstr | NoneNoneCoding conventions to follow.
raw_contentstrRaw unprocessed design content.

Location: amelia/core/types.py

Agentic Execution Entities

ToolCall

A tool call made by the LLM during agentic execution.

FieldTypeDefaultDescription
idstrUnique identifier for this call.
tool_namestrName of the tool being called.
tool_inputdict[str, Any]Input parameters for the tool.
timestampstr | NoneNoneWhen the call was made (ISO format).

Location: amelia/core/agentic_state.py

ToolResult

Result from a tool execution.

FieldTypeDefaultDescription
call_idstrID of the ToolCall this result is for.
tool_namestrName of the tool that was called.
outputstrOutput from the tool (stdout, file content, etc.).
successboolWhether the tool executed successfully.
errorstr | NoneNoneError message if success is False.
duration_msint | NoneNoneExecution time in milliseconds.

Location: amelia/core/agentic_state.py

AgenticState

State for standalone agentic workflow execution.

FieldTypeDefaultDescription
workflow_idstrUnique workflow identifier.
issue_keystrIssue being worked on.
goalstrHigh-level goal or task description.
system_promptstr | NoneNoneSystem prompt for the agent.
tool_callstuple[ToolCall, ...]()History of tool calls made.
tool_resultstuple[ToolResult, ...]()History of tool results received.
final_responsestr | NoneNoneFinal response from the agent when complete.
statusAgenticStatus"running"Current execution status.
errorstr | NoneNoneError message if status is 'failed'.
session_idstr | NoneNoneSession ID for driver continuity.

Location: amelia/core/agentic_state.py

ReviewResult

Result from a code review.

FieldTypeDescription
reviewer_personastrThe persona or role of the reviewer (e.g., "Security", "Performance").
approvedboolWhether the review approved the changes.
commentslist[str]List of review comments or feedback.
severitySeveritySeverity level of issues found.

Location: amelia/core/state.py

AgentMessage

Message from an agent in the orchestrator conversation.

FieldTypeDefaultDescription
rolestrRole of the message sender (system, assistant, user).
contentstrThe message content.
tool_callslist[Any] | NoneNoneTool calls made by the agent.

Location: amelia/core/state.py

ExecutionState

The central state object for the LangGraph orchestrator. This model is frozen (immutable) to support the stateless reducer pattern.

FieldTypeDefaultDescription
profile_idstrID of the active profile (for replay determinism).
issueIssue | NoneNoneThe issue being worked on.
designDesign | NoneNoneOptional design context from brainstorming.
goalstr | NoneNoneHigh-level goal for agentic execution.
base_commitstr | NoneNoneGit commit SHA captured at workflow start for accurate diffing.
plan_markdownstr | NoneNoneThe markdown plan content generated by the Architect.
plan_pathPath | NoneNonePath where the markdown plan was saved.
human_approvedbool | NoneNoneWhether human approval was granted for the goal/strategy.
human_feedbackstr | NoneNoneOptional feedback from human during approval.
last_reviewReviewResult | NoneNoneMost recent review result (only latest matters for decisions).
code_changes_for_reviewstr | NoneNoneStaged code changes for review.
driver_session_idstr | NoneNoneSession ID for driver session continuity.
agent_historyAnnotated[list[str], operator.add][]History of agent actions/messages for context tracking. Uses reducer.
tool_callsAnnotated[list[ToolCall], operator.add][]History of tool calls made during agentic execution. Uses reducer.
tool_resultsAnnotated[list[ToolResult], operator.add][]History of tool results from agentic execution. Uses reducer.
agentic_statusAgenticStatus"running"Current agentic execution status.
created_atdatetimeWhen the workflow was created/queued.
final_responsestr | NoneNoneFinal response from the agent when complete.
errorstr | NoneNoneError message if status is 'failed'.
review_iterationint0Current iteration in review-fix loop.
total_tasksint | NoneNoneNumber of tasks parsed from plan (None = legacy single-session mode).
current_task_indexint00-indexed task being executed, increments after each task passes review.
task_review_iterationint0Review iteration counter that resets to 0 when moving to next task.
structured_reviewAny | NoneNoneStructured review output from reviewer agent.
evaluation_resultAny | NoneNoneOutput from the evaluator agent.
approved_itemslist[int][]Item numbers approved for fixing by human or auto-approve.
auto_approveboolFalseWhether to skip human approval steps.
review_passint0Current review iteration in auto mode.
max_review_passesint3Maximum iterations allowed in auto mode.

Location: amelia/core/state.py

ExecutionState Helper Properties

PropertyReturn TypeDescription
is_queuedboolTrue if workflow is in pending status (not yet started).

Streaming Entities

StreamEventType

Unified streaming event types from agent execution (enum). This is the common event type across all drivers, enabling consistent UI rendering regardless of the underlying LLM driver.

ValueString ValueDescription
CLAUDE_THINKING"claude_thinking"Agent is analyzing the situation and planning.
CLAUDE_TOOL_CALL"claude_tool_call"Agent is invoking a tool.
CLAUDE_TOOL_RESULT"claude_tool_result"Result returned from tool execution.
AGENT_OUTPUT"agent_output"Final output when agent completes execution.

Location: amelia/core/types.py

python
class StreamEventType(StrEnum):
    CLAUDE_THINKING = "claude_thinking"
    CLAUDE_TOOL_CALL = "claude_tool_call"
    CLAUDE_TOOL_RESULT = "claude_tool_result"
    AGENT_OUTPUT = "agent_output"

StreamEvent

Unified real-time streaming event from agent execution. This is the common message format across all drivers (CLI and API), enabling consistent UI rendering and logging regardless of the underlying LLM driver.

Drivers convert their native message types to StreamEvent using conversion functions:

  • Claude CLI driver: convert_to_stream_event() in amelia/drivers/cli/claude.py
  • Codex CLI driver: Conversion in amelia/drivers/cli/codex.py
  • API driver: Similar conversion in the API driver implementation
FieldTypeDefaultDescription
idstruuid4()Unique identifier for this event.
typeStreamEventTypeType of streaming event (see StreamEventType enum).
contentstr | NoneNoneEvent content (text, result output, etc.).
timestampdatetimeWhen the event occurred.
agentstrAgent name (architect, developer, reviewer).
workflow_idstrLinks this event to its parent workflow.
tool_namestr | NoneNoneName of tool being called (for TOOL_CALL/TOOL_RESULT events).
tool_inputdict[str, Any] | NoneNoneInput parameters for tool call (for TOOL_CALL events).

Location: amelia/core/types.py

python
class StreamEvent(BaseModel, frozen=True):
    id: str = Field(default_factory=lambda: str(uuid4()))
    type: StreamEventType
    content: str | None = None
    timestamp: datetime
    agent: str
    workflow_id: str
    tool_name: str | None = None
    tool_input: dict[str, Any] | None = None

Server Models

ServerConfig

Server configuration with environment variable support.

FieldTypeDefaultDescription
hoststr"127.0.0.1"Host to bind the server to.
portint8420Port to bind the server to (range: 1-65535).
database_pathPath~/.amelia/amelia.dbPath to SQLite database file.
log_retention_daysint30Days to retain event logs (min: 1).
log_retention_max_eventsint100000Maximum events per workflow (min: 1000).
websocket_idle_timeout_secondsfloat300.0WebSocket idle timeout in seconds (5 min default).
workflow_start_timeout_secondsfloat60.0Max time to start a workflow in seconds.
max_concurrentint5Maximum number of concurrent workflows (min: 1).

Location: amelia/server/config.py

EventType

Exhaustive list of workflow event types (enum).

ValueCategoryDescription
WORKFLOW_STARTEDLifecycleWorkflow execution started.
WORKFLOW_COMPLETEDLifecycleWorkflow execution completed successfully.
WORKFLOW_FAILEDLifecycleWorkflow execution failed.
WORKFLOW_CANCELLEDLifecycleWorkflow execution cancelled.
STAGE_STARTEDStagesWorkflow stage started.
STAGE_COMPLETEDStagesWorkflow stage completed.
APPROVAL_REQUIREDApprovalHuman approval required for plan.
APPROVAL_GRANTEDApprovalHuman approval granted.
APPROVAL_REJECTEDApprovalHuman approval rejected.
FILE_CREATEDArtifactsFile created during execution.
FILE_MODIFIEDArtifactsFile modified during execution.
FILE_DELETEDArtifactsFile deleted during execution.
REVIEW_REQUESTEDReviewCode review requested.
REVIEW_COMPLETEDReviewCode review completed.
REVISION_REQUESTEDReviewRevision requested after review.
SYSTEM_ERRORSystemSystem error occurred.
SYSTEM_WARNINGSystemSystem warning issued.

Location: amelia/server/models/events.py

WorkflowEvent

Event for activity log and real-time updates. Events are immutable and append-only.

FieldTypeDescription
idstrUnique event identifier (UUID).
workflow_idstrWorkflow this event belongs to (links to ExecutionState).
sequenceintMonotonic sequence number per workflow (min: 1).
timestampdatetimeWhen event occurred.
agentstrEvent source agent (architect, developer, reviewer, system).
event_typeEventTypeTyped event category.
messagestrHuman-readable summary.
datadict[str, Any] | NoneOptional structured payload (file paths, error details, etc.).
correlation_idstr | NoneLinks related events for tracing (e.g., approval request → granted).

Location: amelia/server/models/events.py

TokenUsage

Token consumption tracking per agent with cache-aware cost calculation.

FieldTypeDefaultDescription
idstruuid4()Unique identifier.
workflow_idstrWorkflow this usage belongs to.
agentstrAgent that consumed tokens.
modelstr"claude-sonnet-4-20250514"Model used for cost calculation.
input_tokensintTotal input tokens (includes cache reads, min: 0).
output_tokensintOutput tokens generated (min: 0).
cache_read_tokensint0Subset of input tokens served from cache (discounted, min: 0).
cache_creation_tokensint0Tokens written to cache (premium rate, min: 0).
cost_usdfloat | NoneNoneNet cost in USD after cache adjustments.
timestampdatetimeWhen tokens were consumed.

Notes:

  • input_tokens includes cache_read_tokens (not additive)
  • Cost formula: (base_input × input_rate) + (cache_read × cache_read_rate) + (cache_write × cache_write_rate) + (output × output_rate)
  • Where base_input = input_tokens - cache_read_tokens

Location: amelia/server/models/tokens.py

Entity Relationships

Settings
└── profiles: Dict[str, Profile]
    └── retry: RetryConfig

ExecutionState
├── profile_id: str (references Profile)
├── issue: Issue
├── design: Design (optional)
├── goal: str (from Architect)
├── plan_markdown: str (from Architect)
├── tool_calls: List[ToolCall] (with reducer)
├── tool_results: List[ToolResult] (with reducer)
├── last_review: ReviewResult
├── agent_history: List[str] (with reducer)
├── total_tasks: int | None (task-based execution)
├── current_task_index: int
└── task_review_iteration: int

AgenticState (standalone agentic execution)
├── workflow_id: str
├── issue_key: str
├── goal: str
├── tool_calls: Tuple[ToolCall, ...]
└── tool_results: Tuple[ToolResult, ...]

ServerConfig (singleton)

WorkflowEvent (append-only log)
├── workflow_id → ExecutionState
├── event_type: EventType (enum)
└── correlation_id (links related events)

TokenUsage (per-agent tracking)
└── workflow_id → ExecutionState