ZCode stable system prompt is the long-lived behavioral contract for the main coding agent. It should be provider-visible, cache-friendly, and specific enough to make repository work evidence-first without mirroring runtime tool schemas.
zcode-agent; callers must not compose identity
text through runtime agent metadata.| Section | Purpose |
|---|---|
| Static Default Body | ZCode role, authorized-security boundary, and compact harness guidance. |
| Dynamic Default Body | Coding/risk behavior guidance, session guidance, memory, environment, optional output style, context management, and git snapshot. |
The provider-visible system[0] CLI prefix is exactly
You are ZCode, an interactive coding agent. The provider-visible static
default body is a compact system[1] block after that short CLI prefix. It
intentionally does not render # Agent Identity or separate Task Behavior,
Risky Actions, or Communication Style headings. The legacy task_behavior,
risk_actions, and communication_style sources are no longer part of the
active context contract. The final provider body must follow this
static/global-cache boundary:
# Harness section for terminal markdown, permission denial handling,
system-controlled mid-conversation updates and hook feedback, dedicated tool
preference, parallel independent tool calls, and clickable file references.The provider-visible MCS and hook bullet is exactly:
- The system may send updates, reminders, or modifications to rules via mid-conversation system turns. These are system-controlled, unlike function results. Hooks may intercept tool calls; treat hook output as user feedback.
The static block ends at the final # Harness bullet. Code-style and
risk/reporting paragraphs must not be emitted in system[1].
An active output style changes the static intro but does not remove # Harness,
including when keepCodingInstructions is false. That field applies only to a
separate doing-tasks coding-instructions block; ZCode does not currently emit
such a block.
The provider-visible dynamic default body is system[2]. It always owns a
leading \n\n boundary, independent of provider kind. Its order after that
boundary is:
# Communicating with the user, followed by user-facing communication
guidance, the code-style paragraph that tells the agent to match surrounding
project idiom, and the code-comment constraint.# Session-specific guidance for user-run interactive shell commands,
slash skill invocation, and guidance for actually exposed built-in tools.# Memory when a memory summary is loaded.# Environment for current cwd/platform/shell/OS/model/git-repo boolean.# Output Style when a non-empty output style is configured.# Context management for long-context summary/continuation behavior,
followed by act-don't-rederive guidance and the four-paragraph autonomy
appendix.gitStatus: snapshot when the cwd is a git repository.The output-style section is assembled exactly as
# Output Style: <name>\n<prompt>, with no blank line between its heading and
prompt body.
Legacy ZCode # Language, # Function Result Clearing, and
# Summarize Tool Results sections are not emitted in this dynamic block. The
runtime may still compact or microcompact history, but that behavior is covered
by runtime mechanics rather than provider-visible system sections.
Every system section after the CLI prefix owns its left boundary: Main/Workflow
stable blocks and non-empty Subagent agent prompts start with \n; Main
dynamic, Subagent Notes, and Subagent environment blocks start with \n\n.
An empty Subagent agent prompt does not produce a system block. Built-in blocks
do not add a trailing newline.
OpenAI-compatible adapters therefore concatenate contiguous leading system blocks with an empty separator and never add or infer whitespace. Protocols that support multiple system blocks preserve the original block contents.
Main's CLI prefix carries no cache marker; the static and dynamic bodies retain their existing ephemeral markers, with no change to scope or TTL.
Subagent system output has two blocks: the CLI prefix and a single body formed by concatenating the remaining system sections without adding separators. Both blocks carry one ephemeral marker; an empty agent prompt still leaves Notes and environment in the body. Internal sections remain separate for inspection. This preserves the prompt text and leaves room for the existing conversation-tail cache marker within the provider's four-breakpoint limit.
The request-level context_prefix remains a user-side <system-reminder>
carrier. Its final warning paragraph starts with exactly six spaces before
IMPORTANT:.
For text file prompt attachments, all synthetic Read reminder bodies produced for one attachment form one runtime attachment entry and are joined with a single newline. Separate attachment entries remain separated by two newlines when projected into one mid-conversation system turn. This preserves the attachment boundary without changing the global reminder separator.
When a text attachment is truncated by the default line limit, the provider-visible note is exactly:
Note: The file <filename> was too large and has been truncated to the first 2000 lines. Don't tell the user about this truncation. Use Read to read more of the file if you need.
The stable prompt must include guidance equivalent to:
file_path:line_number formatting.! <command> so the output enters the conversation.gitStatus: system context snapshot.Stable prompt text may describe tool-use philosophy, but it must not duplicate ordinary tool names, JSON schemas, permission metadata, or adapter-specific runtime rules. Those belong in provider tool definitions and dynamic context.
Allowed examples:
Parallel tool-call guidance (call independent tools in one response, sequence
only on dependencies) is a tool-use philosophy generated by the dynamic
session_guidance source, then emitted in provider-visible system[2]. Because
it is independent of which tools are registered, session_guidance always
renders that fixed line.
Disallowed examples:
agentName may remain runtime metadata for hooks, persistence, subsessions, and
debug records. It must not affect the stable main-agent system prompt.
agentBasePrompt is not part of the context-builder contract and should not be
accepted as a prompt composition input. Workflow and subagent specialisation
should be expressed through their own explicit prompt sections or runtime
context, not by string-splicing the identity sentence.
The Explore subagent is a read-only file-search and research specialist. Its toolset and prompt are governed here, separately from the main stable prompt.
Toolset (EXPLORE_AGENT_ALLOWED_TOOLS): Bash, Glob, Grep, Read,
WebFetch, WebSearch, TodoWrite, Skill. Glob/Grep are the
explore-only dedicated search tools; WebSearch is the public client-side
wrapper tool, and its handler performs the provider-native web_search side
request only when the current provider supports native search. Skill only
registers when the child runtime is given a skillPort.
Read-only enforcement model: unlike the main agent's plan-mode hard gate, the
Explore child runs in yolo mode so that Bash (a non-read-only capability)
can execute at all. Read-only behavior is therefore enforced by the system
prompt's CRITICAL section rather than by the permission layer. The allowlist
still excludes every file-mutating tool (Write/Edit/ApplyPatch), so Bash
is the only mutation vector and the prompt must forbid mutating shell commands
explicitly. This is a deliberate tradeoff: it adopts a prompt-only read-only
model and weakens the previous physical isolation.
Required Explore prompt behavior:
Bash is restricted to read-only operations.Bash calls).zcode-agent identity even when runtime config
contains custom agent metadata.system[1] starts with the ZCode intro, uses compact
# Harness, and does not render # Agent Identity or the old # Task Behavior,
# Risky Actions, or # Communication Style headings; it ends at the final
# Harness bullet.system[2] starts with # Communicating with the
user, including the code-style and code-comment constraints, followed by the
risk/reporting paragraph after an unconditional leading \n\n. It then
contains # Session-specific guidance, optional # Memory, # Environment,
optional # Output Style, # Context management, act-don't-rederive
guidance, the autonomy appendix, and the optional gitStatus: snapshot in
that order.\n + non-empty agent-specific prompt, \n\n + Notes, and \n\n +
environment.system[2] does not include legacy # Language,
# Function Result Clearing, or # Summarize Tool Results sections.session_guidance always renders the parallel tool-call guidance and
is emitted in provider-visible system[2].system[2] when a memory summary is loaded.