feat(base2): add JavaScript Control-Flow Verification Rule to system prompt...#872
Open
chicagoist wants to merge 1 commit into
Open
feat(base2): add JavaScript Control-Flow Verification Rule to system prompt...#872chicagoist wants to merge 1 commit into
chicagoist wants to merge 1 commit into
Conversation
…prompt Add a mandatory three-check rule to the General guidelines section: 1. DOM-selector cross-reference — verify querySelector targets exist 2. Execution-path trace — confirm addEventListener calls are reachable 3. boxes.length > 0 pattern — detect dead guards after UI migration Prevents the recurring class of bugs where JS is syntactically valid (node --check passes) but logically dead due to unreachable code wrapped in a falsy condition referencing removed DOM elements.
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.
prompt...
Pull Request: Add JavaScript Control-Flow Verification Rule to Buffy Agent
Repository: CodebuffAI/codebuff
Target file:
agents/base2/base2.tsTarget section:
systemPrompt→# General guidelinesBranch:
mainTitle
Problem
When debugging JS in HTML files, the agent falls into a "syntax-blind loop":
it sees
node --checkfail, fixes brace imbalances mechanically, and declaressuccess when the parser passes — without verifying the code actually executes.
Real-world case study (30-round debugging cycle)
node --check→ SyntaxError (missing braces)node --checkpassed → agent declared "fixed"Root cause: quiz logic was wrapped in
if (boxes.length > 0)whereboxes = querySelectorAll('.answerbox[contenteditable]'). Those elements were removedduring a UI migration to checkboxes.
boxes.lengthwas always 0. Code wassyntactically valid but logically dead. The agent had grep, file reading,
and DOM analysis — but no mandatory checklist to use them.
This is a recurring class of bugs. The fix is not a new tool — it's a
mandatory methodology encoded in the system prompt.
Proposed Change
One new bullet in
# General guidelines, placed after the closing backtick ofthe Composio conditional block (
${ENABLE_COMPOSIO_TOOLS ? ... : ''}) andbefore the literal line
# Spawning agents guidelines.Unified diff
Rationale for single bullet
Existing guidelines use compact
- **Topic:** Actionable instructionformat.This follows the same style. The three sub-checks are inline for brevity while
remaining specific enough to execute.
The Three Rules (reference)
grep '<selector>' *.html→ at least 1 match must existaddEventListener— every wrappingifmust be reachableboxes.length > 0patternContribution Checklist
agents/(per CONTRIBUTING.md)systemPromptAlternatives Considered
instructionsPromptsectionLicense
By submitting this pull request, I confirm that my contribution is made under
the terms of the project's license.