Repository navigation
Conversation
Signed-off-by: eshulman2 <ellashulman1@gmail.com>
E2E tests did not runE2E tests run automatically for pull requests authored by users with write access or higher. For other contributors, someone with write access must add the Reason: See E2E testing guide for details. |
Code Review by Qodo
1. Pi runtime guide still says empty tool lists use the old flag
|
PR Summary by QodoSelect exact vetted Pi extension tools for parent and child runs
AI Description
Merge Risk
|
ascerra
left a comment
There was a problem hiding this comment.
I'm for this. I hit the same limit with a small extension (code): once tools: names a built-in, Pi hides the extension tools, so I had to leave tools: off entirely (note).
One thing that may help now: with tools: left off, extension tools already run on fullsend. I ran them in a GitLab pipeline on v0.55.0 (results). So the CVE extension may not need to wait for this to run, only to be locked down. I haven't tried that extension itself.
Two questions inline.
Resolve native extension tools without widening parent or child permissions. Preserve MCP registration and exposure semantics, fail closed before inference, and guard the selector on launch and dispatch. Add pinned-Pi acceptance tests and document migration from silently ignored tool names. BREAKING CHANGE: Unknown Pi tool names now require a vetted extension that registers the exact requested name. Remove stale names or load their extension. Explicit empty selections now exclude extension tools as well as built-ins. Signed-off-by: eshulman2 <ellashulman1@gmail.com>
Signed-off-by: eshulman2 <ellashulman1@gmail.com>
Signed-off-by: eshulman2 <ellashulman1@gmail.com>
Site previewPreview: https://3eced406-site.fullsend-ai.workers.dev Commit: |
| | `providerModels` | Per provider a run can serve with no `models` entry, the model ids it can serve: `google-vertex` verbatim from the catalog the pinned pi bundles (`@earendil-works/pi-ai` `dist/providers/data/google-vertex.json`), and `xai-vertex` from the ids the vendored extension registers (`xai/grok-4.6`, the publisher-qualified wire form). `openai` is present only when the run-scoped OpenAI provider is attached, listing the ids that configured children resolve to (`subagents.<persona>`, `subagents.default`, a persona's frontmatter `model:`; `runtime.OpenAIChildren`), and its presence is what lets a non-openai parent dispatch to `openai` and turns on the OpenAI launch safeguards for the children (#7981). `gateway` is present only when a gateway run is registered, listing the ids of the rendered `inference-gateway.json`; it admits the `gateway` provider under any parent, since the extension's `-e` directory (`inference-gateway`) does not name the provider id (#8280). A `provider/id` call is accepted only when the full spec is in `models`, is the parent's own spec, or is listed here — a provider prefix alone is not enough, or an invented id would reach the API. A Grok spec is normalized to `xai-vertex/xai/<id>` first, exactly as `normalizeXaiVertexModel` does for the parent, and then goes through this same set | | ||
| | `thinking` | Children's `--thinking`; `FULLSEND_PI_SUBAGENT_THINKING` (validated) else `medium` | | ||
| | `tools` / `toolMode` / `exploreTools` | Parent selection and launch mode (`default` or `explicit`). Each launch and fallback retry queries `pi.getActiveTools()` and `pi.getAllTools()` for active names plus registered `codemode`/`deferred` tools: pi permits nested calls to the latter even when inactive. Inactive direct tools (including `defaultActive: false` direct tools) and other inactive registrations are not added. Default mode retains that callable set; explicit lists restrict names/patterns further. No built-in classification list is needed. Patterns are resolved against concrete callable names, then intersected with the persona's selection or Explore's read-only built-ins, always excluding `Agent`/`Task`. Missing `toolMode` retains explicit-list selection only; it does not guarantee compatibility with older manifests. Missing or malformed `mcpResourceTools` returns a structured `rejected` result before acquiring a child slot. An empty child selection becomes `--tools ''`, filtering both built-in and extension tools. For explicit nonempty parent and child selections without `mcp__` entries, `--exclude-tools` denies `mcp__*` plus each unselected resource tool (`list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource`), preserving selected resource names/patterns. The Go tool mapper translates Claude's `ListMcpResourcesTool` to both list resource tools and `ReadMcpResourceTool` to `read_mcp_resource`. It also accepts the three pi-native resource names and scoped `list_mcp_*`/`read_mcp_*` patterns in parent and persona configuration; those spellings are pi-only. Pi otherwise retains these registrations callable through codemode/deferred exposure even when inactive. Parents without `tools:` keep default behavior. Parents whose translated tools are empty still use `--no-builtin-tools`, but have no `Agent`/`Task`, so Bootstrap writes no child manifest | | ||
| | `tools` / `toolMode` / `exploreTools` | Parent selection and launch mode (`default` or `explicit`). Each launch and fallback retry queries `pi.getActiveTools()` and `pi.getAllTools()` for active names plus registered `codemode`/`deferred` tools: pi permits nested calls to the latter even when inactive. Inactive direct tools (including `defaultActive: false` direct tools) and other inactive registrations are not added. Default mode retains that callable set; explicit lists restrict names/patterns further. No built-in classification list is needed. Patterns are resolved against concrete callable names, then intersected with the persona's selection or Explore's read-only built-ins, always excluding `Agent`/`Task`. Missing `toolMode` retains explicit-list selection only; it does not guarantee compatibility with older manifests. Missing or malformed `mcpResourceTools` returns a structured `rejected` result before acquiring a child slot. An empty child selection becomes `--tools ''`, filtering both built-in and extension tools. For explicit nonempty parent and child selections without `mcp__` entries, `--exclude-tools` denies `mcp__*` plus each unselected resource tool (`list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource`), preserving selected resource names/patterns. The Go tool mapper translates Claude's `ListMcpResourcesTool` to both list resource tools and `ReadMcpResourceTool` to `read_mcp_resource`. It also accepts the three pi-native resource names and scoped `list_mcp_*`/`read_mcp_*` patterns in parent and persona configuration; those spellings are pi-only. Pi otherwise retains these registrations callable through codemode/deferred exposure even when inactive. Parents without `tools:` keep default behavior. Parents whose translated tools are empty use `--tools ''`; both parent and child selections exclude unselected extension tools | |
There was a problem hiding this comment.
1. Pi runtime guide still says empty tool lists use the old flag 📘 Rule violation ⚙ Maintainability
docs/runtimes/pi.md still says buildPiRunCommand uses --no-builtin-tools for parents whose tools map to an empty list, although the launch branch now emits --tools ''. When debugging an explicit empty selection, readers would look for the wrong flag and expect extension tools to load, contradicting the updated guidance in docs/contributing/runtime-implementation.md.
Agent Prompt
## Issue description
The Pi runtime guide describes the old flag for an explicit empty parent tool selection. The launch now uses `--tools ''`, which excludes both built-in and extension tools.
## Fix Focus Areas
- docs/runtimes/pi.md[452-454]
- internal/runtime/pi_run.go[723-732]
## Recommended Fix
Replace the `--no-builtin-tools` reference in the Pi runtime guide with `--tools ''` and state that an explicit empty parent selection excludes both built-in and extension tools, matching the updated wording in `docs/contributing/runtime-implementation.md`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| test("real Pi refuses missing, ambiguous and non-vetted selections before inference", { skip: !realPi }, async () => { | ||
| for (const config of [{ missing: true }, { duplicate: true }, { wrongOrigin: true }]) { |
There was a problem hiding this comment.
3. Missing-tool failure is only tested behind an env-gated pi binary 📎 Requirement gap ⚙ Maintainability
The Go tests (TestPiExactNativeTools, TestPiToolSelectorBootstrap) only check name syntax and
manifest contents, so nothing in a normal go test run shows that a missing or ambiguous native
name stops the run before inference. That behaviour lives in the JS selector selectTools, which
throws when registry has zero or two matches, and it is exercised only by `real Pi refuses
missing, ambiguous and non-vetted selections before inference. That test is wrapped in { skip:
!realPi }, so it is skipped unless FULLSEND_TEST_PI_BIN` is set. The same gating applies to the
real-Pi tests for the selected-tool, hook-denial and empty-selection boundaries.
Agent Prompt
## Issue description
The proof that a missing or ambiguous native tool name fails before inference is only in `real Pi refuses missing, ambiguous and non-vetted selections before inference` in `internal/runtime/pi_extension/fullsend-tools.test.mjs`. That test is skipped unless `FULLSEND_TEST_PI_BIN` is set, and the Go tests do not reach the selector's missing-name path. Rule 4444014 requires this to run in normal runtime tests.
## Fix Focus Areas
- internal/runtime/pi_extension/fullsend-tools.test.mjs[105-113]
- internal/runtime/pi_extension/fullsend-tools.js[24-40]
- internal/runtime/pi_tool_selection_test.go[19-28]
## Recommended Fix
Add a Go-level or non-gated JS test that calls `selectTools` with an empty registry and with duplicate registrations, and asserts that it throws before any model call. Keep the real-Pi variant as the pinned-binary acceptance check. Alternatively, make the Go test harness run the real-Pi test in CI and state that gate in the migration documentation.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if !piNativeToolName(ct) { | ||
| unsupported = append(unsupported, ct) | ||
| continue | ||
| } | ||
| pt = ct |
There was a problem hiding this comment.
4. Personas silently lose tools no extension provides 🐞 Bug ≡ Correctness
piToolsFor now treats exact native names such as WebFetch as supported without verifying that a vetted extension supplies them, so piPersonaTools and piPersonaRegistrable register personas they previously refused. When such a persona dispatches, child selection intersects its requested names with the parent’s callable tools and checks only the result, silently dropping a missing name or launching with --tools '' if none remain, while the troubleshooting row in docs/runtimes/pi.md still says missing selections fail.
Agent Prompt
## Issue description
Exact native tool names in persona `tools:` now pass registration even when no loaded, vetted extension supplies them. Dispatch can silently drop the missing name from the child’s selection or launch the child with an empty tool list instead of reporting the missing tool.
## Fix Focus Areas
- internal/runtime/pi_agent.go[314-319]
- internal/runtime/pi_personas.go[344-361]
- internal/runtime/pi_personas.go[454-481]
- internal/runtime/pi_extension/fullsend-agent.js[454-478]
- internal/runtime/pi_extension/fullsend-agent.js[531-540]
- internal/runtime/pi_extension/fullsend-tools.js[83-99]
- docs/runtimes/pi.md[823-823]
## Recommended Fix
Record each persona’s requested native names in its manifest entry and, before child inference, validate them against the loaded, vetted extension registry and the parent’s callable tools. Return a clear missing-tool error for a declared native name with no verified implementation, without treating an intentionally empty parent/persona permission intersection as a missing implementation. Alternatively, continue refusing Claude-only names in personas until this validation exists. Update the troubleshooting row in `pi.md` to match the resulting behavior.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| ) | ||
|
|
||
| const piToolSelectionExtensionFile = "fullsend-tools.js" | ||
| const piToolSelectionExit = 92 |
There was a problem hiding this comment.
2. Gateway tampering is misreported as a tool-selection failure 🐞 Bug ◔ Observability
piToolSelectionExit and piGatewayConfigTamperedExit both equal 92, and piExecModel checks the tool-selection branch first when m.Tools != nil. If a gateway run declares tools:, a rewritten inference-gateway.json or local overlay reaches that branch and produces a selector diagnosis rather than the gateway-specific diagnostic, directing the operator to the wrong file.
Agent Prompt
## Issue description
The tool selector and gateway-configuration integrity guard both use exit code 92. When a gateway run declares explicit tools, the selector branch consumes a gateway integrity failure before the gateway diagnostic can run.
## Fix Focus Areas
- internal/runtime/pi_tool_selection.go[10-17]
- internal/runtime/pi_extension/fullsend-tools.js[8-8]
- internal/runtime/pi_run.go[1133-1134]
## Recommended Fix
Assign the tool selector an exit code unused by other runtime guards, update both the Go constant and `SELECTION_EXIT` in fullsend-tools.js, and update any tests that assert 92 for selector failures. Add a test for a gateway-integrity failure on a run with explicit tools to verify that it receives the gateway diagnostic.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| const bytes = readFileSync(process.env.FULLSEND_PI_MANIFEST || "/sandbox/pi-config/fullsend-manifest.json"); | ||
| const want = process.env.FULLSEND_PI_MANIFEST_SHA256; | ||
| if (!want || createHash("sha256").update(bytes).digest("hex") !== want) throw new Error("manifest integrity missing or changed"); | ||
| manifest = JSON.parse(bytes); |
There was a problem hiding this comment.
5. Runs that declare tools fail without a recorded manifest digest 🐞 Bug ☼ Reliability
The selector exits 92 whenever FULLSEND_PI_MANIFEST_SHA256 is unset, but buildPiRunCommand exports that variable only when manifestSum is non-empty, i.e. only when Bootstrap ran in the same process. Any caller that bootstraps in one process and runs in another now fails every pi run with a declared tools: list before inference. The existing seam was designed to allow that case: its comment says failing closed there would break such callers.
Agent Prompt
## Issue description
fullsend-tools.js requires FULLSEND_PI_MANIFEST_SHA256, but Run exports it only when Bootstrap recorded a digest in the same process. Without it, every run that declares `tools:` exits 92.
## Fix Focus Areas
- internal/runtime/pi_extension/fullsend-tools.js[71-82]
- internal/runtime/pi_run.go[485-487]
- internal/runtime/pi_run.go[643-645]
## Recommended Fix
Pick one behaviour and make it explicit: either have Run fail with a clear guardErr when m.Tools != nil and manifestSum is empty, or let the selector fall back to reading the manifest without a digest when the env var is absent (as the hook adapter does). Document which one you chose.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit cc928ba |
waynesun09
left a comment
There was a problem hiding this comment.
HIGH: Required test check fails: the real-Pi MCP launch test does not stage the new tool selector (internal/runtime/pi_frontmatter_mcp_test.go around line 56; the file is not in this diff, so this note is here instead of inline)
The required test check fails at head cc928ba (run 45142513710, job 137583718330). All three subtests of TestPiBootstrap_DirectMCPRealPi fail (pattern, bare-parent, bare-persona). The errors are Error: Unknown option: --fullsend-selected-tools and Failed to load extension "/sandbox/pi-config/fullsend-tools.js": Extension path does not exist.
Bootstrap now always writes toolSelector into the child manifest, and both buildPiRunCommand and childArgs add -e /sandbox/pi-config/fullsend-tools.js. This PR does not change pi_frontmatter_mcp_test.go or testdata/pi-direct-mcp.mjs, and neither mentions fullsend-tools.js or FULLSEND_PI_MANIFEST_SHA256. So the child cannot load the selector, and pi rejects the unregistered flag. The local go test ./internal/runtime run in the PR body skipped this test because FULLSEND_TEST_PI_BIN was unset. CI sets that variable.
Suggestion: In testPiDirectMCP and testdata/pi-direct-mcp.mjs, stage fullsend-tools.js the same way as the other runner-owned extensions, or rewrite the toolSelector path. Export FULLSEND_PI_MANIFEST and FULLSEND_PI_MANIFEST_SHA256 for the child. Rerun with FULLSEND_TEST_PI_BIN set to pinned pi 1.6.0, and correct the Validation section of the PR body.
Verified: required check fails: test (TestPiBootstrap_DirectMCPRealPi, log grep); test files unchanged in diff at cc928ba; raised by: Claude
| // DeclaredExtensions are the vetted harness plugins inherited by children. | ||
| // The dispatcher rechecks their tree hashes before every child launch. | ||
| DeclaredExtensions []piManifestExtension `json:"declaredExtensions,omitempty"` | ||
| ToolSelector string `json:"toolSelector,omitempty"` |
There was a problem hiding this comment.
MEDIUM: New manifest fields toolSelector, strictTools and nativeTools are not documented
The PR adds agent.toolSelector, plus strictTools and nativeTools at the top level, to the digest-covered Pi manifest. None of these names appear anywhere under docs/. The manifest field table in docs/contributing/runtime-implementation.md (around lines 1136-1145) lists the other security inputs, such as declaredExtensions, extensionDigests and mcpResourceTools, but not these. toolSelector decides which selector children load. nativeTools decides which names get the vetted-origin check. The tools row in that table still says pi keeps inactive registrations callable through codemode/deferred exposure. That is no longer true for strict-selection runs, because the new tool_call handler blocks them.
Suggestion: Add table rows for toolSelector, strictTools and nativeTools that say what each one controls, and update the tools row for the strict-selection tool_call block.
Verified: read code at head; grep docs/ for the field names returned nothing at cc928ba; raised by: DeepSeek
Summary
An agent can load a vetted Pi extension but lose its native tool names during translation. This implements exact native selection so
tools: [inspect_record]exposes that tool while excluding sibling tools and built-in shell/edit tools. Missing, hidden, ambiguous or non-vetted native selections fail before inference. Explicit empty selections exclude extension tools too.This replaces the ADR-only proposal with runtime code, tests and migration documentation. Adapted from the existing fork implementation, limited to Pi tool selection; journal and tracker changes are excluded. The original ADR additions and their links are removed from the final PR diff.
Closes #9254.
Implementation
The implementation is forge-neutral and applies on GitHub, GitLab and Forgejo.
Breaking change and migration
BREAKING CHANGE: previously ignored unknown Pi tool names now request exact native extension tools, and invalid native patterns fail setup. Remove stale Claude-only names or declare a vetted extension that supplies each exact requested name. An explicit empty selection now excludes extension tools as well as built-ins. The existing runner behavior of adding
readfor skills remains documented.Validation
go test ./internal/runtime -count=1 -coverprofile=...: passes; package coverage 94.4%.FULLSEND_TEST_PI_BINset to pinned Pi 1.6.0 andnode --test --test-concurrency=1 internal/runtime/pi_extension/*.test.mjs.make lint; all applicable checks pass, including security scans, Go vet and Markdown links.git diff --checkpasses.Prepared with coding-agent assistance. Human-directed commits carry DCO sign-off.