Skip to content

fix(repo): a Copilot grep tool call over a guidance file goes into searched - #1228

Merged
antonwolfy merged 1 commit into
intel:mainfrom
antonwolfy:fix/copilot-grep-searched
Nov 25, 2026
Merged

antonwolfy merged 1 commit into
intel:mainfrom
antonwolfy:fix/copilot-grep-searched

Conversation

@antonwolfy

Copy link
Copy Markdown
Contributor

Summary

#1002: Copilot CLI has its own grep tool, and cli_traces._copilot_tool knew only view as a read tool and bash/powershell as shell tools, so a grep call over a guidance file was one bare tool event. On main, with the argument shape of the CLI's grep tool (pattern, paths as a string or a list, output_mode; the issue's repro guessed a path key, which the CLI does not send):

start    {"toolName": "grep", "arguments": {"pattern": "warn", "paths": "AGENTS.md", "output_mode": "content"}}
complete {"success": true, "result": {"content": "AGENTS.md:3:- warn: always lint"}}
convert("copilot-json", ..., "/ws").events  ->  [{'t': None, 'kind': 'tool', 'name': 'grep'}]
process_metrics(...)["guidance_searched"]   ->  []

Now the event carries searched: ["AGENTS.md"] and guidance_searched is ["AGENTS.md"]. The fix takes the option the issue lists: the path and mode are read from the call and the path goes into searched of the tool event, as events._tool_event does for Claude Code's Grep. The issue asked for a recorded trace first; none could be recorded for this PR, so the argument names come from the Copilot CLI 1.0.75 argument schema instead (Risk and Open questions).

Closes #1002

Changes

  • dokimi/dokimi/repos/cli_traces.py: _copilot_tool gives a grep call in output_mode content a searched list, the call's paths (one string or a list; an empty or non-string entry is skipped), each resolved from the start directory as a view path is, through searched_field. The default mode, files_with_matches, count and a call with no paths print no line of a file and stay a bare tool event. _copilot_result drops searched when the result failed (success false), or its content is empty or No matches found.. A search adds no read event, so tool_calls and guidance_read do not change. Arguments that are not an object stay a bare tool event, with no dropped line.
  • dokimi/docs/repo-evaluation-contract.md (§4.1 guidance_searched), dokimi/docs/events-format.md and the process_metrics.py docstring: a Copilot grep call counts under the rules of a Claude Code Grep call; a PowerShell command is still not parsed.
  • dokimi/tests/test_repo_copilot_grep.py: 16 tests through convert("copilot-json", ...) and process_metrics.
  • Changelog fragment (Fixed).

Risk

The grep argument shape (paths, output_mode) follows the Copilot CLI 1.0.75 argument schema; the fixture in the tests is built from it and is not a recorded trace. A trace of a CLI version that names the keys differently gets no searched, as before.

The Copilot converter does not track a shell moved by an earlier bash call's cd for view, so a relative grep path follows view: it is resolved from the start directory and kept after a cd. A Claude Code Grep path is dropped there; a Copilot one is not. Whether a cd in a Copilot bash call moves the directory its grep and view tools start in is not checked on a real trace; if it does, a relative grep path after a cd can credit a file the call did not search, as a relative view path can today.

A merge with #1155 meets a text conflict in repo-evaluation-contract.md: it edits the §4.1 guidance_read row, the line next to the guidance_searched row this PR edits. Keeping both rows settles it. #1201 and #1223 merge cleanly.

A directory in paths is kept in searched and filtered out by process_metrics, as for a Claude Code Grep. Every other Copilot tool and Claude Code's Grep handling convert as before.

Testing

On Linux, at 3c2e6fc0 (on main 602de140):

  • make ci-local: 38 passed, 0 failed, 15 skipped (micromamba, semgrep, the fuzz run, the matrix jobs and the deploy job, whose conditions or tools are absent locally). 28398 tests passed, 23 skipped; changed-line coverage 100%.
  • The new test file fails on main's code, run with the CLI's paths input: 6 failed, 10 passed; the first failure is the content grep over AGENTS.md, whose event lacks searched. The 10 that pass pin what stays (no searched for the other modes, a no-match, an empty or a failed result).
  • Mutants, each failing a test: without the output_mode == "content" check, 3 tests fail (the default, files_with_matches and count cases); without the no-match drop, 4 fail (No matches found., with spaces around it, empty, success: false); with only the first entry of a paths list, the list test fails.
  • Not run: Python 3.11, 3.12 and 3.14, and CI's merge commit.

Open questions

The fixture is built from the CLI's argument schema, not recorded: no Copilot login was available. Should a recorded trace replace it?

Revert

A plain revert restores the bare tool event for a grep call. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…arched (intel#1002)

The copilot-json converter knew only view as a read tool and bash/powershell as shell tools, so a grep tool call was one bare tool event and guidance_searched never listed the file it searched.

A grep call in output_mode content now carries searched: its paths (one string or a list, each resolved from the start directory as a view path is). The default mode, files_with_matches and count print no line of a file, and a call with no paths names none, so they stay bare. A failed result, an empty one or "No matches found." drops searched. A search adds no read event.

The Copilot converter does not track a shell moved by an earlier cd for view, so a relative grep path follows view.

The contract's guidance_searched row, the events format, the process_metrics docstring and a changelog fragment say so.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner November 25, 2026 18:03
@antonwolfy antonwolfy self-assigned this Nov 25, 2026
@exai-bot

exai-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 6 selected item(s).

CI at 3c2e6fc: 25 passing, 4 skipped.

Review details
  • Commit reviewed: 3c2e6fc against merge base 602de14
  • Coverage: 6 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 132k tokens (78k from cache), 18s
  • Tool calls: 8 (5 file_read, 1 ci_status, 1 code_search, 1 linked_items)
  • Copilot grep search trace handling, metrics, tests, and documentation: 6 files

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.07%. Comparing base (602de14) to head (3c2e6fc).
⚠️ Report is 1 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1228      +/-   ##
==========================================
- Coverage   96.07%   96.07%   -0.01%     
==========================================
  Files         496      496              
  Lines       65209    65221      +12     
  Branches    11317    11319       +2     
==========================================
+ Hits        62652    62659       +7     
- Misses       1583     1584       +1     
- Partials      974      978       +4     
Files with missing lines Coverage Δ
dokimi/dokimi/repos/cli_traces.py 98.65% <100.00%> (+0.05%) ⬆️
dokimi/dokimi/repos/process_metrics.py 100.00% <ø> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change class: CONTRACT (head 3c2e6fc)

  • Contract: changed (count signal only, no file:line)
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

Reviewed conversion of content-mode grep calls, path lists, and removal of search evidence on failed or empty results. Seven focused conversion tests passed locally. CI passed. Trace coverage uses the CLI schema and synthetic records. A live Copilot trace remains unverified.

@antonwolfy
antonwolfy merged commit 04b16f9 into intel:main Nov 25, 2026
29 checks passed
@antonwolfy
antonwolfy deleted the fix/copilot-grep-searched branch November 25, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo: a Copilot grep tool call over a guidance file is not in guidance_searched

4 participants