Repository navigation
feat(agent-runtime): add opt-in sandboxed codemode tool - #2511
Merged
Merged
Conversation
Multi-step investigations and chains of MCP calls cost one model round trip per call and put every intermediate result into the context. The new codemode tool runs a short model-written script in a QuickJS-WASI worker so tools can be batched, chained and filtered locally, and only the script's output reaches the model. The sandbox holds no host function or credential. Each nested call goes through pi-agent-core runToolCall with the session's own hooks, so ToolSearch activation, mode policy, extension hooks, Host permission and approval, audit and cancellation are those of a direct call. Lineage uses nestedParentToolCallId, auxiliary model calls record identified usage, and the sidecar bundle ships the worker and WASM. The feature is off by default (Settings -> Agent behavior -> Execution, Agent mode only). fixes #2498
Deploying pi-desktop with
|
| Latest commit: |
458f5c9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://87b74eff.pi-desktop.pages.dev |
| Branch Preview URL: | https://feat-codemode-sandbox.pi-desktop.pages.dev |
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.
Summary
Implements #2498: an opt-in
codemodetool that runs model-written JavaScript in a QuickJS-WASI worker (@earendil-works/pi-codemode) and returns only the script output to the model.packages/agent-runtime/src/codemode/; noAgentSession.tools.*calls go throughrunToolCallwith the session's own hooks: Host permission/approval, ToolSearch activation, mode policy, extension hooks, file admission, cancellation (tools.abort). Only active tools are callable; control/delegation tools are excluded; Read/Glob/Grep may overlap, everything else is serialized.nestedParentToolCallId(neverparentToolCallId); nested rows are excluded from rebuilt model context; delegates do not inherit codemode.models.list/complete/classify/generateImagesexpose allowlisted metadata only; each physical request emits identified usage attributed to its starting turn.chunks/codemode-worker.js+chunks/quickjs.wasm; a packaged test runs a script outside node_modules.codemodeEnabled(default off, Agent only) with Settings UI and 9 locales.docs/adr/codemode-sandbox-boundary.md, spec and E2E plan updates.Validation
system-catimeout passed on rerun)biome lint,check:pi-dependenciesfixes #2498