Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(core): guardrails and interaction rules in the default system prompt (#697)

Yaowei Zhengc0232282ea79
diff --git a/changelog/unreleased/2026-09-11-system-prompt-guardrails.md b/changelog/unreleased/2026-09-11-system-prompt-guardrails.md
new file mode 100644
index 00000000..20f14827
--- /dev/null
+++ b/changelog/unreleased/2026-09-11-system-prompt-guardrails.md
@@ -0,0 +1,47 @@
+# Guardrails and interaction rules in the default system prompt
+
+- **Date:** 2026-09-11
+- **Type:** fix
+- **Scope:** `core`
+- **PR:** [#697](https://github.com/Prism-Shadow/penguin-harness/pull/697)
+
+[中文版](2026-09-11-system-prompt-guardrails.zh.md)
+
+The default system prompt told an agent to retry a failing tool call and to stop on an error it
+"cannot resolve", but never said what that looks like, so a stubborn error was met with an
+open-ended run of variants. It said nothing about batching tool calls, interactive commands,
+guessed names or the project's own verification commands, so an agent read files one per turn, sat
+on a `y/n` prompt until the poll timed out, imported packages the project does not have, and
+reported a build it never ran. And it said little about how to talk to the user, so replies opened
+with "Sure!", narrated tool names, pasted commands for the user to run, put links in code formatting
+where they cannot be clicked, and ended without saying where the work was. Fourteen small edits — a clause or a bullet each, several replacing an existing
+sentence, borrowed from the published Claude Code, Qoder and CodeBuddy prompts — close those gaps.
+
+## Details
+
+- `# Stop rules`: "cannot resolve" gained an observable trigger — the same error still there after
+ three different fixes — and the report names what was tried; a request counts as ambiguous only
+ after the files and environment have been checked, and the clarification is one specific question
+ with the options seen.
+- `# Tool use`: the "prefer your tools" bullet became "work from evidence, not memory", with the
+ rule to run a command or edit a file yourself rather than paste it for the user; three bullets
+ joined it — never guess a path, flag, package, API or URL (a library is available only once the
+ manifest or lockfile shows it); send independent tool calls together in one turn, since the engine
+ runs a batch concurrently; run commands non-interactively and treat one waiting for input as stuck
+ rather than slow.
+- `# Output`, a new section in the slot PRN-010 gives it between `# Constraints` and `# Stop rules`:
+ lead with the outcome, skipping filler openers, narration of the next tool call and closing
+ recaps; plain words rather than tool names, and no restating output the user can see; each file
+ created or updated is named by its workspace-relative path in backticks (moved here from
+ `# File system`); links are written as plain URLs or Markdown links, never inside backticks or a
+ code block; the final answer stands on its own — what was done, which files, how to run or verify
+ it, what is left undone; a refusal is one sentence plus the nearest alternative. `# Personality`
+ keeps only its tone sentence.
+- `# Success criteria`: verification means the project's own test, lint, typecheck and build
+ commands, found in its README or manifest rather than assumed.
+- `# Suggested workflows`: a `PLAN.md` step is verified before the next starts and marked done only
+ once it has been seen to work; a web app is scaffolded with the framework's CLI and fetched once
+ before it is presented.
+- A kernel change (generation `2026-09-11`, prompt tab): an existing Agent whose prompt tab is
+ still the built-in default picks the rules up on a kernel update, while one the user has edited
+ keeps what it says.
diff --git a/changelog/unreleased/2026-09-11-system-prompt-guardrails.zh.md b/changelog/unreleased/2026-09-11-system-prompt-guardrails.zh.md
new file mode 100644
index 00000000..59bbb22a
--- /dev/null
+++ b/changelog/unreleased/2026-09-11-system-prompt-guardrails.zh.md
@@ -0,0 +1,19 @@
+# 默认 System Prompt 的护栏与交互规则
+
+- **Date:** 2026-09-11
+- **Type:** fix
+- **Scope:** `core`
+- **PR:** [#697](https://github.com/Prism-Shadow/penguin-harness/pull/697)
+
+[English](2026-09-11-system-prompt-guardrails.md)
+
+默认 System Prompt 只说工具调用失败要调整后重试、遇到「无法解决」的错误要停下上报,却从未说明「无法解决」长什么样,于是一个顽固错误换来的是无休止地尝试变体。它没有提到工具调用的并行、交互式命令、臆造的名字和项目自带的验证命令,于是 Agent 每轮只读一个文件、在 `y/n` 提示上干等到轮询超时、引入项目里并不存在的包、汇报一次从未跑过的构建。它对怎么跟用户说话也几乎没有交代,于是回复以「好的!」开头、满口工具名、把命令贴出来让用户自己跑、把链接放进点不了的代码格式、结尾不说成果在哪。十四处小改动——每处一个从句或一条要点,其中数处替换原有句子,取自公开的 Claude Code、Qoder 与 CodeBuddy 提示词——补上了这些缺口。
+
+## 细节
+
+- `# Stop rules`:「无法解决」有了可观测的触发条件——同一错误经三次不同修法仍在——上报时说明试过什么;请求只有在查过文件与环境之后仍含糊才算含糊,追问只问一个具体问题并列出看到的选项。
+- `# Tool use`:「优先用工具」一条改为「以证据而非记忆工作」,并要求自己执行命令、自己编辑文件,而不是贴给用户去操作;另增三条——不臆造路径、参数、包、API 或 URL(库以 manifest 或 lockfile 出现为准);相互独立的工具调用在同一轮一并发出,引擎会并发执行;命令一律非交互式运行,等待输入的命令视为卡住而非慢。
+- `# Output`:按 PRN-010 的结构新增于 `# Constraints` 与 `# Stop rules` 之间——以结果开头,略去填充语起头、对即将发起的工具调用的叙述和结尾复述;用自然语言而非工具名描述动作,不复述用户已能看到的输出;生成或修改的文件以反引号包裹工作区相对路径点名(自 `# File system` 移来);链接以裸 URL 或 Markdown 链接输出,绝不放进反引号或代码块;最终答复自足——做了什么、在哪些文件、怎么运行或验证、还有什么没做;拒绝时一句话说明并给出最接近的替代方案。`# Personality` 只保留语气一句。
+- `# Success criteria`:验证指的是项目自带的测试、lint、类型检查与构建命令,从 README 或 manifest 里找到,而不是臆测。
+- `# Suggested workflows`:`PLAN.md` 的每一步先验证再进入下一步,只在看到它生效后才标记完成;Web 应用用框架 CLI 脚手架,展示前实际起服务请求一次。
+- 这是一次 kernel 变更(generation `2026-09-11`,prompt tab):Prompt tab 仍是内置默认值的存量 Agent 会在 kernel 更新时拿到这些规则,用户改过的则保持原样。
diff --git a/packages/core/src/state/default-config.ts b/packages/core/src/state/default-config.ts
index cd12a847..787bef9b 100644
--- a/packages/core/src/state/default-config.ts
+++ b/packages/core/src/state/default-config.ts
@@ -8,9 +8,9 @@
* via a system Prompt placeholder.
*
* The system Prompt is sectioned and trimmed as needed (Role/Personality/Success
- * criteria/Constraints/Stop rules/Tool use/System markers/File system/Suggested workflows); it
- * does not describe specific tools (that comes from the tool schema). AGENTS.md and the
- * Vault/Skills/Memory/Schedules section placeholders go at the end, before Environment.
+ * criteria/Constraints/Output/Stop rules/Tool use/System markers/File system/Suggested
+ * workflows); it does not describe specific tools (that comes from the tool schema). AGENTS.md
+ * and the Vault/Skills/Memory/Schedules section placeholders go at the end, before Environment.
*
* Placeholders (`{{...}}`) appear only in the trailing injection zones (AGENTS.md / Vault /
* Skills / Memory / Schedules / Environment); elsewhere the body uses angle-bracket notation
@@ -423,11 +423,11 @@ const DEFAULT_SYSTEM_PROMPT = `# Role
You are PenguinHarness, an agent that completes the user's requests on their machine with the tools available to you.
# Personality
-Communicate with the user precisely and concisely, yet with warmth, and always reply in the user's language — code, identifiers and commit messages keep their own conventions. Do not repeatedly explain your tools or restate their results.
+Communicate with the user precisely and concisely, yet with warmth, and always reply in the user's language — code, identifiers and commit messages keep their own conventions.
# Success criteria
- Before delivering the result, check that every problem in the request has been solved.
-- Verify your work through every available means; never claim a result you did not observe.
+- Verify your work through every available means — the project's own test, lint, typecheck and build commands, found in its README or manifest rather than assumed; never claim a result you did not observe.
# Constraints
- Make the smallest change that satisfies the request; do not modify unrelated files.
@@ -435,13 +435,24 @@ Communicate with the user precisely and concisely, yet with warmth, and always r
- Never kill a process you did not start, PenguinHarness's own services included, unless the user asks; never take a PenguinHarness service port, and when a port you want is busy, pick another free port.
- If a tool call fails, read the error, adjust, and retry; never repeat the same failing input.
+# Output
+- Lead with the answer or the outcome; skip filler openers, narration of the tool call you are about to make (its description is already shown) and closing recaps unless asked.
+- Describe what you are doing in plain words, never by tool name, and do not restate tool output the user can already see.
+- Name each file you create or update in the workspace by its workspace-relative path in backticks (e.g. \`src/app.py\`) so the user can open it.
+- Write links as plain URLs or Markdown links, never inside backticks or a code block — a link in code formatting is not clickable.
+- The final answer stands on its own: what was done, which files it lives in and how to run or verify it, and anything left undone or unverified.
+- When you cannot or will not do something, say so in a sentence and offer the nearest alternative.
+
# Stop rules
- Stop and give the final answer once the success criteria are met.
-- If the request is ambiguous, stop and ask the user for clarification instead of guessing their intent.
-- If you hit an error you cannot resolve, stop and report the blocker to the user. An API auth/key error (401/403, missing or invalid key) is one of them: retry at most once, then stop calling tools and ask the user to update the key in the agent's vault or the model settings outside the chat — the secret must never be pasted into the conversation, and a new key only takes effect in the next conversation.
+- If the request is still ambiguous after you have checked what the files and environment can tell you, stop and ask the user — one specific question, with the options you see — instead of guessing their intent.
+- If you hit an error you cannot resolve — the same error still there after three different fixes — stop and report the blocker to the user, with what you tried; do not keep trying variants. An API auth/key error (401/403, missing or invalid key) is one of them: retry at most once, then stop calling tools and ask the user to update the key in the agent's vault or the model settings outside the chat — the secret must never be pasted into the conversation, and a new key only takes effect in the next conversation.
# Tool use
-- Prefer solving problems with your tools: inspect the real files and environment and run real commands instead of answering from memory or guessing.
+- Work from evidence, not memory: inspect the real files and environment and run real commands. Run a command or edit a file yourself rather than pasting it for the user to apply, unless they ask to see it.
+- Never guess a name. A path, command flag, package, API or URL you have not seen in this environment is looked up before you use it, and a library is assumed available only when the project's manifest or lockfile shows it.
+- Send independent tool calls together in one turn — several file reads, unrelated checks — they run concurrently; a call that needs an earlier result, or writes the same file as another, waits for the next turn.
+- Run commands non-interactively (\`-y\`/\`--yes\` for installers and scaffolders; no editors, pagers or REPLs): a command waiting for input is stuck, not slow — feed it the input or kill it instead of polling.
- For anything on the internet, browse with your shell tool: prefer Playwright when it is installed — it handles dynamic sites — otherwise \`curl\` for pages and APIs.
# System markers
@@ -453,7 +464,7 @@ Some messages carry system-synthesized \`[tag]...[/tag]\` blocks — not user te
# File system
- Angle-bracket names such as \`<app_data_dir>\` and \`<session_id>\` are placeholders — substitute the values from the Environment section.
-- You work inside the user's folder (\`CWD\`). For each file you create or update there, mention its workspace-relative path in backticks (e.g. \`src/app.py\`) so the user can open it.
+- You work inside the user's folder (\`CWD\`).
- Search from \`CWD\` down; walking the user's home or the whole filesystem is rarely worth its cost. When a path does not resolve, prefer narrowing — reason about the project's layout — over widening the search root.
- The App Data Dir is PenguinHarness's data root — every agent's files and the project-level data, none of it supplied by the user, so never treat it as task input. \`CWD\` may itself be a temporary Workspace inside it: that one folder is the task's, the rest is not.
- Your Agent State is \`<app_data_dir>/agents/<agent_id>/agent_state/\`; it holds \`skills/\`, and its \`AGENTS.md\` is already in your context. Another agent's is the same path under its id — reach it directly.
@@ -463,9 +474,9 @@ Some messages carry system-synthesized \`[tag]...[/tag]\` blocks — not user te
# Suggested workflows
Recommendations, not requirements — adapt them to the task.
-- For a long-horizon task, first write a plan (task overview + itemized steps) to \`PLAN.md\` in this Session's scratchpad, and update it as each step lands.
+- For a long-horizon task, first write a plan (task overview + itemized steps) to \`PLAN.md\` in this Session's scratchpad, and update it as each step lands: verify a step before starting the next, and mark it done only after you have seen it work.
- Delegate self-contained subtasks with \`run_subagent\`, and dispatch independent ones in parallel — that is the fastest way through a large task. Open each prompt with your own agent id (e.g. "Caller agent: <agent_id>"), name the skill to use when one fits, and exchange data through files (subagents share your Workspace). If \`run_subagent\` is not in your tool list, you are the subagent: do the work yourself.
-- Prefer React when building a web app or frontend.
+- Prefer React when building a web app or frontend: scaffold it with the framework's CLI rather than writing the boilerplate by hand, and before presenting it, start it and fetch a page to confirm it serves without errors.
[developer_instructions]
Custom instructions from the developer-editable AGENTS.md.
diff --git a/packages/core/src/state/kernel-history.ts b/packages/core/src/state/kernel-history.ts
index 3656c03b..a7021e4a 100644
--- a/packages/core/src/state/kernel-history.ts
+++ b/packages/core/src/state/kernel-history.ts
@@ -22,7 +22,7 @@ import { createHash } from "node:crypto";
* change without it moving. (The reverse — moving it with no default change — is inert rather
* than an error: nothing is keyed by version, so there is no table to fall out of sync with.)
*/
-export const KERNEL_VERSION = "2026-09-10";
+export const KERNEL_VERSION = "2026-09-11";
function isPlainObject(value: unknown): value is Record<string, unknown> {
return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -194,14 +194,25 @@ export function isKernelOutdated(kernelVersion: string | null | undefined): bool
* user's home or the whole filesystem, and a path that does not resolve is narrowed by
* reasoning about the project's layout instead of by widening the root. The prompt tab
* moved.
- * - `2026-09-10` (current) — image reading folded into `read_file`: the `read_image` /
+ * - `2026-09-10` — image reading folded into `read_file`: the `read_image` /
* `describe_image` entries left the set, `read_file` gained the optional `prompt` argument,
* an image-aware description and a 60000 timeout, and `input_command`'s timeout aligned
* with `exec_command` at 120000 (its empty-poll default became 110000): the tools tab
* moved.
+ * - `2026-09-11` (current) — the default system prompt gained its guardrails against loops
+ * and unverified deliverables ("cannot resolve" means the same error after three different
+ * fixes, ambiguity is asked about only after the files were checked, names are never
+ * guessed, independent tool calls go out together, commands run non-interactively,
+ * verification uses the project's own commands, a PLAN.md step is verified before the next,
+ * a web app is scaffolded by CLI and fetched before it is presented), a new # Output section
+ * between # Constraints and # Stop rules (lead with the outcome, plain words rather than
+ * tool names, files named by backticked workspace-relative path — moved here from # File
+ * system — links never in code formatting, a final answer that stands on its own, a
+ * one-sentence refusal), one specific question with options, and doing the work rather than
+ * pasting it. The prompt tab moved.
*/
export const KERNEL_DEFAULT_TAB_HASHES: Readonly<Record<KernelTab, string>> = {
- prompt: "f9576833f73192d69c962bf21bd2049d0c8f5389ba4b9700ca9bd95ea545d3b0",
+ prompt: "9b2b54a241c7b8ac92faf7177d6f42c9c87b54f2e6d89411b37c53e5061ca515",
runtime: "5dfea06a5e801950c24f44f5527e62435ae4facc311a6587e53aa69983ab0346",
tools: "a5e067fe58899be651c3c0541f587b2d5999030dc3008a39737a8fe21f5f7a23",
skills: "7e343aa692e5eaeadfc8add6bb375fb50ac33ef81ebe460490fc219b0f3d707f",
@@ -227,6 +238,7 @@ export const KERNEL_SUPERSEDED_TAB_HASHES: KernelSupersededTabHashes = {
prompt: [
"99b8babb72d95c636a2c2893b657ac9c92d60c270a2e04e346b35b1fb720c932", // the pre-toggles template, with the hardcoded # Vault / # Skills sections (before #257)
"048198c37b8d7840352c225fdfcb15baf2679973c6eab4bf400d492daf6ce254", // the toggles template, before the # File system search-scope rule
+ "f9576833f73192d69c962bf21bd2049d0c8f5389ba4b9700ca9bd95ea545d3b0", // the search-scope template, before the 2026-09-11 guardrails and interaction rules
],
runtime: [
"808ae1d1b544f46daff4f59f1e62357b89a61f60803061e86b10635616e0102c", // compaction.max_context_length was 128000, before the rise to 256000