Skip to main content

Side Execution

Side execution runs background work alongside a main agent — spawning a separate process that communicates via WebSocket, without blocking the agent's main loop.

Side executions are managed by the server's SideExecutionManager and exposed through the codebolt.sideExecution SDK module.

When side execution fits

  • Running action blocks — invoke a registered action block as a background operation.
  • Inline code execution — run a snippet of JavaScript in an isolated process.
  • Parallel work — kick off multiple operations that don't need to block the main agent.
  • Background processing — long-running tasks like code analysis, plan generation, or task breakdown.

If the agent needs the result before proceeding, it can await the side execution's completion (the manager provides a waitForCompletion mechanism).

Two execution modes

1. Action block execution

Run a registered action block by path:

import codebolt from '@codebolt/codeboltjs';

const result = await codebolt.sideExecution.startWithActionBlock(
'./action-blocks/break-task-into-jobs', // path to action block
{ plan, task, existingJobs }, // parameters
60000 // timeout in ms (optional)
);

2. Inline code execution

Run arbitrary JavaScript code in an isolated process:

const result = await codebolt.sideExecution.startWithCode(
`
const data = await fetch('https://api.example.com/data');
return await data.json();
`,
{ apiKey: 'xxx' }, // parameters available in execution context
30000 // timeout in ms (optional)
);

Management APIs

// List available action blocks
const blocks = await codebolt.sideExecution.listActionBlocks(projectPath);

// Get status of a running side execution
const status = await codebolt.sideExecution.getStatus(sideExecutionId);

// Stop a running side execution
await codebolt.sideExecution.stop(sideExecutionId);

Lifecycle states

Side executions move through these states:

STARTING → RUNNING → COMPLETED
→ FAILED
→ TIMEOUT
→ STOPPING (when stop is requested)
StateDescription
STARTINGProcess spawned, waiting for WebSocket connection (30s timeout)
RUNNINGWebSocket connected, execution in progress
STOPPINGStop requested, waiting for graceful shutdown (5s before force kill)
COMPLETEDExecution finished successfully with a result
FAILEDExecution encountered an error
TIMEOUTExecution exceeded the configured timeout

How it works internally

  1. Spawn — the manager spawns a child process with environment variables (SIDE_EXECUTION_ID, THREAD_ID, PARENT_AGENT_ID, etc.)
  2. Connect — the child process establishes a WebSocket connection back to the server (30s timeout)
  3. Context — the server sends the thread context (messages, project path, agent metadata) over WebSocket
  4. Execute — the side execution runs its logic (action block handler or inline code)
  5. Complete — the execution sends an actionBlockComplete message with the result
  6. Cleanup — temp files are removed and resources are released

Available tools for LLM agents

Agents can use these tools to manage side executions during their reasoning loop:

ToolDescription
SideExecutionStartActionBlockToolStart a side execution with an action block path
SideExecutionStartCodeToolStart a side execution with inline JavaScript
SideExecutionStopToolStop a running side execution by ID
SideExecutionListActionBlocksToolList available action blocks
SideExecutionGetStatusToolGet status of a side execution by ID

Side execution vs. subagent

AxisSide ExecutionSubagent
ProcessSeparate child processFull agent instance
CommunicationWebSocketAgent protocol
ScopeSingle operation (action block or code)Open-ended task with full reasoning loop
ResultStructured return valueConversation output
Good forBackground operations, action blocks, parallel tasksDecomposition of work requiring reasoning

API reference

For detailed method signatures, parameters, and return types, see the CodeboltJS API reference:

For MCP-based access, see Side Execution MCP tools.

See also