Pi (pi-mono)

Pi is an open-source AI agent harness. OpenClaw is derived from Pi and inherits its core file read and compaction machinery.

Chasen Liao (2026-08-27) 把主力从 Claude Code 切到 Pi 后,强调 Pi 的价值是 thin core + 可自建控制面:读改代码、跑 Shell、加载规则、按需 SubAgent、改完验证。其余用 AGENTS.md / Skills / Packages 拼。详见 pi-three-layer-harness。作者提醒 Pi 默认最高权限、没有沙箱。

File Read Management

  • Hard cap: 2,000 lines or 50KB, whichever hits first — even without the model requesting a slice
  • Style: head-truncated, with an explicit continuation nudge appended to the output: [Showing lines 1-2000 of 50000. Use offset=2001 to continue.]
  • Tool description reinforces pagination: “output is truncated to 2000 lines or 50KB. Use offset/limit for large files.”
  • Philosophy: harness-first — the harness protects the context window, then teaches the model to paginate

Session Compaction

  • Trigger: estimated context tokens exceed contextWindow - reserveTokens (default reserve: 16,384 tokens)
  • Kept: most recent ~20,000 tokens of messages (keepRecentTokens)
  • Summarized: everything older → passed to LLM for summarization
  • Summary placement: synthetic user message prepended to the kept tail
  • Safety: never cuts at an orphaned tool result — walks boundaries to keep tool-call/result pairs intact

Relationship to OpenClaw

openclaw.md inherits Pi’s read tool (2K line / 50KB cap) and compaction architecture, then adds:

  • Bootstrap file caps (12K chars/file, 60K total)
  • Tool result budgets (16K chars or 30% of context)
  • Multi-pass summarization
  • Pre-compaction flush via silent agentic turn
  • Non-destructive tool-result pruning on 5-min TTL

相关页面

harbor, openclaw, pi-three-layer-harness, chasen-liao, sandbox