task_runtime
Task runtime model for mutable per-task execution state.
This package contains runtime envelopes and lifecycle state for tasks derived from immutable task specs.
TaskArtifacts
dataclass
Outputs and observations produced by a task's agent.
These are accumulated as the agent works, representing the external artifacts and notable observations from task execution.
Attributes:
| Name | Type | Description |
|---|---|---|
pr_url |
Optional[str]
|
URL of the pull request created by the agent, or None if no PR has been created yet. |
concerns |
list[str]
|
List of design concerns or observations noted by the agent during execution. Defaults to empty list. |
agent_address |
Optional[AgentAddress]
|
Address of the agent that executed this task (e.g. tmux session + pane), or None if no agent has been launched yet. Stored as an immutable audit trail after agent teardown. |
Source code in src/agentrelay/task_runtime/runtime.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
TaskRuntime
dataclass
Mutable runtime envelope for a Task.
Groups a frozen Task specification with all mutable state accumulated during execution. The Task spec itself never changes; TaskRuntime tracks how that spec is being executed.
Attributes:
| Name | Type | Description |
|---|---|---|
task |
Task
|
The immutable Task specification being executed. |
state |
TaskState
|
Operational state (status, worktree, branch, error, attempts). Defaults to a new TaskState (PENDING, no paths, no error, attempt 0). |
artifacts |
TaskArtifacts
|
Work outputs and observations (PR URL, concerns, agent address). Defaults to a new TaskArtifacts (no PR, no concerns, no agent address). |
Source code in src/agentrelay/task_runtime/runtime.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
prepare_for_attempt(attempt_num)
Reset error and set attempt number before a task attempt.
Source code in src/agentrelay/task_runtime/runtime.py
125 126 127 128 | |
mark_failed(error)
Transition to FAILED with an error message.
Source code in src/agentrelay/task_runtime/runtime.py
130 131 132 133 | |
reset_for_retry()
Archive current error to concerns and reset to PENDING for retry.
Source code in src/agentrelay/task_runtime/runtime.py
135 136 137 138 139 140 141 142 | |
mark_pending()
Set status to PENDING (used for retry normalization).
Source code in src/agentrelay/task_runtime/runtime.py
144 145 146 | |
TaskState
dataclass
Mutable operational state of a running task.
This tracks the execution progress and infrastructure of a task as managed by the orchestrator.
Attributes:
| Name | Type | Description |
|---|---|---|
status |
TaskStatus
|
Current execution state (TaskStatus enum). |
worktree_path |
Optional[Path]
|
Filesystem path to the git worktree where the agent works, or None if not yet created. |
branch_name |
Optional[str]
|
Name of the feature branch in the worktree, or None if not yet created. |
error |
Optional[str]
|
Error message if the task failed, or None if no error. |
attempt_num |
int
|
The current attempt number (0-indexed). Used to track retries and conditional logic like when to start self-review. |
integration_branch |
Optional[str]
|
Name of the workstream integration branch this task targets. Set by the orchestrator before dispatch from the workstream runtime. None until set. |
workstream_worktree_path |
Optional[Path]
|
Filesystem path to the shared workstream worktree. Set by the orchestrator before dispatch from the workstream runtime. None until set. |
Source code in src/agentrelay/task_runtime/runtime.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
TaskStatus
Bases: str, Enum
Execution state of a task during orchestration.
Attributes:
| Name | Type | Description |
|---|---|---|
PENDING |
Task is waiting to be executed. |
|
RUNNING |
Task is currently being executed by an agent. |
|
PR_CREATED |
Agent completed work; pull request exists against worktree branch. |
|
PR_MERGED |
Pull request has been merged into the worktree primary branch. |
|
FAILED |
Task execution failed. |
Source code in src/agentrelay/task_runtime/runtime.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |