Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jul 8, 2025

Problem

The codebase_search tool was only being enforced at the start of new tasks, not throughout entire conversations. This led to situations where the AI would use less effective search methods (like search_files or list_files) when exploring code later in a conversation, missing important context and relationships.

Solution

Updated the prompt language across multiple sections to make codebase_search enforcement continuous throughout conversations:

Changes Made

  1. Tool Use Guidelines (src/core/prompts/sections/tool-use-guidelines.ts):

    • Changed from: "When starting a new task or when you need to understand existing code/functionality"
    • Changed to: "For ANY exploration of code you haven't examined yet in this conversation"
    • Added explicit statement: "This requirement applies throughout the entire conversation"
  2. Rules Section (src/core/prompts/sections/rules.ts):

    • Changed from: "When you need to understand existing code or functionality"
    • Changed to: "For ANY exploration of code you haven't examined yet in this conversation"
    • Added: "regardless of when in the conversation it occurs"
  3. Objective Section (src/core/prompts/sections/objective.ts):

    • Changed from: "if the task involves understanding existing code or functionality"
    • Changed to: "For ANY exploration of code you haven't examined yet in this conversation"
    • Added: "This applies throughout the entire conversation"
  4. Test Updates:

    • Updated test expectations in objective.spec.ts and tool-use-guidelines.spec.ts to match the new enforcement language
    • All tests are passing

Impact

This change ensures that codebase_search is used consistently throughout conversations, improving:

  • Code discovery and understanding
  • Context awareness when exploring unfamiliar parts of the codebase
  • Overall quality of code analysis and modifications

Testing

  • ✅ All unit tests updated and passing
  • ✅ Linting checks passed
  • ✅ Type checking passed

Important

Enforces continuous use of codebase_search throughout conversations for consistent code exploration, with updates to prompt language and tests.

  • Prompt Language Updates:
    • Updated tool-use-guidelines.ts, rules.ts, and objective.ts to enforce codebase_search for any new code exploration during conversations.
    • Added language to emphasize continuous enforcement, not just at task start.
  • Test Updates:
    • Modified objective.spec.ts and tool-use-guidelines.spec.ts to align with new codebase_search enforcement language.
    • Ensured tests check for continuous enforcement language.
  • Impact:
    • Ensures consistent use of codebase_search, improving code understanding and context awareness.
    • Enhances quality of code analysis and modifications.

This description was created by Ellipsis for 73782d9. You can customize this summary. It will automatically update as commits are pushed.

- Remove conditional 'when starting a new task' language
- Change to 'For ANY exploration of code you haven't examined yet in this conversation'
- Add explicit statements that the requirement applies throughout the entire conversation
- Update test expectations to match the new enforcement language

This ensures codebase_search is used consistently throughout conversations,
not just at the beginning of tasks, improving code discovery and understanding.
Copilot AI review requested due to automatic review settings July 8, 2025 23:44
@hannesrudolph hannesrudolph requested review from cte, jr and mrubens as code owners July 8, 2025 23:44
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 8, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jul 8, 2025

No security or compliance issues detected. Reviewed everything up to 73782d9.

Security Overview
  • 🔎 Scanned files: 5 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► objective.ts
    Strengthen codebase_search enforcement language
► rules.ts
    Update codebase_search rules with stronger enforcement
► tool-use-guidelines.ts
    Enhance codebase_search tool usage guidelines
Configuration changes ► package.json
    Update package version
Refactor ► objective.spec.ts
    Update test expectations for new enforcement language
► tool-use-guidelines.spec.ts
    Update test cases for revised tool guidelines

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR strengthens the enforcement of the codebase_search tool by making it mandatory for any new code exploration throughout conversations.

  • Unified prompt language to insist on codebase_search first whenever exploring unfamiliar code areas
  • Updated all related sections (tool-use-guidelines, rules, objective) with continuous-enforcement wording
  • Adjusted corresponding unit tests to validate the new phrasing

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/core/prompts/sections/tool-use-guidelines.ts Made codebase_search enforcement apply throughout conversations
src/core/prompts/sections/rules.ts Broadened rule to require semantic search for any new code area
src/core/prompts/sections/objective.ts Changed objective text to mandate continuous codebase_search use
src/core/prompts/sections/tests/tool-use-guidelines.spec.ts Updated test strings to match the new guideline wording
src/core/prompts/sections/tests/objective.spec.ts Modified objective tests to check for the added enforcement note
Comments suppressed due to low confidence (1)

src/core/prompts/sections/objective.ts:14

  • The objective section refers to 'entire task' while other sections mention 'entire conversation'. Consider standardizing this phrasing for consistency across all prompts.
		? "First, for ANY exploration of code you haven't examined yet in this conversation, you MUST use the `codebase_search` tool to search for relevant code based on the task's intent BEFORE using any other search or file exploration tools. This applies throughout the entire task, not just at the beginning - whenever you need to explore a new area of code, codebase_search must come first. Then, "

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 8, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 9, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jul 9, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 9, 2025
@mrubens mrubens merged commit 0028c56 into main Jul 9, 2025
26 checks passed
@mrubens mrubens deleted the fix/strengthen-codebase-search-enforcement branch July 9, 2025 03:12
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 9, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer PR - Needs Review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants