Skip to content

0.23.0: agents on a local model, through Pi - #56

Merged
samifouad merged 6 commits into
mainfrom
claude/pi-client-55
Nov 14, 2026
Merged

samifouad merged 6 commits into
mainfrom
claude/pi-client-55

Conversation

@samifouad

Copy link
Copy Markdown
Member

closes #55

An agent can now run on a model of your own, such as a local Qwen through llama.cpp, by being set up in Pi (pi.dev), a third client next to Claude Code and Codex. Tested live: a Pi agent on Qwen3.5-4B (8k context, on an M1 Mac mini) answered an @mention in a channel.

What changed

clients.rs: Pi as a client (Kind::Pi)

  • Found with command -v pi. Set up with pi mcp add gild-<agent> --url <endpoint> --header Authorization=Bearer <token> --exposure direct, removed with pi mcp remove.
  • Checked by reading ~/.pi/agent/mcp.json back (pi mcp list connects to every server, so it's slow): the address, the token and exposure: direct must all match, or the setup fails with a message saying so.
  • Wake command: pi -p --no-session --no-context-files --tools 'mcp__gild_<agent>__*'. The tools allowlist means only the agent's gild tools, no Pi file/shell tools. Pi names MCP tools with every character other than a letter, digit or _ replaced by _ (pi_tool_prefix).

Why --exposure direct: Pi's default MCP exposure is codemode, where tools are reached only through scripts the model writes. With the wake command's allowlist, the model had no tools at all and the wake ended "stayed quiet". Direct tools are declared to the model like built-in ones, which also suits small models better than script-writing.

wake.rs: a Pi agent's written answer is its reply (Answer::Writes)

  • A 4B model reliably writes its answer instead of calling post_message. gild doesn't post a command agent's output, so the wake again ended "stayed quiet". I saw this in the real wake's event log: 2,526 tokens in, 139 tokens of answer written, no tool call.
  • For an agent whose wake command is exactly the Pi command gild set up (clients::answers_by_writing), the prompt says that what it writes back is posted where it was mentioned. gild posts it there (channel or thread) unless the agent already posted during the wake, or wrote NOTHING (offered for untagged thread replies).
  • Claude Code, Codex and hand-written wake commands are unchanged (Answer::Posts), so their deliberate "nothing to add" still stays quiet.

Copy: README "What works" and the Connect/Settings text mention Pi. Version 0.23.0.

Evidence

cargo test --locked --lib --manifest-path src-tauri/Cargo.toml
test result: ok. 56 passed; 0 failed; 2 ignored

cargo clippy --locked --all-targets --manifest-path src-tauri/Cargo.toml -- -D warnings
clippy exit=0 (no warnings)

npm run check   → exit 0
npm run build   → exit 0
cargo check --locked --all-targets (after the version bump) → exit 0

The new and changed tests:

  • clients::tests::gild_finds_the_clients_and_sets_the_agent_up_in_them: Pi through the whole cycle (status, connect, read back incl. exposure: direct, reconnect with a new token, disconnect). A stand-in pi writes mcp.json in the real one's shape (checked against Pi 1.5.1's actual output).
  • a_client_that_isn_t_installed_says_so: "Pi couldn't add gild-ava".
  • wake::tests::a_pi_agent_s_written_answer_is_posted_where_it_was_mentioned: posts as the agent where mentioned; nothing for empty/NOTHING; not again once it has posted; only the exact Pi command answers by writing.
  • wake::tests::the_prompt_says_how_the_answer_reaches_the_channel

Proving the fixes (each reverted, test run, restored):

  • Without --exposure direct: gild_finds_the_clients_and_sets_the_agent_up_in_them FAILED, "Pi couldn't add gild-ava: it doesn't read back the address, token and direct tools gild gave it".
  • Without posting the written answer: a_pi_agent_s_written_answer_is_posted_where_it_was_mentioned FAILED, left: ("Demo", "person", "hey @local") right: ("local", "agent", "Hi! What can I do for you?").

Not run locally: the app CI job (Linux WebKitGTK e2e), which only runs on Linux.

Known limit, not in this PR

An 8k-context model overflows with all 25 gild tools declared and 20 long recent messages (measured: 5,138 tokens in, then stop=length after one token). For the live test I trimmed the agent's tools by hand in Pi's mcp.json. gild should give local agents a small tool set and a short mention context automatically; that's the follow-up named in #55.

-claude

Pi (pi.dev) runs agents on a model of their own, including a local one
like Ava's. gild finds pi, adds the agent's server with pi mcp add
(--header Authorization=Bearer …), reads ~/.pi/agent/mcp.json back to
check it, removes it with pi mcp remove, and wakes the agent with
pi -p --no-session --no-context-files --tools 'mcp__gild_<agent>__*'
so it can use only its gild tools.
pi mcp add defaults to codemode exposure, where MCP tools are reached
only through codemode scripts. The wake command allows only the agent's
gild tools, so the model had no tools at all and could not post its
answer ("woken · stayed quiet"). gild now adds the server with
--exposure direct and checks it reading mcp.json back.
A small local model often writes its answer instead of calling
post_message, and gild doesn't post a command agent's output, so the
wake ended "stayed quiet". For an agent whose wake is the Pi command
gild set up, the prompt now says what it writes is posted where it was
mentioned, and gild posts it there unless the agent already posted
during the wake or wrote NOTHING. Claude Code, Codex and hand-written
commands keep posting with post_message.
Asked to make a doc, a Pi agent wrote the doc's text into the chat: the
prompt said to use tools only to look things up. It now says to do what
was asked with the tools (propose_doc_edit to create or change a doc)
and to write just the answer when done.
@samifouad
samifouad merged commit 8cf2593 into main Nov 14, 2026
3 checks passed
@samifouad
samifouad deleted the claude/pi-client-55 branch November 14, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agents on a local model: Pi as a client

1 participant