Skip to content

pi adapter is missing automatic tool-call logging #13

Description

@aliirz

What's missing

The pi adapter ships with just AGENTS.md and a .pi/skills/ symlink. There's no hook that automatically logs tool calls to AGENT_LEARNINGS.jsonl. The only way the episodic log gets populated is if the agent explicitly calls memory_reflect.py after significant actions — which in practice it skips constantly. So the log stays empty, the dream cycle gets no signal, and the compounding loop described in the README never actually starts.

The README harness table lists pi as "no (extension system)" for hook support. That's the misleading part — pi absolutely has an extension system. The tool_result event fires after every tool execution and is the direct equivalent of Claude Code's PostToolUse. The gap isn't architectural, it's just a missing file.

Why this matters

Claude Code gets claude_code_post_tool.py wired via settings.json PostToolUse. Pi gets nothing. Same brain, completely different behaviour depending on which harness you're in. Pi users who follow the README and expect the memory system to compound over time get quietly nothing.

The fix

Add .pi/extensions/memory-hook.ts to the pi adapter. Pi auto-discovers extensions from .pi/extensions/ at startup — no config needed. The extension subscribes to tool_result and writes to AGENT_LEARNINGS.jsonl using the same importance scoring and reflection format as claude_code_post_tool.py.

Relevant pi API:

pi.on("tool_result", async (event, ctx) => {
  const { toolName, input, isError } = event;
  // toolName: "bash" | "edit" | "write" | "read" etc.
  // isError: boolean
  // write to AGENT_LEARNINGS.jsonl here
});

Extensions in .pi/extensions/*.ts are auto-discovered at startup, no settings.json or CLI flags needed. Pi extension docs: https://github.com/badlogic/pi-mono

Also worth updating the README harness table from no (extension system) to yes (tool_result event) so future users aren't misled.

Happy to submit a PR if helpful — already have a working implementation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions