feat: enforce cwd and track PIDs in subAgent process delegation#456
Merged
Conversation
- Add src/tools/scanAgents.js with implementation, tool definition, and factory - Register tool in src/tools/index.js (TOOL_PERMISSIONS, TOOL_FACTORIES, switch case) - Add unit tests in tests/unit/tools_scanAgents.test.js - Update tool_index.test.js to account for new tool registration - Archive OpenSpec change as 2026-06-26-scan-agents-tool - Create spec in openspec/specs/scan-agents/spec.md
Owner
Author
Audit Results — scanAgents Tool (Implementation)Audit 1: Implementation Against Specs & GoalsGoal Fulfillment
Spec Compliance
Task Completion
Quality Check
ResultNo errors found. Implementation is complete and correct. |
33da5c6 to
87ed201
Compare
- Create src/workspace/loadAgents.js to read AGENTS.md from any directory - Update scanAgents tool to delegate to loadAgents with validated path - Wire loadAgents into index.js session init to append AGENTS.md to system prompt - Remove scanAgents reference from SYSTEM_PROMPT.md
- Add cwd: '' to config.yaml and schema - Set config.cwd = process.cwd() in loader before any chdir - Import config loader first in index.js, before all other ./src imports - Replace all process.cwd() calls in ./src with config.cwd - Document CLI arguments in README
- Add subAgent option to buildToolConfig to exclude subAgent tools - Skip subAgent, subAgentLog, and subAgentMessage when subAgent=true - Fix pre-existing bug: subAgentMessage missing from TOOL_PERMISSIONS - Pass config.subAgent from index.js to buildToolConfig - Add tests for subAgent tool exclusion behavior
…tradictions, and unnecessary sections
Sub-agents running in target project directories (e.g., ../tiny-lru) were trying to navigate back to madz. Added explicit WORKING DIRECTORY section to prevent this behavior.
Sub-agents running in target directories (e.g., ../tiny-lru) were denied file access because the cwd wasn't in the sandbox scope. Now config.cwd is pushed into sandbox.paths at load time.
Only push config.cwd into sandbox.paths when running as a sub-agent, preventing unnecessary path pollution for normal app runs.
…l change - Add 'What Actually Happened' sections to design.md and proposal.md - Document the expanded scope beyond original scanAgents tool proposal - Add scope delta table comparing original vs actual implementation - Update .openspec.yaml with name, archived, and archivedDate fields - Fill in Purpose sections for scan-agents and subagent specs - Capture lessons learned about scope creep and architectural evolution
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.
Description
This branch introduces comprehensive subAgent process management: enforcing explicit cwd for delegation, tracking OS-level PIDs in process results, and adding the loadAgents workspace function for AGENTS.md discovery. It also creates and refines the SUB_AGENT.md prompt for one-shot skill execution, adds the --sub-agent CLI flag, and excludes subAgent tools from sub-agent processes to prevent recursion.
Type of Change
Testing
Unit tests for scanAgents tool, subAgent cwd handling, skills module cwd override, sandbox runner, discoverer, and tool registration. Full test suite runs with no failures.
Coverage
Checklist
npm run lintpasses