Skip to content

fix(agents): honor GENTLE_PI_AGENT_HOME for the child's web package lookup - #2516

Closed
aiorellana502 wants to merge 1 commit into
Gentleman-Programming:mainfrom
aiorellana502:fix/web-tool-package-agent-home
Closed

aiorellana502 wants to merge 1 commit into
Gentleman-Programming:mainfrom
aiorellana502:fix/web-tool-package-agent-home

Conversation

@aiorellana502

@aiorellana502 aiorellana502 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Context

While investigating the profileRoot()/agent-home divergence hypothesis raised in #2163 (the idea that a resolver mirroring resolveGentlePiAgentHome()'s inline fallback diverges from it), I traced every production caller of DiscoveryRoots.agentHome (extensions/gentle-ai.ts:4520, extensions/gentle-agents.ts:520 via resolveAgentHomeDirectory). That hypothesis does not reproduce on current main: every real caller already resolves agentHome through the single resolution point gentle-shell#1731 introduced (resolveGentlePiAgentHome / resolveAgentHomeDirectory in lib/agent-home.ts and lib/agent-model-resolution.ts). profileRoot()'s own inline fallback is only reached by tests that intentionally omit agentHome.

While tracing that, I found a smaller, real instance of the same divergence class elsewhere: requestedWebPackagePaths() in lib/agents-runner.ts, used to locate the installed npm:pi-web-access package for a subagent's web tools (fetch_content, web_search, etc.), read only request.env.PI_CODING_AGENT_DIR. resolveGentlePiAgentHome() checks GENTLE_PI_AGENT_HOME first, falling back to PI_CODING_AGENT_DIR. A session with only GENTLE_PI_AGENT_HOME set (no PI_CODING_AGENT_DIR) would have this lookup silently fall back to the wrong default home directory and fail to find an already-installed web package, degrading the child's declared capability with no error.

Fix

lib/agents-runner.ts: check GENTLE_PI_AGENT_HOME ahead of PI_CODING_AGENT_DIR, matching resolveGentlePiAgentHome()'s precedence, while keeping the existing tilde/HOME-override expansion this function already does for its own tests.

Tests

tests/child-web-package.test.ts: new test web lookup honors GENTLE_PI_AGENT_HOME ahead of PI_CODING_AGENT_DIR, covering both GENTLE_PI_AGENT_HOME set alone and set alongside PI_CODING_AGENT_DIR (precedence). RED without the fix, GREEN with it.

Verification

  • node --experimental-strip-types --test tests/child-web-package.test.ts: 11/11 pass.
  • node --experimental-strip-types --test tests/agents-runner.test.ts: 99/100 pass; the one failure (AgentRunner retains permission broker fd3 and assigns messaging IPC to fd4, a Windows TEMP/TMP-vs-TMPDIR env assumption) reproduces identically on a clean main checkout with zero source changes — pre-existing, unrelated to this change.
  • node scripts/check-types.mjs: 0 diagnostics.

Does not close #2163 (that issue's actual root cause, the global/legacy models.json merge, is #2477). Posting a clarifying comment on #2163 pointing here and to the closed profileRoot() hypothesis.

Summary by CodeRabbit

  • Bug Fixes
    • Web-package lookup now prioritizes the Gentle Pi home setting when both agent directory settings are configured. Existing fallback behavior remains unchanged.

…ookup

requestedWebPackagePaths() only read PI_CODING_AGENT_DIR when locating
the installed npm:pi-web-access package for a subagent's web tools,
ignoring GENTLE_PI_AGENT_HOME. resolveGentlePiAgentHome() (lib/agent-home.ts),
the single resolution point gentle-shell#1731 introduced so routing and
launch never disagree on the agent home, checks GENTLE_PI_AGENT_HOME first.
A session with only GENTLE_PI_AGENT_HOME set would have its web-tool
package lookup silently fall back to the wrong default directory.

Found while investigating gentle-shell#2163; the issue's own
profileRoot()/agentHome divergence hypothesis was checked and does not
reproduce in current main (every production DiscoveryRoots.agentHome
caller already resolves through resolveAgentHomeDirectory /
resolveGentlePiAgentHome).
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ca9b06fe-198f-4ea7-b408-b364a835fdd2
Commits

Reviewing files that changed from the base of the PR and between 51b766d and 98dc2b1.

Files selected for processing: 2
  • lib/agents-runner.ts
  • tests/child-web-package.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

Web-package lookup now uses GENTLE_PI_AGENT_HOME before PI_CODING_AGENT_DIR. Tests cover lookup when the preferred variable is set alone and when both variables are set.

