Skip to content

code-mode: move cell state into library actor#28599

Merged
cconger merged 2 commits into
mainfrom
cconger/code-mode-runtime-compact-02-cell-actor
Jun 17, 2026
Merged

code-mode: move cell state into library actor#28599
cconger merged 2 commits into
mainfrom
cconger/code-mode-runtime-compact-02-cell-actor

Conversation

@cconger

@cconger cconger commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

A code-mode cell is a single JavaScript execution that can produce output, call tools, wait for asynchronous work, resume, or be terminated. This PR extracts the existing per-cell run loop into a dedicated actor that owns the cell’s lifecycle state. It is primarily an ownership change rather than a new lifecycle contract: existing behavior now has one clear implementation boundary.

Architecture

The session service remains responsible for session-wide concerns: allocating cell IDs, storing shared values, creating cells, and routing requests to them.

Once a cell is created, its execution state belongs to its actor. Callers interact with the actor through a handle. The actor receives two kinds of input: runtime events and control requests.

A single event loop serializes these inputs and applies the lifecycle rules. It tracks the current observer—the caller waiting for an update—along with accumulated output, outstanding callbacks, runtime state, yield deadlines, and termination progress. Observation, termination, completion, and cleanup therefore have one consistent owner.

When the runtime has no immediately runnable work and is waiting only on timers or tool results, the actor can return accumulated output and information about outstanding tool calls while keeping the cell available to resume. On completion or termination, it performs the appropriate callback cleanup before publishing the final result and removing the cell from the session.

A small host interface connects the actor to session-owned facilities such as tool dispatch, notifications, stored values, and final cell removal, keeping those responsibilities outside the actor itself.

Why

Previously, cell lifecycle state and coordination lived alongside session management. The actor boundary makes each cell a self-contained state machine with a single writer, while the service becomes a registry and adapter around it.

This makes lifecycle behavior easier to reason about and test in isolation. It also establishes a clean boundary for later changing where cells run or how they communicate without recreating their lifecycle rules.

@cconger
cconger force-pushed the cconger/code-mode-runtime-compact-02-cell-actor branch from 2099c3a to 29f2d08 Compare June 16, 2026 22:36
@cconger
cconger merged commit e2f074e into main Jun 17, 2026
31 checks passed
@cconger
cconger deleted the cconger/code-mode-runtime-compact-02-cell-actor branch June 17, 2026 02:28
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants