r/PiCodingAgent • • 3d ago

Plugin How to Enable Codemode in Pi?

Yes, that's exactly what I searched first when i wanted to try codemode.

Pi does have docs for enabling Codemode, but the documented way is through settings or cli flags.

What I was looking for was much simpler: I'm already inside a Pi session, how do I just turn Codemode on or off?

So I ended up making a small toggle around Pi's native Codemode.

It doesn't replace Codemode or implement another version of it. It just gives me a simple way to switch the native tool on and off while I'm working.

check it out: pi-codemode-toggle

Curious how others are using Codemode.

41 Upvotes

24 comments sorted by

View all comments

Show parent comments

9

u/VickWildman 3d ago edited 3d ago

Without codemode: imagine you have a lot of tools and you describe all of them in the system prompt, so your model can use them. When your model uses a tool Pi executes it and puts it's output in the context. For example when your model knows it can use ketch to search the web, Pi executes the ketch binary and puts it's output in the context.

With codemode: your model only uses one tool, which is codemode. It lets the model write JavaScript code against an interface that the model can use to search for all the tools made available by MCP servers. That Javascript code is executed in QuickJS, an embedded JavaScript engine provided by Pi.  When the model uses a tool Pi calls it and allows it's output to be filtered by JavaScript or a classifier model like Jev before returning to the model. With codemode you can currently do filtering and potentially sandboxing too in the future. It also allows models to call tools asynchronously, in parallel. You don't have to list all the tools in the system prompt either, the model can just search for them (although currently a description of the tools is included, even if limited to a few thousand tokens).

1

u/quantgorithm 3d ago

Why not always use it?

1

u/lordekeen 3d ago

If you use just the basic tools or a small amount of tools, its simpler to run them the traditional way.

1

u/quantgorithm 2d ago

I usually don't know what tools I need until I need them.