Skip to content

fix(tools): stop overriding settings.json defaultTools on new sessions (#700) - #936

Merged
agegr merged 1 commit into
mainfrom
claude/charming-goldberg-reeqnp
Sep 22, 2026
Merged

agegr merged 1 commit into
mainfrom
claude/charming-goldberg-reeqnp

Conversation

@agegr

@agegr agegr commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Fixes #700.

The problem

Pi Web sent an explicit toolNames array on every session it created — hooks/useAgentSession.ts resolved getToolNamesForPreset(toolPreset) where toolPreset defaulted to "default" even for users who had never opened the tool picker. The server then persisted a pi-web:tool-selection entry, 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 pi CLI, but only read, bash, edit, write from 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 the defaultTools override remained.

The fix

Add a configured preset that stands for "send no override", shown first in the picker:

Tools: [configured ▼]
  ✓ configured    From settings.json defaultTools
    chat-only     Chat only
    read-only     4 read-only built-in tools
    default       4 built-in tools
    full          All built-in tools

Picking it omits toolNames entirely. The server already handled that: startRpcSession leaves the allow-list unset and falls back to the SDK's resolved active tools, and writes no pi-web:tool-selection entry, 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: readSessionToolSelection treats 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 loadout defaultTools resolves 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 defaultTools as 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 cleared entry skips it as invalid and falls through to the previous pin. Only relevant when rolling back.

Also

  • The picker labels an unpinned session configured rather than borrowing whichever concrete preset its resolved tools happen to match — tracked with sessionToolsPinnedRef, sourced from whether the session carries a selection of its own.
  • getPresetFromTools / getPresetFromToolNames now return ConcreteToolPreset, so no tool set can ever map back to configured.

Testing

npx tsc --noEmit, npm run lint, npm test (1246 passed, 0 failed) and npm run build all pass.

New coverage: configured maps to undefined; the reverse mapping never yields configured; cleared retracts a pin and a later pin wins again (only exact cleared: true at version 1 counts); session creation omits toolNames; an unpinned session's label does not borrow a concrete preset.

One thing worth checking before merge

For users with no defaultTools configured at all, configured resolves 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 inspecting get_tools — getDefaultTools() returns string[] | undefined and 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

#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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-22T13:26:29.065116Z 115d5ec PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@agegr
agegr merged commit 03a9f5d into main Sep 22, 2026
2 checks passed
@agegr
agegr deleted the claude/charming-goldberg-reeqnp branch October 1, 2026 13:28
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]>
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.

Expose the existing tool preset selector in the UI and honor settings.json defaultTools

2 participants