task_runner
Task runner package — one-task lifecycle state machine, dispatch, and I/O protocols.
Re-exports all public names so that from agentrelay.task_runner import X
continues to work.
Subpackages
core: Protocols, state machine, dispatch, I/O boundary composition. implementations: Concrete protocol implementations.
StepDispatch
dataclass
Bases: Generic[T]
Per-step dispatch table for one lifecycle step.
Selects the right protocol implementation based on the task's
:class:~agentrelay.task.AgentFramework and
:class:~agentrelay.environments.AgentEnvironment type. Each entry
maps a (framework, env_type) key to a factory callable that
receives the :class:TaskRuntime and returns a protocol implementation.
The default fallback handles steps that don't vary by
framework/environment.
Callable — use as self._preparer(runtime) directly via
:meth:__call__.
Dispatch resolution order
- Exact match in
entriesfor(framework, type(environment)) defaultfallbackKeyErrorif neither matches
Extension guide
To add support for a new AgentFramework or AgentEnvironment,
add an entry to the entries dict for each step that has a
distinct implementation for that combo. Steps that don't vary
(e.g. preparer, merger) can continue using default.
Attributes:
| Name | Type | Description |
|---|---|---|
entries |
dict[DispatchKey, Callable[[TaskRuntime], T]]
|
Mapping of |
default |
Callable[[TaskRuntime], T] | None
|
Fallback factory used when no exact key match exists. |
Source code in src/agentrelay/task_runner/core/dispatch.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 81 82 83 84 85 86 87 88 | |
__call__(runtime)
Resolve and return the protocol implementation for this runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Task runtime used to extract the dispatch key from
|
required |
Returns:
| Type | Description |
|---|---|
T
|
The resolved protocol implementation instance. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no entry matches and no default is provided. |
Source code in src/agentrelay/task_runner/core/dispatch.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
GateCheckResult
dataclass
Result of a single completion gate check attempt.
Attributes:
| Name | Type | Description |
|---|---|---|
passed |
bool
|
Whether the gate command exited successfully (exit code 0). |
output |
str
|
Combined stdout and stderr from the gate command. |
Source code in src/agentrelay/task_runner/core/io.py
113 114 115 116 117 118 119 120 121 122 123 | |
TaskCompletionChecker
Bases: Protocol
Wait for a terminal task completion signal.
Source code in src/agentrelay/task_runner/core/io.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
wait_for_completion(runtime)
async
Wait for terminal task signal from the execution boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope being observed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TaskCompletionSignal |
TaskCompletionSignal
|
Terminal signal payload with outcome data. |
Source code in src/agentrelay/task_runner/core/io.py
101 102 103 104 105 106 107 108 109 110 | |
TaskCompletionSignal
dataclass
Signal payload returned by the completion checker.
Attributes:
| Name | Type | Description |
|---|---|---|
outcome |
Literal['done', 'failed']
|
Terminal completion signal from external execution.
|
pr_url |
Optional[str]
|
Pull request URL for a |
error |
Optional[str]
|
Failure detail for a |
concerns |
tuple[str, ...]
|
Design concerns captured during execution. |
ops_concerns |
tuple[str, ...]
|
Operational concerns (build errors, tooling friction) captured during execution. |
Source code in src/agentrelay/task_runner/core/io.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
TaskGateChecker
Bases: Protocol
Run a completion gate command and return the result.
Source code in src/agentrelay/task_runner/core/io.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
check_gate(runtime)
Execute the completion gate command for a task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope with gate command and worktree path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GateCheckResult |
GateCheckResult
|
Pass/fail outcome and captured output. |
Source code in src/agentrelay/task_runner/core/io.py
130 131 132 133 134 135 136 137 138 139 | |
TaskKickoff
Bases: Protocol
Send kickoff instructions to a launched agent.
Source code in src/agentrelay/task_runner/core/io.py
83 84 85 86 87 88 89 90 91 92 93 94 | |
kickoff(runtime, agent)
Send kickoff instructions to the launched task agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope for the task being kicked off. |
required |
agent
|
Agent
|
Live agent handle to send instructions to. |
required |
Source code in src/agentrelay/task_runner/core/io.py
87 88 89 90 91 92 93 94 | |
TaskLauncher
Bases: Protocol
Launch and return the primary agent for a task.
Source code in src/agentrelay/task_runner/core/io.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
launch(runtime)
Launch and return the primary agent for this task runtime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope to launch against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Agent |
Agent
|
Live agent handle bound to this task. |
Source code in src/agentrelay/task_runner/core/io.py
71 72 73 74 75 76 77 78 79 80 | |
TaskLogCapture
Bases: Protocol
Capture agent execution log unconditionally at task termination.
Source code in src/agentrelay/task_runner/core/io.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
capture_log(runtime)
Capture the agent's execution log to the signal directory.
Called unconditionally when a task reaches a terminal status, regardless of teardown mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope whose agent log should be captured. |
required |
Source code in src/agentrelay/task_runner/core/io.py
175 176 177 178 179 180 181 182 183 184 | |
TaskMerger
Bases: Protocol
Merge the completed task PR into the integration target.
Source code in src/agentrelay/task_runner/core/io.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
merge_pr(runtime, pr_url)
Merge the completed task PR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope being merged. |
required |
pr_url
|
str
|
Pull request URL to merge. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TaskMergeResult |
TaskMergeResult
|
Pre-merge SHA for rollback support. |
Source code in src/agentrelay/task_runner/core/io.py
158 159 160 161 162 163 164 165 166 167 168 | |
TaskMergeResult
dataclass
Result from merging a task PR.
Attributes:
| Name | Type | Description |
|---|---|---|
integration_branch_before_merge |
str
|
SHA of the integration branch immediately before the task PR was merged into it. |
Source code in src/agentrelay/task_runner/core/io.py
142 143 144 145 146 147 148 149 150 151 | |
TaskPreparer
Bases: Protocol
Prepare runtime execution prerequisites before agent launch.
Source code in src/agentrelay/task_runner/core/io.py
54 55 56 57 58 59 60 61 62 63 64 | |
prepare(runtime)
Prepare runtime execution prerequisites.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope to prepare (e.g. branch, signal files). |
required |
Source code in src/agentrelay/task_runner/core/io.py
58 59 60 61 62 63 64 | |
TaskTeardown
Bases: Protocol
Release runtime resources after terminal completion.
Source code in src/agentrelay/task_runner/core/io.py
187 188 189 190 191 192 193 194 195 196 197 | |
teardown(runtime)
Release runtime resources after terminal completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope whose resources should be cleaned up. |
required |
Source code in src/agentrelay/task_runner/core/io.py
191 192 193 194 195 196 197 | |
StandardTaskRunner
dataclass
Standard task lifecycle: prepare → launch → kickoff → wait → gate → merge → teardown.
Uses :class:StepDispatch tables for per-step implementation selection
based on the task's AgentFramework and AgentEnvironment.
Step sensitivity reference:
+-----------------------+----------------+----------------------+ | Step | Varies by env? | Varies by framework? | +=======================+================+======================+ | preparer | No | No | +-----------------------+----------------+----------------------+ | launcher | Yes | Yes | +-----------------------+----------------+----------------------+ | kickoff | Yes | Yes | +-----------------------+----------------+----------------------+ | completion_checker | Maybe | No | +-----------------------+----------------+----------------------+ | gate_checker | No | No | +-----------------------+----------------+----------------------+ | merger | No | No | +-----------------------+----------------+----------------------+ | log_capture | Partially | No | +-----------------------+----------------+----------------------+ | teardown | Partially | No | +-----------------------+----------------+----------------------+
Extension guide — adding a new framework or environment:
Add entries to the StepDispatch tables for steps that have distinct
implementations. Steps that don't vary can keep using default.
Extension guide — different lifecycle (e.g., adding a review step):
Create a new class satisfying the :class:TaskRunner protocol. It can
reuse StepDispatch tables and per-step protocol implementations.
Attributes:
| Name | Type | Description |
|---|---|---|
_preparer |
StepDispatch[TaskPreparer]
|
Dispatch table for :class: |
_launcher |
StepDispatch[TaskLauncher]
|
Dispatch table for :class: |
_kickoff |
StepDispatch[TaskKickoff]
|
Dispatch table for :class: |
_completion_checker |
StepDispatch[TaskCompletionChecker]
|
Dispatch table for :class: |
_gate_checker |
TaskGateChecker
|
Completion gate checker (not dispatch-based — always a shell command, does not vary by framework/environment). |
_merger |
StepDispatch[TaskMerger]
|
Dispatch table for :class: |
_log_capture |
StepDispatch[TaskLogCapture]
|
Dispatch table for :class: |
_teardown |
StepDispatch[TaskTeardown]
|
Dispatch table for :class: |
Source code in src/agentrelay/task_runner/core/runner.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 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 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
run(runtime, *, teardown_mode=TearDownMode.ALWAYS)
async
Execute one task lifecycle run and return a result snapshot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Mutable task runtime to execute. Must enter in |
required |
teardown_mode
|
TearDownMode
|
Resource teardown policy after run completion. |
ALWAYS
|
Returns:
| Name | Type | Description |
|---|---|---|
TaskRunResult |
TaskRunResult
|
Convenience snapshot of terminal runtime fields. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/agentrelay/task_runner/core/runner.py
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 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
TaskRunner
Bases: Protocol
Protocol for the task runner boundary used by Orchestrator.
Different lifecycle variants (standard, reviewing, dry-run) are different classes satisfying this protocol. The orchestrator does not know or care about internal step structure.
Source code in src/agentrelay/task_runner/core/runner.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
run(runtime, *, teardown_mode=TearDownMode.ALWAYS)
async
Execute one task attempt and return terminal task fields.
Source code in src/agentrelay/task_runner/core/runner.py
145 146 147 148 149 150 151 152 | |
TaskRunResult
dataclass
Convenience return value mirroring terminal fields on :class:TaskRuntime.
TaskRuntime remains the single source of truth; this result is a snapshot
for ergonomic call-site consumption.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
str
|
Task identifier. |
status |
TaskStatus
|
Terminal task status after |
pr_url |
Optional[str]
|
Task PR URL, if one was recorded. |
error |
Optional[str]
|
Task failure message, if one was recorded. |
failure_class |
Optional[IntegrationFailureClass]
|
Integration error classification for I/O boundary
failures. |
Source code in src/agentrelay/task_runner/core/runner.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 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 | |
from_runtime(runtime, failure_class=None)
classmethod
Build a result snapshot from the current runtime state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope to snapshot. |
required |
failure_class
|
Optional[IntegrationFailureClass]
|
Optional integration error classification. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
TaskRunResult |
TaskRunResult
|
Snapshot of task ID, status, PR URL, and error. |
Source code in src/agentrelay/task_runner/core/runner.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
TearDownMode
Bases: str, Enum
Policy controlling whether runtime resources are torn down after run.
Attributes:
| Name | Type | Description |
|---|---|---|
ALWAYS |
Always call teardown at end of run. |
|
NEVER |
Never call teardown. |
|
ON_SUCCESS |
Call teardown only when task reaches a terminal success
status ( |
Source code in src/agentrelay/task_runner/core/runner.py
75 76 77 78 79 80 81 82 83 84 85 86 87 | |
GhTaskMerger
dataclass
Merge a task PR via GitHub CLI and update the local integration branch.
After merging, fetches the updated integration branch and writes a
.merged signal file to the task's signal directory.
Reads integration_branch from runtime.state (set by the
orchestrator before dispatch).
Source code in src/agentrelay/task_runner/implementations/task_merger.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
merge_pr(runtime, pr_url)
Merge the completed task PR.
Captures the integration branch SHA before merging for rollback
support. Returns a :class:TaskMergeResult with the pre-merge SHA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope being merged. |
required |
pr_url
|
str
|
Pull request URL to merge. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TaskMergeResult |
TaskMergeResult
|
Pre-merge SHA of the integration branch. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/agentrelay/task_runner/implementations/task_merger.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
ShellGateChecker
dataclass
Run a completion gate shell command and return the result.
Executes the gate command from runtime.task.completion_gate in the
task's workstream worktree. Captures combined stdout and stderr to
gate_last_output.txt in the signal directory.
The checker does NOT raise on command failure — a non-zero exit code
is returned as GateCheckResult(passed=False, ...).
Source code in src/agentrelay/task_runner/implementations/task_gate_checker.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 | |
check_gate(runtime)
Execute the completion gate command for a task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope with gate command and worktree path. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GateCheckResult |
GateCheckResult
|
Pass/fail outcome and captured output. |
Source code in src/agentrelay/task_runner/implementations/task_gate_checker.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 | |
SignalCompletionChecker
dataclass
Poll signal files and parse the result into a completion signal.
Watches the task's signal directory for .done or .failed files,
then parses the signal file content and any concerns.log /
ops_concerns.log entries into a :class:TaskCompletionSignal.
Source code in src/agentrelay/task_runner/implementations/task_completion_checker.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 81 82 83 84 85 | |
wait_for_completion(runtime)
async
Wait for terminal task signal from the execution boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope being observed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TaskCompletionSignal |
TaskCompletionSignal
|
Terminal signal payload with outcome data. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/agentrelay/task_runner/implementations/task_completion_checker.py
39 40 41 42 43 44 45 46 47 48 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 81 82 83 84 85 | |
TmuxTaskKickoff
dataclass
Send kickoff instructions to a launched agent.
Delegates to :meth:Agent.send_kickoff with the path to the
instructions.md file in the task's signal directory.
Source code in src/agentrelay/task_runner/implementations/task_kickoff.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
kickoff(runtime, agent)
Send kickoff instructions to the launched task agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope for the task being kicked off. |
required |
agent
|
Agent
|
Live agent handle to send instructions to. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/agentrelay/task_runner/implementations/task_kickoff.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
TmuxTaskLauncher
dataclass
Launch an agent in a tmux pane using a framework adapter and sandbox.
Orchestrates the command-building pipeline: the adapter builds the
framework-specific CLI command, the sandbox wraps it with isolation,
and :meth:TmuxAgent.from_config sends the final command to a tmux pane.
Attributes:
| Name | Type | Description |
|---|---|---|
adapter |
AgentFrameworkAdapter
|
Framework adapter that builds the raw CLI command. |
sandbox |
AgentSandbox
|
Sandbox that wraps the command with isolation. |
credential_provider |
CredentialProvider
|
Credential provider that resolves token tier to environment variables. |
repo_path |
Path
|
Path to the main repository. |
graph_name |
str
|
Name of the task graph being executed. |
Source code in src/agentrelay/task_runner/implementations/task_launcher.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
launch(runtime)
Launch and return the primary agent for this task runtime.
Builds the agent command via the adapter, wraps it with the sandbox, and sends it to a new tmux pane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope to launch against. Must have
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
Agent |
Agent
|
Live agent handle bound to this task. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/agentrelay/task_runner/implementations/task_launcher.py
46 47 48 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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
WorktreeTaskLogCapture
dataclass
Delegate agent log capture to the agent address.
Calls agent_address.capture_log() to write the agent's execution
log (e.g. tmux scrollback) to the signal directory. This step runs
unconditionally at task termination, before the teardown decision.
Source code in src/agentrelay/task_runner/implementations/task_log_capture.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
capture_log(runtime)
Capture the agent's execution log to the signal directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope whose agent log should be captured. |
required |
Source code in src/agentrelay/task_runner/implementations/task_log_capture.py
23 24 25 26 27 28 29 30 31 32 | |
WorktreeTaskPreparer
dataclass
Create a task branch in a shared workstream worktree and write protocol files.
Creates a task-specific branch off the integration branch, checks it out
in the workstream worktree, writes manifest.json, policies.json,
and instructions.md into the signal directory, and updates the runtime
state with computed paths.
The worktree itself is owned by the workstream preparer — this class only creates and checks out branches within it.
Source code in src/agentrelay/task_runner/implementations/task_preparer.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 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 | |
prepare(runtime)
Prepare runtime execution prerequisites.
Creates a task branch in the workstream worktree, checks it out, and writes protocol files to the signal directory.
Reads integration_branch and workstream_worktree_path from
runtime.state (set by the orchestrator before dispatch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope to prepare (e.g. branch, signal files). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/agentrelay/task_runner/implementations/task_preparer.py
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 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 | |
WorktreeTaskTeardown
dataclass
Delegate agent-address cleanup and delete the task branch.
Performs best-effort cleanup: delegates log capture and environment teardown to the agent address, then deletes the task branch. The workstream worktree is owned by the workstream teardown handler and is not touched here. Errors during teardown are caught and not propagated.
Source code in src/agentrelay/task_runner/implementations/task_teardown.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
teardown(runtime)
Release runtime resources after terminal completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime
|
TaskRuntime
|
Runtime envelope whose resources should be cleaned up. |
required |
Source code in src/agentrelay/task_runner/implementations/task_teardown.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |