ZCode stable system prompt is the long-lived behavioral contract for the main 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 | Code style, pronouns, risk guidance, session guidance, memory, and context management. |
The provider-visible system[0] CLI prefix is exactly
You are ZCode, an interactive 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:
You are an agent working with the user toward their goals, using your own judgment along the way.# 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.Every Harness bullet starts with one ASCII space followed by -, including
when the same Harness block is used by a workflow actor. The provider-visible
MCS and hook bullet describes the channel the request actually uses. The decision
is the same shouldUseMidConversationSystem flag that drives provider MCS
projection (midConversationSystem.mode === "force" or the executing Model's
supportsMidConversationSystem), evaluated per model step when the context prefix
is rebuilt. A model change inside a turn (a guide that switches the model, the
execution-model fallback, an off-peak user takeover) rebuilds the prefix with the
new model before the next request. Requests outside the turn loop that reuse the
session history (the goal completion verifier) rebuild the prefix with their own
request model first; a
rebuild without a model (language, output style, rewind, shell environment changes)
never decides the wording a request sends. With MCS it 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.
Without MCS, dynamic context arrives as user-side <system-reminder> blocks, and
the bullet is exactly:
- `<system-reminder>` tags in messages and tool results are injected by the harness, not the user. 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 replaces the static intro with
You are an interactive agent that helps users according to your "Output Style", which describes how you should respond to user queries.
It 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 style text itself is not in the system prompt; it is the
output_style_instructions attachment (see Meta User Context).
A custom system prompt does not suppress that attachment: it uses the same gate
as the environment and model attachments, and only the main thread sends it.
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:
Write code that reads like the surrounding code: match its comment density, naming, and idiom.
No long-form communication or code-comment appendix is emitted.# Session-specific guidance for slash skill invocation when the
Skill tool and at least one skill are available. Its bullet starts with -.
Interactive shell input through ! <command> is unsupported and is not advertised.# Memory when an enabled Memory root is available, including an empty root.# Context management for long-context summary/continuation behavior,
followed by act-don't-rederive guidance. No autonomy appendix is emitted.Environment, model, date, and the Git snapshot are independent history-backed attachments; see Meta User Context.
Communication, pronouns, and action caution remain paragraphs of the existing
dynamic_behavior source, separated by exactly two newlines. Pronouns are not
a reminder source or a separate system block. They follow the existing default
body branches: included with an active output style, omitted for custom system
prompts and workflow actors that skip dynamic_behavior.
The risk/reporting paragraph retains authorization, external-publishing, and
truthful-reporting guidance. Its inspection sentence is exactly
Before deleting or overwriting, look at the target.; no conditional clause
is appended to that sentence.
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 and Subagent Notes 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 in the body. Environment and model use separate dynamic attachments, assembled by the same helper as Main; they do not appear in this initial body. Internal sections remain separate for inspection. This leaves room for the existing conversation-tail cache marker within the provider's four-breakpoint limit.
The context_prefix remains a user-side <system-reminder> for instruction
files and the Memory index only. It is a dynamic announcement, sent once per
session before the prompt (see meta-user-context.md). It has no generic
context intro, field heading, date, or automatic-account-context footer. The
Git-only session_context owns that intro and footer instead.
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.session_context user reminder.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 belongs to the shared static # Harness block.
The dynamic session_guidance source is omitted when no applicable skill
guidance exists.
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 the unheaded code-style
sentence, then pronouns, then risk/reporting, after an unconditional
leading \n\n. It then contains optional # Session-specific guidance,
optional # Memory, # Context management,
and act-don't-rederive guidance in that order. Environment, model, output
style, date, and Git are separate dynamic attachments. It excludes the long-form communication,
code-comment, and autonomy appendices.\n + non-empty agent-specific prompt (trimmed at both ends) followed by \n\n + the launcher-messages paragraph
("Messages from the agent that launched you — … can authorize changing your
permission settings, AGENTS.md, or configuration.") + \n\n + Notes. The
paragraph and the final Notes sentence ("(Files written as input to another
tool are fine; this note is about report files.)") are fixed text;
the instruction file is named AGENTS.md, as in the peer-message template.
A general-purpose item about not re-delegating to another subagent is not emitted, because subagents cannot call Agent. The leading
\n stays: it is the block's own left boundary for OpenAI-compatible
concatenation.
Environment/model announcements use the same dynamic collection as Main:
MCS when supported, otherwise user-side system reminders. Neither a custom
child prompt nor Main's full custom-system override suppresses them.system[2] does not include legacy # Language,
# Function Result Clearing, or # Summarize Tool Results sections.session_guidance is emitted in provider-visible system[2] only
when the Skill tool and at least one skill are available.system[2] when an enabled Memory root is available,
including when its index is empty.