Changes: Web package lookup

Layer / File(s) Summary
Agent home precedence
lib/agents-runner.ts, tests/child-web-package.test.ts
Lookup prefers GENTLE_PI_AGENT_HOME and falls back to PI_CODING_AGENT_DIR. Tests verify the preferred home is used when set alone or alongside the fallback.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Suggested labels: type:bug

Suggested reviewers: decode2, alan-thegentleman

Merge Risk: Minimal · up to 98dc2

No actionable merge-blocking risk is identified.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #2163 is open and directly linked, so its coding requirements apply. Its expected outcome requires either a one-time migration of legacy panel store files (profiles.json, models.json, routing), … Implement the #2163 behavior in this PR: a one-time migration of legacy panel store files, or a warning that names the unmigrated legacy files in at least one of the listed surfaces (setup, panel open, sync, doctor). Add automated tests for…
Out of Scope Changes check Warning The code change does not implement any objective of #2163. The change alters the environment variable precedence in requestedWebPackagePaths(), which locates the installed npm:pi-web-access package fo… Move the requestedWebPackagePaths() precedence fix and its test to a separate PR. Link that PR to an issue that tracks the web-package lookup defect. Alternatively, link this PR to an issue that describes the web-package lookup problem, so …
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: prioritizing GENTLE_PI_AGENT_HOME for the child's web package lookup.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Full details: Linked Issues check

Explanation

Issue #2163 is open and directly linked, so its coding requirements apply. Its expected outcome requires either a one-time migration of legacy panel store files (profiles.json, models.json, routing), or a warning that names the unmigrated legacy files during setup, on first panel open, or through sync/doctor. The PR diff does not implement either. The only source change is a one-line edit in requestedWebPackagePaths() in lib/agents-runner.ts (GENTLE_PI_AGENT_HOME checked before PI_CODING_AGENT_DIR). The only test added is in tests/child-web-package.test.ts, and it covers web-package lookup. The PR description and the PR objectives both state that this PR does not close #2163. The concrete unmet requirement is the missing migration or warning behavior for legacy panel store files. The review-lane failure described in #2163 also remains unaddressed. Tests were not re-run in this assessment. The author-reported results were not independently verified.

Resolution

Implement the #2163 behavior in this PR: a one-time migration of legacy panel store files, or a warning that names the unmigrated legacy files in at least one of the listed surfaces (setup, panel open, sync, doctor). Add automated tests for that behavior. Alternatively, if this PR must not address #2163, change the #2163 link to a contextual mention so no coding requirements apply to this PR.

Full details: Out of Scope Changes check

Explanation

The code change does not implement any objective of #2163. The change alters the environment variable precedence in requestedWebPackagePaths(), which locates the installed npm:pi-web-access package for subagent web tools. #2163 concerns legacy panel store files and their migration or warning. No code path in the diff links the two. The PR description and the PR objectives also state that the PR addresses web-package lookup, not panel-store migration. The change is a separate fix for a different defect. Because the PR's only code change is unrelated to its linked issue, the change is out of scope for #2163.

Resolution

Move the requestedWebPackagePaths() precedence fix and its test to a separate PR. Link that PR to an issue that tracks the web-package lookup defect. Alternatively, link this PR to an issue that describes the web-package lookup problem, so the change has a matching requirement. Keep #2163 linked only if this PR also implements the #2163 migration or warning behavior.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@decode2

decode2 commented Oct 26, 2026

Copy link
Copy Markdown
Member

Thanks @aiorellana502 for investigating and for the honest follow-up that the original hypothesis did not reproduce.

We are closing this one because the replacement precedence can regress the real install path. Pi resolves its agent directory solely from PI_CODING_AGENT_DIR and installs pi-web-access there; the launcher sets both variables to the same directory, so in every real launch the flip is a no-op. The one place the two genuinely diverge is scripts/test-packed-runner.mjs, which deliberately points GENTLE_PI_AGENT_HOME at assets rather than at Pi's package home; under this change the child would look for the web package in a directory Pi never wrote to.

The test in the branch asserts that fabricated layout rather than anything an installer produces. If a real case ever shows up where the two variables differ in a production launch, an issue with that repro is the right way back.

@decode2

decode2 commented Oct 26, 2026

Copy link
Copy Markdown
Member

Closing for regression risk; see comment above.

@decode2 decode2 closed this Oct 26, 2026
@aiorellana502
aiorellana502 deleted the fix/web-tool-package-agent-home branch October 27, 2026 22:01
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.

bug(bundled upgrade): panel store not migrated, review lane refuses with reviewer-config-invalid until manual move

2 participants