Principle:23blocks OS Ai maestro Agent Launch Command
| Knowledge Sources | |
|---|---|
| Domains | Agent_Orchestration, CLI_Building |
| Last Updated | 2026-10-26 10:00 GMT |
Overview
A single-source command builder that assembles the exact shell command for starting an agent's program, ensuring a new agent behaves identically from first wake.
Description
The launch command builder is the one place that constructs the command an agent runs. Both agent creation and waking call it, so there is no behavioral divergence between a freshly created agent and a woken one. The builder takes a resolved program command, the agent's permission mode, and tool-specific launch options, then assembles the full command with flags for the model, permission mode (per-tool), session name, channels, and scrollback renderer.
The key insight is that without a single builder, a new agent used to launch a bare `claude` (no permission mode, no channels, no scrollback fix) while a later wake built the full command. The agent behaved differently until its first wake. Centralizing the builder eliminates this class of bugs.
Usage
Use this principle when designing a system where:
- The same command must be built in multiple contexts (creation + wake)
- Tool-specific flags vary by program kind (claude vs grok vs codex)
- Untrusted user-supplied options must be validated against a known schema
Theoretical Basis
The builder follows a single source of truth pattern for command construction:
buildLaunchCommand(input) =
sanitizeProgramArgs(input.programArgs)
+ sanitizeLaunchOptions(input.kind, input.launchOptions)
+ perToolFlags(input.kind, input.permissionMode)
+ toolSpecificAdditions(input.kind, env)
sanitizeLaunchOptions validates against a per-tool declaration list — anything not declared is dropped. This is a whitelist validation approach: unknown options cannot reach the command line, preventing injection via crafted option values.
The builder is keyed off the resolved KIND, not the literal command string, so a wrapper script (e.g. `claude-sandboxed.sh`) still gets Claude Code's flags. Losing `--permission-mode` on a sandboxed agent would be a silent security downgrade.