You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.
In addition to the tools above, you may have access to other custom tools depending on the project.
Guidelines: ${guidelines} ← guideline,就是告诉 Agent 具体怎么工作,例如: - Be concise in your responses - Show file paths clearly when working with files
Pi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI): - Main documentation: ${readmePath} - Additional docs: ${docsPath} - Examples: ${examplesPath} (extensions, custom tools, SDK) - When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory - When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md), environment variables (docs/environment-variables.md) - When working on pi topics, read the docs and examples, and follow .md cross-references before implementing - Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)`;
pi 的系统提示词非常简短,几乎只有一句话:You are an expert coding assistant,而后面还有补充说明 Agent 应该干的事情:You help users by reading files, executing commands, editing code, and writing new files.,这就是有效的角色扮演,用简短的语句告诉 LLM 你该干什么。
接下来是 toolslist,是引用式的,只给出了 name 和 description 这两个基本属性,工具的所有详细信息,比如 Schema,全部在下方给出。
[ { "type":"session", "version":3, "id":"01a0136e-ba6c-7b7b-8205-ba7f1767f298", "timestamp":"2026-08-18T05:53:38.924Z", "cwd":"C:\\Users\\a1829\\Desktop\\pi" }, { "type":"model_change", "id":"94db3e22", "parentId":null, "timestamp":"2026-08-18T05:53:39.119Z", "provider":"deepseek", "modelId":"deepseek-v4-flash" }, { "type":"thinking_level_change", "id":"6f707f7c", "parentId":"94db3e22", "timestamp":"2026-08-18T05:53:39.119Z", "thinkingLevel":"max" }, { "type":"custom", "customType":"pi-deck-todo", "data":{ "todos":[], "nextId":1 }, "id":"edb88bc9", "parentId":"6f707f7c", "timestamp":"2026-08-18T05:53:39.121Z" }, { "type":"message", "id":"54f05dc6", "parentId":"edb88bc9", "timestamp":"2026-08-18T05:57:42.054Z", "message":{ "role":"user", "content":[ { "type":"text", "text":"我正在学习pi的session.jsonl的结构,本次交互中你只能read一次目录下的README.md,然后总结内容告诉我,也就是说,本次的交互流程应该是:```我输入->llm启动->返回工具意图->内核使用工具,返回结构->llm第二次启动->向我输出总结->结束```,这样我能很清晰地看到session.jsonl里面的简洁内容。" } ], "timestamp":1787032662053 } }, { "type":"message", "id":"3410567f", "parentId":"54f05dc6", "timestamp":"2026-08-18T05:57:45.863Z", "message":{ "role":"assistant", "content":[ { "type":"thinking", "thinking":"The user is learning about pi's session.jsonl structure. They want me to:\n1. Only use `read` once on the README.md in the current directory\n2. Then summarize the content to them\n\nWait, let me re-read. \"本次交互中你只能read一次目录下的README.md\" - \"In this interaction, you can only read the README.md in the directory once\"\n\nHmm, but which README.md? The current working directory is C:/Users/a1829/Desktop/pi. Let me check what's in there. Actually, the user says \"目录下的README.md\" - README.md in the directory (current working directory presumably).\n\nWait, but the project context says the AGENTS.md is at C:\\Users\\a1829\\Desktop\\pi\\AGENTS.md. So the cwd is the pi repo root. There should be a README.md there.\n\nThe user wants me to:\n1. Read README.md once (only once)\n2. Summarize the content\n3. Not do anything else with tools\n\nThis is to demonstrate the session.jsonl flow: user input -> llm start -> tool intent returned -> kernel uses tool, returns structure -> llm second start -> output summary -> end.\n\nSo I should do exactly one read call, then summarize. Let me do that.\n\nActually, should I check if README.md exists first? The user explicitly said I can only read once. So I should just read it. If it doesn't exist, the error would be informative too, but let me just try reading it.\n\nThe file might be large. Let me just read it once.", "thinkingSignature":"reasoning_content" }, { "type":"toolCall", "id":"call_00_HqSiet6TDVJULMCZQdEG3395", "name":"read", "arguments":{ "path":"C:/Users/a1829/Desktop/pi/README.md" } } ], "api":"openai-completions", "provider":"deepseek", "model":"deepseek-v4-flash", "usage":{ "input":160, "output":393, "cacheRead":22784, "cacheWrite":0, "reasoning":338, "totalTokens":23337, "cost":{ "input":0.000022400000000000002, "output":0.00011004000000000001, "cacheRead":0.0000637952, "cacheWrite":0, "total":0.0001962352 } }, "stopReason":"toolUse", "timestamp":1787032662054, "responseId":"b726f8ab-b209-4661-8575-6f66389443a0" } }, { "type":"message", "id":"b4226897", "parentId":"3410567f", "timestamp":"2026-08-18T05:57:45.866Z", "message":{ "role":"toolResult", "toolCallId":"call_00_HqSiet6TDVJULMCZQdEG3395", "toolName":"read", "content":[ { "type":"text", "text":"<p align=\"center\">\n <a href=\"https://pi.dev\">\n <img alt=\"pi logo\" src=\"https://pi.dev/logo-auto.svg\" width=\"128\">\n </a>\n</p>\n<p align=\"center\">\n <a href=\"https://discord.com/invite/3cU7Bz4UPx\"><img alt=\"Discord\" src=\"https://img.shields.io/badge/discord-community-5865F2? ......(此处省略)" } ], "isError":false, "timestamp":1787032665865 } }, { "type":"message", "id":"d873db64", "parentId":"b4226897", "timestamp":"2026-08-18T05:57:50.593Z", "message":{ "role":"assistant", "content":[ { "type":"thinking", "thinking":"The user wanted me to read README.md once and summarize. I did that. Now I summarize the content. Keep it concise, in Chinese since the user wrote in Chinese.", "thinkingSignature":"reasoning_content" }, { "type":"text", "text":"已读取完毕,这是 `README.md` 的内容总结:\n\n**项目简介**:这是 Pi Agent Harness 项目仓库,包含一个可自我扩展的编码 agent。\n\n**核心包**(3 个 npm 包):\n- `@earendil-works/pi-coding-agent`:交互式编码 agent CLI\n- `@earendil-works/pi-agent-core`:agent 运行时(工具调用 + 状态管理)\n- `@earendil-works/pi-ai`:统一多提供商 LLM API(OpenAI、Anthropic、Google 等)\n- (另有 `pi-tui`:带差异渲染的终端 UI 库)\n\n**权限与容器化**:Pi 没有内置权限系统,默认以启动它的用户权限运行;如需隔离,可用 Gondolin 扩展、Docker 或 OpenShell 三种沙箱模式。\n\n**开发命令**:`npm install --ignore-scripts`、`npm run build`、`npm run check`(lint/format/typecheck)、`./test.sh`(跑测试)、`./pi-test.sh`(从源码运行)。\n\n**供应链安全**:直接依赖精确锁定版本、lockfile 为依赖事实依据、pre-commit 阻止意外的 lockfile 提交、发布前用 `release:local` 在仓库外做冒烟测试、CI 用 `npm ci --ignore-scripts` 并定时跑 npm audit。\n\n**开源会话共享**:鼓励分享 OSS 编码会话,可用 `badlogic/pi-share-hf` 发布到 Hugging Face,作者自己在 [badlogicgames/pi-mono](https://huggingface.co/datasets/badlogicgames/pi-mono) 发布会话。\n\n**其他**:MIT 协议;新贡献者的 issue/PR 默认自动关闭,维护者每日审查;学习资料见 pi.dev。\n\n---\n\n这就是本次交互在 session.jsonl 中的记录结构:你的输入 → LLM 第一次调用(生成了 `read` 工具调用意图)→ 内核执行工具并返回结果 → LLM 第二次调用(基于结果生成总结)→ 输出给用户。你可以打开 session.jsonl 对照查看这几次消息的记录格式。" } ], "api":"openai-completions", "provider":"deepseek", "model":"deepseek-v4-flash", "usage":{ "input":1726, "output":510, "cacheRead":23296, "cacheWrite":0, "reasoning":36, "totalTokens":25532, "cost":{ "input":0.00024164000000000002, "output":0.0001428, "cacheRead":0.0000652288, "cacheWrite":0, "total":0.0004496688 } }, "stopReason":"stop", "timestamp":1787032665866, "responseId":"9c1da671-a712-4295-83b4-5acd2a967b43" } } ]
{ "name":"read", "description":"Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images aresent as attachments. For text files, output is truncated to 2000 lines or 50KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.", "input_schema":{ "type":"object", "properties":{ "path":{"type":"string","description":"Path to the file to read (relative or absolute)"}, "offset":{"type":"number","description":"Line number to start reading from (1-indexed)"}, "limit":{"type":"number","description":"Maximum number of lines to read"} }, "required":["path"] } }
Pi 种只保留了四种工具,且每种工具都只包含一个单一功能,工具直接没有直接的功能重叠,这有助于 LLM 立刻判断应该用什么工具,而不会花费精力去横向对比,这也是一个工具定义的一个哲学。