Repository navigation
fix(tools): stop overriding settings.json defaultTools on new sessions (#700) - #936
Merged
Merged
Conversation
#700) Pi Web sent an explicit toolNames array on every session it created, so a new session was always pinned to the hardcoded "default" preset (read, bash, edit, write) even for users who had never opened the tool picker. That silently narrowed the loadout configured in ~/.pi/agent/settings.json and made Pi Web disagree with the `pi` CLI over the same agent directory. Add a "configured" preset that stands for "send no override". Picking it omits toolNames entirely, which the server already handles: startRpcSession leaves the allow-list unset and falls back to the SDK's resolved active tools, and no pi-web:tool-selection entry is written, so the session keeps following the setting. It is also the fallback when no preference is stored, since only an explicit pick from the dropdown is ever persisted - so "never chose" no longer means "pinned to our four built-ins". Returning an already pinned session to the configured defaults needs a way to retract the pin, and the session log is append-only. Add a `cleared: true` tool-selection entry for that; readSessionToolSelection treats it as "no selection" while a later pin still wins. Clearing rebuilds the session, because the loadout defaultTools resolves to is only known once pi builds it. The picker labels an unpinned session "configured" rather than borrowing whichever concrete preset its resolved tools happen to match, so the reverse mapping is now typed to the concrete presets only. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017hwqrw5gysXzj7axehH9ng
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
agegr#700) (agegr#936) Pi Web sent an explicit toolNames array on every session it created, so a new session was always pinned to the hardcoded "default" preset (read, bash, edit, write) even for users who had never opened the tool picker. That silently narrowed the loadout configured in ~/.pi/agent/settings.json and made Pi Web disagree with the `pi` CLI over the same agent directory. Add a "configured" preset that stands for "send no override". Picking it omits toolNames entirely, which the server already handles: startRpcSession leaves the allow-list unset and falls back to the SDK's resolved active tools, and no pi-web:tool-selection entry is written, so the session keeps following the setting. It is also the fallback when no preference is stored, since only an explicit pick from the dropdown is ever persisted - so "never chose" no longer means "pinned to our four built-ins". Returning an already pinned session to the configured defaults needs a way to retract the pin, and the session log is append-only. Add a `cleared: true` tool-selection entry for that; readSessionToolSelection treats it as "no selection" while a later pin still wins. Clearing rebuilds the session, because the loadout defaultTools resolves to is only known once pi builds it. The picker labels an unpinned session "configured" rather than borrowing whichever concrete preset its resolved tools happen to match, so the reverse mapping is now typed to the concrete presets only. Claude-Session: https://claude.ai/code/session_017hwqrw5gysXzj7axehH9ng Co-authored-by: Claude <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
agegr#700) (agegr#936) Pi Web sent an explicit toolNames array on every session it created, so a new session was always pinned to the hardcoded "default" preset (read, bash, edit, write) even for users who had never opened the tool picker. That silently narrowed the loadout configured in ~/.pi/agent/settings.json and made Pi Web disagree with the `pi` CLI over the same agent directory. Add a "configured" preset that stands for "send no override". Picking it omits toolNames entirely, which the server already handles: startRpcSession leaves the allow-list unset and falls back to the SDK's resolved active tools, and no pi-web:tool-selection entry is written, so the session keeps following the setting. It is also the fallback when no preference is stored, since only an explicit pick from the dropdown is ever persisted - so "never chose" no longer means "pinned to our four built-ins". Returning an already pinned session to the configured defaults needs a way to retract the pin, and the session log is append-only. Add a `cleared: true` tool-selection entry for that; readSessionToolSelection treats it as "no selection" while a later pin still wins. Clearing rebuilds the session, because the loadout defaultTools resolves to is only known once pi builds it. The picker labels an unpinned session "configured" rather than borrowing whichever concrete preset its resolved tools happen to match, so the reverse mapping is now typed to the concrete presets only. Claude-Session: https://claude.ai/code/session_017hwqrw5gysXzj7axehH9ng Co-authored-by: Claude <[email protected]>
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.
Fixes #700.
The problem
Pi Web sent an explicit
toolNamesarray on every session it created —hooks/useAgentSession.tsresolvedgetToolNamesForPreset(toolPreset)wheretoolPresetdefaulted to"default"even for users who had never opened the tool picker. The server then persisted api-web:tool-selectionentry, pinning the session permanently.So a user with this in
~/.pi/agent/settings.json:{ "defaultTools": ["read", "write", "edit", "bash", "grep", "find", "ls"] }got all seven tools from the
piCLI, but onlyread, bash, edit, writefrom Pi Web over the same agent directory.The other half of #700 — "there is no discoverable tool preset selector" — was already fixed since 0.8.11; the dropdown lives in
components/ChatInput.tsx. Only thedefaultToolsoverride remained.The fix
Add a
configuredpreset that stands for "send no override", shown first in the picker:Picking it omits
toolNamesentirely. The server already handled that:startRpcSessionleaves the allow-list unset and falls back to the SDK's resolved active tools, and writes nopi-web:tool-selectionentry, so the session keeps following the setting.It is also the fallback when no preference is stored. Only an explicit pick from the dropdown is ever written to
localStorage, so "no stored value" precisely means "never chose" — those users stop being silently pinned to our four built-ins. Anyone who had already picked a preset keeps it.Retracting a pin
Returning an already pinned session to the configured defaults needs a way to undo the pin, and the session log is append-only. This adds a
{ version: 1, cleared: true }tool-selection entry:readSessionToolSelectiontreats it as "no selection", while a later pin still wins by the existing newest-entry-wins rule.Clearing rebuilds the session (
recreated: true, which the client already handles) because the loadoutdefaultToolsresolves to is only known once pi builds the session — the server cannot guess it.This deviates from the smaller snapshot approach considered first (apply the resolved
defaultToolsas an explicit pin). That would have produced a dropdown item that unchecks itself the moment you click it: the session becomes pinned, so the label jumps to whichever concrete preset the tools match. ~10 extra lines buys a stable label and a session that genuinely keeps following the setting.Downgrade note: an older Pi Web reading a
clearedentry skips it as invalid and falls through to the previous pin. Only relevant when rolling back.Also
configuredrather than borrowing whichever concrete preset its resolved tools happen to match — tracked withsessionToolsPinnedRef, sourced from whether the session carries a selection of its own.getPresetFromTools/getPresetFromToolNamesnow returnConcreteToolPreset, so no tool set can ever map back toconfigured.Testing
npx tsc --noEmit,npm run lint,npm test(1246 passed, 0 failed) andnpm run buildall pass.New coverage:
configuredmaps toundefined; the reverse mapping never yieldsconfigured;clearedretracts a pin and a later pin wins again (only exactcleared: trueat version 1 counts); session creation omitstoolNames; an unpinned session's label does not borrow a concrete preset.One thing worth checking before merge
For users with no
defaultToolsconfigured at all,configuredresolves to the SDK's own default, which may or may not equal the four built-ins Pi Web used to hardcode. That is exactly the CLI/Web consistency #700 asks for, but it is a behavior change for those users, and it can only be confirmed by running a real session and inspectingget_tools—getDefaultTools()returnsstring[] | undefinedand the SDK decides when it is undefined. If the values differ, the issue's "clarify what Default means" discussion may deserve a follow-up on wording.🤖 Generated with Claude Code
https://claude.ai/code/session_017hwqrw5gysXzj7axehH9ng
Generated by Claude Code