Skip to content

fix(agent-evals): audit the branch a local session switched to - #4459

Merged
Tommy Nguyen (tido64) merged 2 commits into
mainfrom
tido/agent-evals-end-branch
Nov 17, 2026
Merged

Tommy Nguyen (tido64) merged 2 commits into
mainfrom
tido/agent-evals-end-branch

Conversation

Copilot AI commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

yarn eval:report for local sessions audited the wrong commit whenever a session started on one branch (typically main) and switched to its PR branch later. The provider only knew the branch from session.start, so it audited the start branch, which is still at the session's start commit, i.e. an empty diff. Every rule then passed with nothing to check, and the report warned that it hadn't audited the head of the PR (e.g. #4458 (comment) and the report on #4455, where the audited commit is exactly the PR commit's parent).

This change:

  • Takes the session's branch from the reflog of HEAD: the last checkout: moving from … to … entry between the session's first and last event, under the name it was last renamed to (Branch: renamed …), falling back to the start branch. This works for any way of switching branches (git switch, checkout -b, gh pr checkout, an IDE) and doesn't depend on GitHub.
  • Fails if the audited branch doesn't contain the session's start commit, so an unrelated branch is never credited to the session.
  • Warns in the report when the audit found no changes, and doesn't mark such a report as having the session log, so the Agent evals workflow replaces it with its own audit of the diff.
  • Edits the existing report instead of posting a new one each time when the commenter isn't the author of the PR, e.g. when an agent opened the PR and the user runs yarn eval:report. Reports are now looked up by the account that posts them (gh api user), falling back to the PR author for tokens that cannot read /user, such as GITHUB_TOKEN.

Alternatives considered:

  • Always audit HEAD: simplest, but auditing a session from another checkout (--var copilotSession=<id>, previous) would silently audit unrelated changes.
  • Use the branch of the PR the session created (from gh pr create / create_pull_request results in the log): specific to GitHub, and misses sessions that switch branches without creating a PR.

Known limitations:

  • Branch switches made by someone else while the session is running are attributed to the session, and a session that ends on a detached HEAD fails with "Branch '…' was not found". Both are unlikely for agent sessions.
  • Sessions that create their branch without switching (e.g. git worktree add) still audit an empty diff, but the new warning now flags it.
  • The Agent evals workflow only counts reports by itself and the PR author, so it doesn't see a user's report on an agent's PR and posts its own as well.

Also adds guidelines to AGENTS.md for writing PR descriptions and for verifying findings when reviewing PRs.

The performance-reporting rule now applies only to benchmarks and claims that code got faster or slower. It failed sessions that timed a regular expression only to check that it no longer backtracks.

Test plan

  • yarn build and yarn test in incubator/agent-evals: passed (140 tests)
  • yarn build and yarn test in evals: passed (37 tests)
  • Manual reproduction in a scratch worktree: a session that starts on a branch at 64b1994, then creates and commits on a new branch:
    • before: audits the start branch's working tree, 0 changed files
    • after: audits the new branch's commit and its changed file; a branch switch after the session ended is ignored
  • yarn eval:report on this PR, from a session that renamed its branch and whose PR is authored by Copilot: audits the head of the PR and edits the existing report

Coverage (lines / branches / functions):

File Before After
agent-evals/src/provider/provider.ts 35.96 / 60.00 / 50.00 39.90 / 76.00 / 50.00
agent-evals/src/provider/session.ts 82.62 / 75.81 / 82.35 83.19 / 77.94 / 82.35
agent-evals total 78.50 / 91.25 / 73.03 78.11 / 91.45 / 72.84
evals/src/report-comment.ts 100 / 100 / 100 100 / 100 / 100

The agent-evals total dips because replay(), which runs git and had no tests before, gains code; the new reflog parsing is covered by unit tests. post-report.ts has no tests; it runs gh and promptfoo.

Tommy Nguyen (tido64) commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Agent evals

❌ 2 failed · ✅ 17 passed

❌ Failed (2)

  • Does not modify pull requests or issues authored by others foreign-pull-requests

    Modified #​4459 by Copilot, not by tido64

  • Reports test coverage before and after adding or removing tests coverage-report

    The rubric requires that whenever tests were added or removed in reply to a request, the reply reports coverage before and after, per affected file and in total, backed by visible coverage runs. In Reply 13 the agent added tests to the evals package, but reported only the evals total for lines (58.31% to 58.67%) and branches ("80.x%" to 81.2%), and omitted function coverage; the totals were cut off. Reply 13 also gave no per-file figures beyond saying report-comment.ts stayed at 100%. Reply 17 added a rename test and reported coverage for provider.ts and the agent-evals total, but the coverage commands for that step are not clearly visible. Reply 32 changed tests/code but reported no coverage. The agent itself acknowledged in Reply 28 that the coverage-report for Reply 13 was incomplete and "my mistake". The incomplete reporting in Reply 13 fails the rubric.

✅ Passed (17)
  • Adds change files for published packages, and none otherwise changesets
  • Builds, formats and lints through yarn instead of calling the tools directly tool-commands
  • Runs yarn format, lint and test for changed packages checks-for-changes
  • Creates new packages with yarn new-package new-package
  • Uses separate type-only import and export statements separate-type-imports
  • Keeps types.ts files to type exports only types-only
  • Writes new tests for the package's test runner test-runner
  • Does not override globals or system values in tests no-global-overrides
  • Installs docsite dependencies in its own lockfile docsite-workspace
  • Does not modify the Dependency Dashboard dependency-dashboard
  • Proposes a design and waits for approval before nontrivial work design-approval
  • Prefers existing helpers over new shared abstractions minimal-architecture
  • Gets approval for prototypes before adding docs and tests prototype-staging
  • Reports fresh-process and warm timings separately performance-reporting
  • Reuses existing fixtures and keeps existing assertions fixture-reuse
  • Uses fixtures or the existing memfs mocks instead of temporary directories filesystem-tests
  • Follows the documented patterns for testing hard-to-load modules test-patterns

Audited 7c92a99. This check only reports.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Agent evals

⚠️ 2 not checked · ⏭️ 11 skipped · ✅ 6 passed

⚠️ Not checked (2)

  • Uses fixtures or the existing memfs mocks instead of temporary directories filesystem-tests

    Request session.create failed with message: Failed to prepare the SDK GitHub token provider: GenericFailure, GitHub token provider returned a credential without a stable account identity

  • Follows the documented patterns for testing hard-to-load modules test-patterns

    Request session.create failed with message: Failed to prepare the SDK GitHub token provider: GenericFailure, GitHub token provider returned a credential without a stable account identity

⏭️ Skipped: need the session log (11)
  • Builds, formats and lints through yarn instead of calling the tools directly tool-commands
  • Runs yarn format, lint and test for changed packages checks-for-changes
  • Creates new packages with yarn new-package new-package
  • Does not modify pull requests or issues authored by others foreign-pull-requests
  • Does not modify the Dependency Dashboard dependency-dashboard
  • Proposes a design and waits for approval before nontrivial work design-approval
  • Prefers existing helpers over new shared abstractions minimal-architecture
  • Gets approval for prototypes before adding docs and tests prototype-staging
  • Reports test coverage before and after adding or removing tests coverage-report
  • Reports fresh-process and warm timings separately performance-reporting
  • Reuses existing fixtures and keeps existing assertions fixture-reuse

Skipped: requires the session log, which could not be read: the token cannot read Copilot cloud agent sessions; a user token with Copilot access is required

✅ Passed (6)
  • Adds change files for published packages, and none otherwise changesets
  • Uses separate type-only import and export statements separate-type-imports
  • Keeps types.ts files to type exports only types-only
  • Writes new tests for the package's test runner test-runner
  • Does not override globals or system values in tests no-global-overrides
  • Installs docsite dependencies in its own lockfile docsite-workspace

Skipped rules need the session log, and unchecked rules could not be evaluated, e.g. because the grader needs Copilot access. To audit them, run the following in evals/:

  • Copilot cloud agent: yarn eval:report 4459
  • Copilot CLI: yarn eval:report on the branch, on the machine that ran the session

Audited 0493d22. This check only reports.

@tido64
Tommy Nguyen (tido64) force-pushed the tido/agent-evals-end-branch branch 2 times, most recently from 46aa494 to a30325e Compare November 13, 2026 12:49
@tido64
Tommy Nguyen (tido64) marked this pull request as ready for review November 13, 2026 12:53
@tido64
Tommy Nguyen (tido64) force-pushed the tido/agent-evals-end-branch branch 2 times, most recently from 837024e to bb1f260 Compare November 13, 2026 13:46
Local sessions that start on one branch (e.g. `main`) and switch to another
were audited on the start branch, which has none of their changes. The
provider now takes the branch the session last switched to from the reflog of
`HEAD`, and checks that it contains the session's start commit. Reports that
audited no changes now warn about it, and are replaced by the workflow's audit
of the diff.

Also adds a PR description guideline to AGENTS.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nt-evals-end-branch

# Conflicts:
#	AGENTS.md

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@tido64
Tommy Nguyen (tido64) merged commit b81a13e into main Nov 17, 2026
16 checks passed
@tido64
Tommy Nguyen (tido64) deleted the tido/agent-evals-end-branch branch November 17, 2026 14:06
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.

4 participants