Skip to main content

handle_spawn_worker

Function handle_spawn_worker 

Source
pub(crate) fn handle_spawn_worker(
    workspace: &Arc<Workspace>,
    project_key: ProjectKey,
    args: WorkerSpawnArgs,
    spawned_by: SessionSlot,
    resume_existing: Option<&str>,
    from_boot_respawn: bool,
    return_to: Sender<Result<WorkerSpawnReply, String>>,
)
Expand description

Handle a Command::SpawnWorker: insert a Spawning worker entry in live_workers[project_key], dispatch a spawn for the id the worker will run under (or the id being resumed) with the charter threaded onto SessionLaunchSettings, then reply on return_to with that id and the tag value. The Connected handler in session_task::translate_event writes the actual JSONL tag row and transitions the entry from Spawning to Running (or rolls back on tag-write failure).

The reply’s session id is informational: the LLM’s agents__spawn caller addresses the worker by label, not by id, and logs the id to have a stable handle on the row.