Project-2 baseline
This commit is contained in:
@@ -5,8 +5,8 @@ its captured workspace state — no model calls, no agent work.
|
||||
Reads a `reference_run_dir` pointing at a `reference-runs/<id>/` directory
|
||||
captured during a prior real trial. Inside that dir:
|
||||
|
||||
agent/trajectory.json — the grader reads this via the symlink
|
||||
/tmp/outputs/task_transcript.txt → /logs/agent/trajectory.json
|
||||
agent/trajectory.json — the grader reads this through the transcript
|
||||
symlink test.sh creates (→ /logs/agent/trajectory.json)
|
||||
agent-output/ — files the agent created or modified (captured by
|
||||
tests/test.sh after the agent ran)
|
||||
agent-output/_HARBOR_DELETIONS.txt
|
||||
@@ -44,12 +44,13 @@ from harbor.models.trial.paths import EnvironmentPaths
|
||||
|
||||
# Sibling module (shipped alongside in the worker toolkit; on PYTHONPATH via
|
||||
# harbor-regrade). Kept harbor-free so its logic stays unit-testable.
|
||||
from reference_run_capture import captured_mutating_tools
|
||||
from reference_run_capture import captured_mutating_tools, resolve_capture_dir
|
||||
|
||||
_WORKSPACE = PurePosixPath("/workspace")
|
||||
_DELETIONS_MARKER = "_HARBOR_DELETIONS.txt"
|
||||
|
||||
|
||||
|
||||
class ReplayAgent(BaseAgent):
|
||||
"""Replays a captured reference run so the verifier can be re-graded
|
||||
without invoking the model again."""
|
||||
@@ -82,7 +83,15 @@ class ReplayAgent(BaseAgent):
|
||||
raise FileNotFoundError(f"reference_run_dir does not exist: {ref}")
|
||||
self._reference_run_dir = ref
|
||||
self._agent_output_dir = ref / "agent-output"
|
||||
self._trajectory_path = ref / "agent" / "trajectory.json"
|
||||
self._capture_dir = resolve_capture_dir(ref)
|
||||
self._trajectory_path = self._capture_dir / "agent" / "trajectory.json"
|
||||
if self._capture_dir != ref:
|
||||
self.logger.info(
|
||||
"reference_run %s has no agent/trajectory.json; replaying the "
|
||||
"stored regrade's copy at %s",
|
||||
ref,
|
||||
self._trajectory_path,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def name() -> str:
|
||||
@@ -105,12 +114,12 @@ class ReplayAgent(BaseAgent):
|
||||
# workspace edits, so a faithful capture of one has an empty (or, in
|
||||
# older pipelines, absent) agent-output/. That is not a data gap: the
|
||||
# deliverable is the agent's final message, captured in
|
||||
# agent/trajectory.json, which the grader reads via
|
||||
# /tmp/outputs/task_transcript.txt. So overlay captured edits when
|
||||
# agent/trajectory.json, which the grader reads through test.sh's
|
||||
# transcript symlink. So overlay captured edits when
|
||||
# present; otherwise grade the base workspace + transcript, exactly
|
||||
# what the original advisory grading saw.
|
||||
if not self._agent_output_dir.is_dir():
|
||||
mutating = captured_mutating_tools(self._reference_run_dir)
|
||||
mutating = captured_mutating_tools(self._capture_dir)
|
||||
if mutating:
|
||||
# The agent edited files but they weren't captured — grading the
|
||||
# base workspace would silently score the wrong state. Refuse.
|
||||
@@ -160,12 +169,12 @@ class ReplayAgent(BaseAgent):
|
||||
)
|
||||
|
||||
# 3. Materialize the captured trajectory at the path the grader's
|
||||
# test.sh symlinks to /tmp/outputs/task_transcript.txt.
|
||||
# test.sh symlinks its transcript to.
|
||||
await self._upload_trajectory(environment)
|
||||
|
||||
async def _upload_trajectory(self, environment: BaseEnvironment) -> None:
|
||||
"""Upload agent/trajectory.json to the path the grader's test.sh
|
||||
symlinks to /tmp/outputs/task_transcript.txt. Shared by the normal
|
||||
symlinks its transcript to. Shared by the normal
|
||||
(overlay) path and the advisory (no agent-output) path."""
|
||||
if self._trajectory_path.exists():
|
||||
env_paths = EnvironmentPaths.for_os(environment.os)
|
||||
@@ -174,7 +183,7 @@ class ReplayAgent(BaseAgent):
|
||||
target_path=str(env_paths.agent_dir / "trajectory.json"),
|
||||
)
|
||||
else:
|
||||
# The grader's test.sh reads /tmp/outputs/task_transcript.txt,
|
||||
# The grader's test.sh reads its transcript symlink,
|
||||
# which symlinks to trajectory.json. Without the file the symlink
|
||||
# dangles and the grader sees an empty transcript — so the regrade
|
||||
# will look like the agent did nothing. Yell via harbor's own
|
||||
|
||||
Reference in New Issue
Block a user