Repository navigation
0.23.0: agents on a local model, through Pi - #56
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)command -v pi. Set up withpi mcp add gild-<agent> --url <endpoint> --header Authorization=Bearer <token> --exposure direct, removed withpi mcp remove.~/.pi/agent/mcp.jsonback (pi mcp listconnects to every server, so it's slow): the address, the token andexposure: directmust all match, or the setup fails with a message saying so.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 iscodemode, 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)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.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 wroteNOTHING(offered for untagged thread replies).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
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-inpiwritesmcp.jsonin 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_channelProving the fixes (each reverted, test run, restored):
--exposure direct:gild_finds_the_clients_and_sets_the_agent_up_in_themFAILED, "Pi couldn't add gild-ava: it doesn't read back the address, token and direct tools gild gave it".a_pi_agent_s_written_answer_is_posted_where_it_was_mentionedFAILED,left: ("Demo", "person", "hey @local") right: ("local", "agent", "Hi! What can I do for you?").Not run locally: the
appCI 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=lengthafter one token). For the live test I trimmed the agent's tools by hand in Pi'smcp.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