Repository navigation
fix(pi): subagent processes follow the parent's mode and PONYTAIL_SUBAGENT_MATCHER - #1534
Open
marcioazam wants to merge 1 commit into
Open
marcioazam wants to merge 1 commit into
marcioazam wants to merge 1 commit into
Conversation
…AGENT_MATCHER A child pi process started by pi-code's subagent tool read the saved default mode instead of the parent's session mode, so `/ponytail off` (or `lite`) in the parent did not reach it, and PONYTAIL_SUBAGENT_MATCHER only applied to the Claude Code SubagentStart hook. The extension now exports the current mode as PONYTAIL_PARENT_MODE. A child (PI_CODE_SUBAGENT=1) starts in that mode and turns it off when PONYTAIL_SUBAGENT_MATCHER is set and does not match the agent name read from the `--system-prompt .../prompt-<name>.md` argument. Same semantics as the hook: unanchored, case-insensitive, fail open on a bad regex, an unknown name or a matcher that times out (100 ms vm timeout, DietrichGebert#658). The child mode is never persisted.
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 #1533
A child
piprocess started by pi-code'ssubagenttool read the saved default mode instead of the parent's session mode, so/ponytail off(orlite) in the parent did not reach it, andPONYTAIL_SUBAGENT_MATCHERonly applied to the Claude Code SubagentStart hook.What changes (
pi-extension/index.js):PONYTAIL_PARENT_MODE(on/ponytail <mode>and onsession_start).PI_CODE_SUBAGENT=1) starts in that mode. IfPONYTAIL_SUBAGENT_MATCHERis set and does not match the agent name (parsed from--system-prompt .../prompt-<name>.md), it startsoff.hooks/ponytail-subagent.js: unanchored, case-insensitive, fail open on a bad regex, an unknown name, or a timeout (same 100 msvmtimeout, PONYTAIL_SUBAGENT_MATCHER compiled into RegExp without validation (crash on invalid pattern + ReDoS) #658).appendEntry.This is an extension fix only: no change to
skills/,AGENTS.mdor any rule copy, so no benchmark applies (CONTRIBUTING, "Everything else").Tests: new
pi-extension/test/subagent.test.js(name parsing, parent-mode inheritance, matcher, fail-open incl. a catastrophic-backtracking regex, childsession_startneither injects nor persists);extension.test.jsclears the subagent env vars so a run inside a pi subagent does not change its result.Not verified: behavior inside a real pi-code subagent run (covered by unit tests with the same argv/env shape only).