§1

DeepSeek and Pi through one ledger

DimensionDeepSeek HarnessPiDesign consequence
CompositionCordis plugin tree; services, events, effects, scopes, profiles, bundles.Provider package + reusable agent package + coding product; direct config/callbacks and product extensions.DeepSeek emphasizes replaceable providers; Pi makes the minimal loop easier to isolate.
LoopAgent factory plus per-session phase machine and event waterfalls.Compact agentLoop()/runLoop() wrapped by Agent and coding AgentSession.Both separate model calls from harness control; interception style differs.
Durable stateAppend-only typed session events; surface operations derive model history.Append-only branchable session-entry tree; active path plus compaction/branch summaries builds context.DeepSeek centers replay projections; Pi centers navigable session paths.
Context pressureToken-meter seam, model-free pruning, summary replacement, spill artifacts.Bounded tools, transform/convert boundary, fixed defaults, valid cut points, recent-tail summary.DeepSeek decomposes capabilities; Pi keeps coding policy close to the product.
PermissionsTool waterfalls, monotonic guards, approval, sandbox and capability policies.Tool hooks and project trust are extensible; README states no built-in permission system and recommends external confinement.Deployment responsibility sits at a different layer.
DelegationCore provider seam with spawn/fork/external/continuable backends.Demonstrated as a coding extension that starts separate Pi processes.Feature label is similar; architectural status is different.

§2

A scoped Pi assessment

Pi’s strength is legibility across layers. The provider boundary, reusable event loop, and coding product can be read separately, and the extension system gives product users broad customization. Its context implementation is concrete: read caps, append-only branch entries, explicit cut points, and summaries are easy to locate.

The embedder owns the missing product policy. A small reusable core cannot silently promise product-level permission safety, and Pi explicitly does not. An embedder must design approval, confinement, trust, and extension loading for its deployment.

§3

Lab 1 · locate the tool loop

  1. Open packages/agent/src/agent-loop.ts, lines 152–220.
  2. Mark the message conversion call, assistant stream, tool-call extraction, length-stop guard, result append, and continuation decision.
  3. Find prepareToolCall, execution, and finalization. Write what each stage may change.
  4. Explain why completion-event order can differ from persisted result order in parallel mode.

§4

Lab 2 · change a read budget on paper

Find DEFAULT_MAX_LINES and DEFAULT_MAX_BYTES in truncate.ts. Suppose the byte cap is halved. List affected tool description, tests, continuation guidance, first-line edge case, and the expected context tradeoff. Do not assume the core loop changes.

§5

Lab 3 · follow a compaction cut

  1. Start at the threshold formula and calculate it for the selected model window.
  2. Walk the current branch backward toward keepRecentTokens.
  3. Reject an invalid tool-result boundary.
  4. Separate summarized history, any split-turn prefix, and retained tail.
  5. Find where the resulting compaction entry changes active context construction.

Trigger Cut points

§6

Lab 4 · add an extension hook safely

Choose one: add a read-only tool, annotate successful results in afterToolCall, or contribute a skill directory in resources_discover. Specify load location, project-trust behavior, cancellation, session cleanup, model-visible change, and why the hook does or does not need external confinement. Source · extension guide

§7

What travels to the next codebase

Both repositories make the foundation’s four actors visible. DeepSeek locates more harness policy in swappable services and event stages. Pi exposes a smaller agent protocol, then builds a coding product and extensions around it. The right design depends on whether you need a platform for provider substitution or a direct runtime that embedders can shape.

When comparing another harness, use the broader foundation checklist: model boundary, context working set, tool authority, durable state, extension contract, delegation semantics, and evidence class.

Created by Varma Chanderraju. Built with Codex, Claude and Gemini. · Glossary · Sources