Skip to content

Return AgentResult from BC-Bench agent harnesses - #1009

Merged
Sun Haoran (haoranpb) merged 1 commit into
core/harness-02-contractfrom
app/harness-03-agent-result
Nov 3, 2026
Merged

Sun Haoran (haoranpb) merged 1 commit into
core/harness-02-contractfrom
app/harness-03-agent-result

Conversation

@haoranpb

Copy link
Copy Markdown
Collaborator

Stacked on #1008.

First BC-Bench adoption step: the Copilot, Claude, PR Review and BCal harness functions return the core AgentResult instead of a (metrics, experiment) tuple, and AgentRunner / the 8 pipelines read it. Copilot and Claude now also return their final message as response (previously discarded).

Next in the stack: harness classes implementing Harness[T] (with identity() replacing the per-harness get_*_version() calls in the CLI), then BCal transcripts and bc-bench-internal adoption.

The Copilot, Claude, PR Review and BCal harness functions now return the
core AgentResult instead of a (metrics, experiment) tuple, and pipelines
read it through AgentRunner. Copilot and Claude also return their final
message as the response, which was previously discarded.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 10:21

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the AgentResult migration.

No open issues 🎉

What changed in this PR

This PR adopts the harness-neutral AgentResult introduced in #1008 across BC-Bench’s four agent harnesses and eight evaluation pipelines, preparing for the later Harness[T] migration.

Changes:

  • Replace (metrics, experiment) return tuples with AgentResult and update AgentRunner and pipeline consumers.
  • Preserve Copilot and Claude final messages in AgentResult.response.
  • Update mocks and tests to use the new result contract.
File Description
tests/​test_pr_review_agent.py Assert metrics and experiment fields on the returned result.
tests/​test_nl2al_pipeline.py Return AgentResult from the test runner.
tests/​test_evaluate_pipeline.py Adapt pipeline stubs and runners to the new contract.
tests/​test_copilot_agent.py Verify final response preservation and experiment access.
tests/​test_bcal_agent_provider.py Check metrics through the returned result.
src/​bcbench/​evaluate/​testgeneration.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​nl2al.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​ext_request_triage.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​ext_request_implement.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​ext_request_advisor.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​dataquery.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​codereview.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​bugfix.py Read metrics and experiment from AgentResult.
src/​bcbench/​evaluate/​base.py Change the AgentRunner protocol to return AgentResult.
src/​bcbench/​commands/​evaluate.py Return an empty AgentResult for mock evaluation.
src/​bcbench/​agent/​pr_review/​agent.py Wrap review metrics and experiment in AgentResult.
src/​bcbench/​agent/​copilot/​agent.py Return response, metrics, and experiment in AgentResult.
src/​bcbench/​agent/​claude/​agent.py Return response, metrics, and experiment in AgentResult.
src/​bcbench/​agent/​bcal/​agent.py Wrap execution metrics and experiment in AgentResult.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: Python

Python / code-coverage/pytest

core/harness-02-cont... c89d9aa app/harness-03-agent... 266df18 +/-
88% 88% 0%
View coverage of the 10 most impacted files.
File core/harness-02-cont... c89d9aa app/harness-03-agent... 266df18 +/-
src/bcbench/exceptions.py 70% 65% -5%
src/bcbench/eva...uest_advisor.py 94% 91% -3%
src/bcbench/eva...e/codereview.py 90% 88% -2%
src/bcbench/eva...quest_triage.py 62% 60% -2%
src/bcbench/eva...st_implement.py 69% 68% -1%
src/bcbench/eva...te/dataquery.py 69% 68% -1%
src/bcbench/eva...stgeneration.py 56% 55% -1%
src/bcbench/types.py 94% 94% 0%
packages/bcbenc...gent/harness.py 0% 100% +100%
packages/bcbenc...t/experiment.py 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


class AgentRunner[E: BaseDatasetEntry](Protocol):
def __call__(self, context: EvaluationContext[E], /) -> tuple[AgentMetrics | None, ExperimentConfiguration | None]: ...
def __call__(self, context: EvaluationContext[E], /) -> AgentResult: ...
@haoranpb
Sun Haoran (haoranpb) merged commit 266df18 into main Nov 3, 2026
18 checks passed
@haoranpb
Sun Haoran (haoranpb) deleted the app/harness-03-agent-result branch November 3, 2026 10:42
@haoranpb

Copy link
Copy Markdown
Collaborator Author

Folded into #1008 (its commit is now part of that branch).

An error occurred while trying to automatically change base from core/harness-02-contract to main November 3, 2026 14:29
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.

2 participants