Fix research rules handling: prevent LLM confusion and unnecessary tool cascades#262
Merged
Merged
Conversation
Contributor
Author
377d05f to
8862fd2
Compare
Owner
|
Thanks! |
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.
Title: Fix research rules handling: prevent LLM confusion and unnecessary tool cascades
Description:
Fixes two related issues with
.dexter/RULES.mdhandling:LLM fails to create first research rule — The system prompt only showed "use write_file or edit_file to modify rules" when
RULES.mdalready existed. For the first rule, the LLM never saw these instructions and fell back tomemory_search(which mentions "portfolio rules") and thenweb_search./rulescommand triggers tool cascade — The slash command routed through the full agent loop, causing the agent to callread_file,browser,memory_search, andread_fileagain just to discover the file didn't exist.Changes:
src/agent/prompts.ts— Rule management instructions now always appear in the system prompt, not just when rules already existsrc/tools/filesystem/write-file.ts— Added.dexter/RULES.mdas an explicit use case examplesrc/tools/filesystem/edit-file.ts— Added.dexter/RULES.mdediting as an explicit use case examplesrc/tools/memory/memory-search.ts— Changed "portfolio rules" to "portfolio/trading rules" to reduce confusion with research rulessrc/cli.ts—/rulescommand now reads.dexter/RULES.mddirectly and displays results or a "no rules set" message, bypassing the agent loop entirelyTesting:
bun run typecheckpassesbun testpasses (37 tests)Logs:
Before:
After: