Repository navigation
Description
Pi's coding agent loads TypeScript extensions that see each tool call before it runs (extensions). A tool_call handler gets toolName, toolCallId and input, and blocks the call by returning {block: true, reason}; a handler that throws blocks it too ("tool_call errors block the tool (fail-safe)"). tool_result carries the same toolCallId with the result (content, isError), and session_start, session_shutdown and input cover the session and what the person typed. Every MCP call (mcp__<server>__<tool>) and every call a codemode script makes goes through the same handlers, a nested one with parentToolCallId (MCP). Pi finds extensions in ~/.pi/agent/extensions/ and, once a project is trusted, in its .pi/extensions/. The built-in tools are bash (command), read (path), write (path, content), edit (path, edits), grep, find and ls (path), and powershell. Pi has 120k GitHub stars; v1.5.0 shipped on 2 Nov 2026.
This is the shape of OpenCode's plugin, which Tracekit already generates (_opencode_plugin in tracekit/agent_hooks.py): a small extension that spawns the Python hook for each event without blocking Pi's event loop. Unlike OpenCode, Pi also gives session and prompt events, so prompts and session ends can be recorded.
Task:
- In a real
pirun, confirm thattool_callwaits for a handler that takes minutes (a held call), whatctx.sessionManager.getSessionId()andgetSessionFile()return (a run id, and a transcript to hash), and whetherinputcarries the typed prompt before expansion. Record the payloads the extension builds as cases intests/data/harness/pi.json. - Add
pitoAGENT_NAMES.tool():bash→Bash,read→Read,write→Write,edit→Edit(path:path),grep,findandlsdecided onpath, MCP tools asmcp__<server>__<tool>. Decide howpowershellis decided (Tracekit's shell rules read POSIX shells; holding it for a person is the safe default) and say so in the docs. - Generate
~/.pi/agent/extensions/tracekit.ts(--project:.pi/extensions/tracekit.ts) with a marker line, refusing to overwrite a file Tracekit didn't write, as_install_opencodedoes. Itstool_callhandler returns{block: true, reason}unless the hook exits 0, and kills a hook still running after 600 s and blocks;tool_result,session_start,session_shutdownandinputsend the post-tool, session and prompt events. Wiretracekit init --dev [--v2] --agent pi/uninstall/doctor. - Tests: in
tests/test_agent_hooks.py(mapping, the generated extension, the installer's refusal) and the recorded cases throughcases("pi")intests/test_harness_hooks_v2.py. - Add
~/.pi/agent/extensionsand.pi/extensionstoTK-F009/TK-F015intracekit/policy2/packs/coding.yaml, a column indocs/coding-agents.md, anddocs/limits.mdrows:pi --no-extensions(-ne) starts Pi without Tracekit's extension; a project's extension loads only once the project is trusted; howpowershellis decided.
Done when: in a real Pi session (say which version in the PR) a denied call is blocked, a held call waits for tracekit approvals approve, an MCP call is decided, and the session's calls and prompts show up in tracekit last; the tests pass and make test passes.
Comment here to claim it. Commits need a DCO sign-off (git commit -s).
Activity
LoopGlitch26 commentedon Nov 10, 2026
Refreshed as #696 with current file paths.