System prompt assembly in Prime Agent is orchestrated by a single buildSystemPrompt function that merges a base prompt (either the RLM template or a custom one) with injected context—subagent guidance, active tools, skills, harness state, project files, and guidelines—in a strict order that ensures the model reads delegation rules before concrete specs and receives consistent cross-platform paths. The assembly process adapts its output based on what tools are enabled: IPython defaults when unspecified, skills inject only when file access exists, subagent guidance only when recursion is allowed, and each section's formatting is normalized to prevent duplication and embedding errors.
buildSystemPrompt in packages/coding-agent/src/core/system-prompt.ts is the single function that assembles the full system prompt, merging the base RLM prompt, subagent guidance, harness state, project context files, skills, additional guidelines, and an optional append section.[1] When no customPrompt is provided, buildSystemPrompt calls buildRlmPrompt as the base and then appends subagent guidance, harness state, additional guidelines, project context files, and the skills section in that order.[1] When a customPrompt is provided, buildSystemPrompt uses it as the base and still appends context files, skills, current date, working directory, child agent doctrine, harness state, and the append section — preserving full context injection.[1] The RLM prompt in packages/coding-agent/src/core/prompts/rlm.ts is the canonical source for RLM subagent constraints; it instructs the model to perform long-running tasks in a nonblocking manner, surface progress visibly, and clarify the scope of each task. The RLM prompt in packages/coding-agent/src/core/prompts/rlm.ts omits any reference to an async bash() kernel helper, as that function is not available in the kernel runtime; including it would cause the model to attempt calls that silently fail. The RLM prompt in packages/coding-agent/src/core/prompts/rlm.ts explicitly discourages use of subprocess.run, directing the model toward the agent's bash() tool instead, to prevent Python subprocess calls that bypass tool-call traceability and sandboxing. Tool-preference guidance in rlm.ts is order- and phrasing-sensitive; reordering sections or rewording tool instructions risks re-introducing model drift toward uncontrolled execution patterns.
buildSystemPrompt defaults selectedTools to ["ipython"] when none are provided, making IPython the only assumed tool.[1] All backslashes in cwd and messagesPath are normalized to forward slashes before being embedded in the system prompt, ensuring cross-platform consistency; messagesPath defaults to the string "not persisted" when the option is absent.[1] buildSystemPrompt embeds the current date (formatted YYYY-MM-DD) into custom prompts explicitly; the base buildRlmPrompt handles date injection for the default path.[1]
Subagent guidance (buildSubagentGuidance) is injected into the default prompt only when both allowRecursion is true (default) and ipython is an active tool.[1] Subagent guidance is positioned after the base RLM prompt prefix and before the harness-state menu, so the model reads when and why to delegate before seeing the concrete subagent specs it can match against — the same ordering convention used in Claude Code's Agent tool.[1] The skills section is appended (on both the custom and default paths) only when the model has file access — i.e., when at least one of ipython or bash is in the active tool list.[1] Skills tagged with disableModelInvocation are filtered out before the visible skills list is built and are never referenced in the system prompt.[1] BuildSystemPromptOptions.harnessState accepts a HarnessState that is serialized via formatHarnessStateForPrompt and appended as compact persistent context; IPython, bash, and refine example variants are included based on which tools and skills are active.[1]
BuildSystemPromptOptions exposes rlmDepth (fixed recursive-agent depth), rlmParentAgent (human-readable parent name for child doctrine), and allowRecursion (whether to include RLM recursion guidance) as first-class fields.[1] formatPromptGuidelines deduplicates guidelines by normalized (trimmed) text and emits each unique line as a bullet (- guideline), preventing duplicate instructions when callers supply overlapping guidelines.[1]
Sources