session
Session resolution and validation for agent execution environments.
This module defines the SessionResolver protocol and its
TmuxSessionResolver implementation for resolving and validating
tmux sessions used by agent tasks.
Protocols
SessionResolver: Resolve and validate agent execution sessions.
Classes:
| Name | Description |
|---|---|
TmuxSessionResolver |
Tmux-based session resolution. |
SessionError |
Raised when session resolution or validation fails. |
SessionError
Bases: RuntimeError
Raised when the tmux session is not specified or doesn't exist.
Source code in src/agentrelay/session.py
23 24 | |
SessionResolver
Bases: Protocol
Protocol for resolving and validating agent execution sessions.
Implementations handle auto-detection and validation of the execution environment (e.g., tmux sessions) where agent tasks will run.
Methods:
| Name | Description |
|---|---|
resolve |
Resolve CLI session override to a concrete session name. |
validate |
Validate that all tasks' sessions exist. |
Source code in src/agentrelay/session.py
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 | |
resolve(cli_session)
Resolve a session name from CLI override or auto-detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli_session
|
Optional[str]
|
Explicit session name from CLI, or |
required |
Returns:
| Type | Description |
|---|---|
str
|
Resolved session name. |
Raises:
| Type | Description |
|---|---|
SessionError
|
If no session can be resolved. |
Source code in src/agentrelay/session.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
validate(graph)
Validate that all tasks reference existing sessions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
TaskGraph
|
Validated task graph whose tasks' sessions to check. |
required |
Raises:
| Type | Description |
|---|---|
SessionError
|
If any session is missing or does not exist. |
Source code in src/agentrelay/session.py
54 55 56 57 58 59 60 61 62 63 | |
TmuxSessionResolver
Tmux-based session resolver.
Resolves the session by checking the CLI override, then
auto-detecting from the current tmux session. Validates by
checking tmux has-session for each unique session in the graph.
Source code in src/agentrelay/session.py
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 | |
resolve(cli_session)
Resolve tmux session: CLI flag > auto-detect > error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cli_session
|
Optional[str]
|
Explicit session name, or |
required |
Returns:
| Type | Description |
|---|---|
str
|
Resolved tmux session name. |
Raises:
| Type | Description |
|---|---|
SessionError
|
If not in tmux and no CLI override given. |
Source code in src/agentrelay/session.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
validate(graph)
Validate that all tasks' tmux sessions exist.
Checks two things for every task in the graph:
- The task has a non-empty session name.
- The tmux session actually exists (
tmux has-session).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
TaskGraph
|
Task graph to validate. |
required |
Raises:
| Type | Description |
|---|---|
SessionError
|
If any task's session is empty or the tmux session does not exist. |
Source code in src/agentrelay/session.py
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 | |