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. |
ops_concerns |
list[str]
|
List of operational concerns (build errors, missing deps, tooling friction) noted by the agent. 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. |
sandbox |
Optional[AgentSandbox]
|
Sandbox instance used to launch the agent, or None if no sandbox was configured. Stored so teardown can clean up the container (or other sandbox resources) after task completion. |
sandbox_context |
Optional[SandboxContext]
|
Execution context passed to the sandbox, or None.
Paired with |
Source code in src/agentrelay/task_runtime/runtime.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
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 (worktree, branch, signal_dir, error, attempts). Defaults to a new TaskState (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
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
attempt_dir
property
Path to the current attempt's artifact directory.
Returns signal_dir / "attempts" / "<attempt_num>", or None
if no signal directory has been set. Agent-written artifacts
(.done, .failed, concerns.log, etc.) live here so
every attempt has a uniform layout under attempts/<N>/.
status
property
Current task status, derived from signal files on disk.
Falls back to PENDING if no signal directory has been set,
unless an error has been recorded (indicating failure before
provisioning), in which case FAILED is returned.
mark_pending()
Write the pending status signal file.
Source code in src/agentrelay/task_runtime/runtime.py
236 237 238 | |
mark_running()
Write the running status signal file.
Source code in src/agentrelay/task_runtime/runtime.py
240 241 242 | |
mark_pr_created()
Write the pr_created status signal file.
Source code in src/agentrelay/task_runtime/runtime.py
244 245 246 | |
mark_pr_merged()
Write the pr_merged status signal file.
Source code in src/agentrelay/task_runtime/runtime.py
248 249 250 | |
mark_completed()
Write the completed status signal file.
Source code in src/agentrelay/task_runtime/runtime.py
252 253 254 | |
mark_failed(error)
Write the failed status signal file with the error message.
If signal_dir is not set (task was never prepared),
only the in-memory error is recorded without writing to disk.
Source code in src/agentrelay/task_runtime/runtime.py
256 257 258 259 260 261 262 263 264 | |
mark_reset()
Write the reset status signal file.
Source code in src/agentrelay/task_runtime/runtime.py
266 267 268 | |
prepare_for_attempt(attempt_num)
Reset error and set attempt number before a task attempt.
Source code in src/agentrelay/task_runtime/runtime.py
270 271 272 273 | |
reset_for_retry()
Record current error as a concern and reset to PENDING for retry.
Agent artifacts (.done, .failed, concerns.log, etc.)
are already scoped to attempts/<N>/ and do not need archiving
or cleanup. Only orchestrator-managed status signals are cleared.
Source code in src/agentrelay/task_runtime/runtime.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
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 |
|---|---|---|
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. |
signal_dir |
Optional[Path]
|
Path to the task signal directory for signal and status files, or None if not yet provisioned. |
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
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 | |
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. |
|
COMPLETED |
Task completed successfully without creating a PR. |
|
FAILED |
Task execution failed. |
|
RESET |
Task was reset via |
Source code in src/agentrelay/task_runtime/runtime.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |