fix(pi-bash-bg): stop replacing the bash tool so shellCommandPrefix keeps working#43
Open
mgabor3141 wants to merge 1 commit intomainfrom
Open
fix(pi-bash-bg): stop replacing the bash tool so shellCommandPrefix keeps working#43mgabor3141 wants to merge 1 commit intomainfrom
mgabor3141 wants to merge 1 commit intomainfrom
Conversation
…working createBashTool(process.cwd()) + pi.registerTool(...) was used to append a background-job note to the tool description, but the freshly-constructed bash tool shadowed pi's built-in one in the registry, silently dropping the shellCommandPrefix, shellPath, and spawnHook that pi wires onto the built-in tool. Any user with "shellCommandPrefix": "..." in settings saw their prefix stop running as soon as pi-bash-bg was loaded. Move the guidance into the system prompt via before_agent_start so the built-in bash tool is left untouched. Add a changeset.
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.
Problem
Since 0.1.0,
pi-bash-bgcallscreateBashTool(process.cwd())andpi.registerTool(...)to append a background-job note to the bash tool description:The freshly-constructed
bashToolis created without thecommandPrefix,shellPath, orspawnHookoptions pi wires onto its built-inbashtool. In pi's_refreshToolRegistry, extension-registered tools win over built-in ones with the same name, so that replacement silently drops those options.Concretely, any user with something like this in
~/.pi/agent/settings.json:{ "shellCommandPrefix": "export PI_ROOT=..." }sees their prefix stop running as soon as
pi-bash-bgis loaded. Same forshellPath. I hit this while settingPI_ROOTfor agent bash sessions and traced it throughgetShellCommandPrefix->createAllToolDefinitions({ bash: { commandPrefix } })-> the registry override above.Fix
Move the background-job guidance into the system prompt via a
before_agent_starthook (same mechanism the extension already uses for other prompt tweaks), and stop registering a replacement bash tool. Pi's built-inbashstays put, soshellCommandPrefix,shellPath, and anyspawnHookkeep working.The guidance section injected into the system prompt:
It's exported as
BASH_BG_SYSTEM_PROMPT_SECTIONand the handler no-ops if it's already present, so repeatedbefore_agent_startevents don't duplicate it.Verification
yarn test --run packages/bash-bg: 76/76 pass (new test covers that no tool is registered, handlers are wired up, and the system prompt is augmented once).yarn lint: clean.shellCommandPrefixset,env | grep ^PI_ROOTin agent bash now returns the expected value; before the fix it was empty.Changeset
Included as a patch bump on
pi-bash-bg.