Skip to content

feat: add resume-first executor sessions - #410

Merged
delete-cloud merged 2 commits into
mainfrom
executor-runtime-resume-first
Jun 1, 2026
Merged

delete-cloud merged 2 commits into
mainfrom
executor-runtime-resume-first

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add ADRs and task packets for executor/runtime terminology and resume-first session semantics
  • route local CLI/repl through durable SessionManager-backed run/session paths and add local JSONL/file persistence
  • add resume API/CLI behavior, interrupted-run linkage, checkpoint/tape/message-snapshot context assembly, and resume_boundary tape anchor metadata
  • align attached executor naming/compatibility paths and observability correlation metadata
  • add direct SQLite session/runtime store coverage for the local durable backend path

Verification

  • uv run pytest tests/cli/test_repl.py tests/cli/test_entrypoint_contract.py tests/cli/test_remote_client.py tests/ui/test_execution_binding.py tests/ui/test_session_manager_runtime.py tests/ui/test_http_server.py tests/ui/test_session_manager_public_api.py tests/ui/test_sqlite_session_store.py tests/coding_agent/test_pg_runtime_store.py tests/coding_agent/test_jsonl_runtime_store.py tests/coding_agent/test_sqlite_runtime_store.py tests/coding_agent/test_agent_observability.py -v -> 549 passed, 96 warnings
  • uv run ruff check <changed python files> --output-format=concise -> All checks passed
  • uv run ruff format --check <changed python files> -> 23 files already formatted
  • git diff --check -> passed

Note: full-repo ruff check src tests and full-repo ruff format --check src tests still surface pre-existing unrelated issues outside this PR scope.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements executor/runtime terminology alignment and session resume semantics by introducing local_attached execution binding, renaming worker-centric APIs to executor-centric with backward-compatibility aliases, adding JSONL/SQLite-backed durable session and runtime stores, implementing session resume with linked-run tracking and checkpoint context injection, and wiring managed session execution through CLI/REPL with new resume and inspection commands.

Changes

Executor/Runtime Terminology & Session Resume Implementation

Layer / File(s) Summary
Documentation & Requirements
coding-agent/.opencode/prompts/tasks/*.md, coding-agent/docs/adr/005[45]*.md
New ADRs 0054–0055 define executor/runtime terminology, resume-first direction, and session resume semantics with linked-run tracking and checkpoint injection. Task packets enumerate scope, references, and verification criteria.
Execution Binding & API Schemas
coding-agent/src/coding_agent/server/execution_binding.py, coding-agent/src/coding_agent/server/schemas.py
Added LocalAttachedExecutionBinding dataclass and updated union type. Extended SessionSummaryResponse with resume/checkpoint fields. Added ResumeSessionRequest and ExecutorListResponse schemas. Updated worker request models to accept both worker_id and executor_id via validation aliases.
Runtime Store Backends
coding-agent/src/coding_agent/runtime_store.py
Introduced JSONLRuntimeStore and SQLiteRuntimeStore for append-only JSONL and transactional SQLite persistence of runs, events, snapshots, and interactions. Updated PostgreSQL store to generalize run-claiming SQL for both external_worker and local_attached binding kinds.
Session Storage Backends
coding-agent/src/coding_agent/server/stores/session_store.py
Added FileSessionStore (JSON files) and SQLiteSessionStore (SQLite records) with thread-locking and atomic writes. Extended create_session_store factory to route fs, file, json, and sqlite backends.
Attached Executor API & Remote Integration
coding-agent/src/coding_agent/remote/worker.py, coding-agent/src/coding_agent/remote/client.py
Refactored from "external worker" to "attached executor" API contract with AttachedExecutorError and AttachedExecutorConsumer. Renamed execution paths and updated endpoints to /executor/runs/*. Added remote executor listing/status functions and stream_resume_or_run_request SSE helper.
Session Manager Resume & Execution
coding-agent/src/coding_agent/server/session_manager.py
Introduced SessionResumeContext with metadata/checkpoint/tape-tail collection. Implemented request_attached_executor_run, resume_session orchestration with resume boundary anchors, and runtime event correlation. Changed IO guard to threading.Lock and added JSONL/file/SQLite backend routing. Propagates resume_context through observation recording and runtime metadata.
HTTP API Endpoints
coding-agent/src/coding_agent/server/http_server.py
Renamed /worker/* routes to /executor/* with backward-compatible dispatch. Added /sessions/{session_id}/resume SSE endpoint and /executors list/detail endpoints. Implemented _session_summary_response helper enriching session payloads with resume metadata.
Observability
coding-agent/src/coding_agent/agent_observability.py
Extended AgentObservationRecorder.start_turn to accept optional attributes parameter, merged with sanitized allowed entries, and propagated into emitted child and turn spans.
CLI Commands & Session Management
coding-agent/src/coding_agent/cli/main.py
Added resume command and sessions command group with list, status, checkpoints subcommands. Refactored batch/interactive execution to use SessionManager with asyncio-driven managed turns. Implemented async helpers for session inspection, resume, and wire-message streaming.
REPL Managed Sessions
coding-agent/src/coding_agent/cli/repl.py
Updated InteractiveSession to use _local_session_manager() with explicit fs/jsonl backend configuration. Refactored _process_message to branch on session availability: if session exists, runs managed turn via asyncio task with concurrent wire streaming and root-TurnEnd detection; otherwise falls back to direct run_turn.
Remote CLI Executor Terminology & Resume
coding-agent/src/coding_agent/cli/remote_commands.py
Updated to reflect attached-executor terminology by renaming commands and adding --executor-id support with --worker-id backward compatibility. Introduced remote executor, remote executors, remote executor-status, and remote resume commands. Extended session/run listing with executor id, resumable flag, and checkpoint columns.
Comprehensive Test Coverage
coding-agent/tests/cli/test_*.py, coding-agent/tests/ui/test_*.py, coding-agent/tests/coding_agent/test_*.py
Added extensive contract/integration tests validating managed-session CLI execution, session resume flow with linked runs, local session inspection, checkpoint persistence across store instances, attached executor claiming, HTTP resume endpoints, runtime event correlation, and wire-message payload structure. Updated existing tests to assert executor terminology, resume fields, and new metadata expectations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#407: Implements the external-worker control-plane foundation that this PR refactors into attached-executor/resume semantics, extending claim/prompt/event endpoints and runtime store claiming logic.
  • delete-cloud/Coding-Agent-Loop#375: Restructures the CLI entrypoint that this PR extends with managed-session/resume commands in the same src/coding_agent/cli/main.py module.
  • delete-cloud/Coding-Agent-Loop#402: Modifies observability span emission in AgentObservationRecorder that this PR extends to propagate turn-level attributes into nested spans.

🐰 Session resume hops through the checkpoint forest,
Old runs linked like clover chains,
Executor names now loud and proud,
Where workers once hid in the weeds,
Fresh spawns bloom from durable seeds. 🌱

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch executor-runtime-resume-first

@delete-cloud
delete-cloud merged commit 9c2d6a0 into main Jun 1, 2026
1 check was pending
@delete-cloud
delete-cloud deleted the executor-runtime-resume-first branch June 1, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant