Repository navigation
fix(prompt): skip duplicate gentle-ai orchestration blocks from ancestor AGENTS.md (#1722) - #1769
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughPrimary sessions now filter system-prompt context files before prompt construction. The filter removes all managed blocks from ancestor context files and orchestrator-only blocks from project-local files. Empty ancestor files are omitted. Named-agent and child sessions skip this filtering. ChangesPrimary-session context filtering
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant gentleAiExtension
participant filterSessionContextFiles
participant systemPromptOptions
participant promptConstruction
gentleAiExtension->>filterSessionContextFiles: Pass context options and session working directory
filterSessionContextFiles->>systemPromptOptions: Remove selected managed blocks and omit empty ancestor files
gentleAiExtension->>promptConstruction: Build prompt with filtered context options
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The identified comments do not require changes before merge; normal checks remain appropriate. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 4 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1722
Problem
When a
~/AGENTS.md(or any ancestorAGENTS.md) written bygentle-aiexists, agentle-shellsession started in any project under$HOMEloads the orchestration rules twice:gentle-shell's own injected harness (appendSystemPromptinextensions/gentle-ai.tscontaining## el Gentleman Identity and Harnessand# el Gentleman Orchestrator).AGENTS.mdloaded into Pi'ssystemPromptOptions.contextFiles(~59 KB containinggentle-ai:orchestrator,gentle-ai:agent-routing,gentle-ai:sdd-orchestrator,gentle-ai:sdd-model-assignments,gentle-ai:engram-protocol,gentle-ai:remote-authorization, andgentle-ai:codegraph-guidance).This results in:
Change
lib/child-context-files.ts:filterManagedBlocksto accept a custom block-removal predicate while preserving byte-for-byte all unmanaged project text, code fences, and structure.isAncestorContextFile(filePath, cwd, home)to detect when a context file is$HOME/AGENTS.md,$HOME/CLAUDE.md, or located in an ancestor directory abovecwd.filterSessionContextFiles(options, cwd, home):~/AGENTS.md), strip all duplicategentle-aimanaged blocks (orchestrator,sdd-orchestrator,sdd-model-assignments,agent-routing,engram-protocol,remote-authorization,codegraph-guidance,persona,strict-tdd-mode), while keeping unmanaged user/workspace instructions byte-for-byte. If an ancestor file becomes entirely blank after filtering, omit it fromcontextFilesto prevent rendering empty instruction blocks.ORCHESTRATOR_ONLY_MANAGED_BLOCKS(orchestrator,sdd-orchestrator,sdd-model-assignments,agent-routing) to prevent stale prompt overrides, while keeping project-local tools and non-orchestrator guidance.extensions/gentle-ai.ts:filterSessionContextFilesintobefore_agent_startfor primary sessions before the orchestrator prompt is appended, ensuring exactly one canonical copy of orchestration rules reaches the model.tests/child-context-files.test.ts: testisAncestorContextFileedge cases (home, parent, cwd, subfolder, unrelated) andfilterSessionContextFilesstripping / omitting.tests/append-system-prompt-route.test.ts: test primary sessionbefore_agent_startfiltering ancestor context files while appendinggentlePrompt.Verification
tests/child-context-files.test.tstests/append-system-prompt-route.test.tstests/orchestrator-budget.test.tsnode scripts/check-types.mjsclean (186 recorded diagnostics, 0 regressions).node scripts/build-runtime-modules.mjs --checkmatches TypeScript sources.Summary by CodeRabbit