driver
driver
¶
InteractiveSessionDriver — the state machine that pushes a TUI agent to done.
::
LAUNCH → GATES → READY → SUBMIT → DRIVE ⟲ → HARVEST (once) → CLEANUP
The driver owns idle handling for interactive sheets: busy detection from
profile busy_patterns (primary signal), a work-area change hash that only
resets the quiet clock (never alone means busy), and a nudge budget consulted
through a :class:ContinuationPolicy. Completion is signalled by the agent
creating a per-attempt marker file — a protocol signal, not semantic success;
validations remain the authoritative arbiter downstream.
All per-attempt state lives in locals inside :meth:run — never on the
instance — so BackendPool free-list reuse of the owning backend is inherently
clean.
See docs/specs/2026-06-10-interactive-mode-design.md.
Classes¶
ContinuationContext
dataclass
¶
NudgeDecision
dataclass
¶
An input to send, or a reason the idle session cannot continue.
Abstain: message=None, unrecoverable=False means "nothing to send
right now" — the driver re-polls without spending nudge budget; the
attempt deadline still bounds the loop.
ContinuationPolicy
¶
StaticNudgePolicy
¶
DriverResult
dataclass
¶
Outcome of one interactive session attempt.
Attributes¶
final_screen
instance-attribute
¶
Last captured rendered screen (plain text). May be empty when the session died before any capture succeeded.
detail
class-attribute
instance-attribute
¶
Human-readable diagnostic for non-completed outcomes.
supervisor_report
class-attribute
instance-attribute
¶
Parsed instrument-supervisor forensic report for this attempt (GH #487).
Present only when the pane ran under supervise: true AND the
supervisor managed to write its report before the pane teardown — an
absent report is itself evidence (external kill; the supervisor never
observed a forwarded signal). Never parsed from the agent's output:
the report is the backend-controlled supervisor's own record.
InteractiveSessionDriver
¶
Drives one agent CLI session to completion inside tmux.
Stateless across attempts: everything attempt-specific is passed to
:meth:run and lives in its locals.
Source code in src/marianne/execution/instruments/interactive/driver.py
Methods:¶
run
async
¶
run(*, session, command, cwd, prompt, marker_path, timeout_seconds, policy, max_nudges, transcript_path=None, supervisor_report_path=None, on_pane_pid=None, env=None, on_output=None)
Run one full attempt: launch, gate, submit, drive, harvest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
str
|
tmux session name (already sanitized, deterministic). |
required |
command
|
list[str]
|
agent argv (executable + args), exec'd directly. |
required |
cwd
|
Path
|
working directory for the agent (the sheet workspace). |
required |
prompt
|
str
|
full prompt text, already carrying the completion
protocol suffix that names |
required |
marker_path
|
Path
|
per-attempt completion marker the agent creates. |
required |
timeout_seconds
|
float
|
overall attempt deadline. |
required |
policy
|
ContinuationPolicy
|
continuation policy consulted on idle. |
required |
max_nudges
|
int
|
consecutive-idle nudge budget (resets when the agent transitions back to verified-busy). |
required |
transcript_path
|
Path | None
|
raw pipe-pane log destination (debug artifact), or None to skip transcript capture. |
None
|
supervisor_report_path
|
Path | None
|
where the instrument supervisor writes its JSON forensic report (GH #487). Read after the attempt ends; an absent/unreadable/malformed report simply means no forensics — it never fails the attempt. |
None
|
on_pane_pid
|
Callable[[int], None] | None
|
callback fired with the pane PID once known — the backend routes this to the baton's process-group registration. |
None
|
on_output
|
Callable[[str, bytes], None] | None
|
live output sink |
None
|
Never raises TmuxError — tmux failures map to session_lost /
startup_failed outcomes. CancelledError propagates (after
cleanup) so musician-task cancellation works unchanged.
Source code in src/marianne/execution/instruments/interactive/driver.py
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 | |