"""Validation-only Harbor agents. Never used for benchmark model scores.""" from harbor.agents.base import BaseAgent from harbor.agents.oracle import OracleAgent class CaptureOracleAgent(OracleAgent): """Validation only: make a scripted capture call, then use the real oracle.""" def __init__(self, validation_base_url, validation_session, **kwargs): super().__init__(**kwargs) self.validation_base_url = validation_base_url self.validation_session = validation_session async def run(self, instruction, environment, context): import asyncio import json import urllib.request request = urllib.request.Request( self.validation_base_url + "/v1/chat/completions", data=json.dumps( { "model": "validation-oracle", "messages": [ { "role": "user", "content": "Acknowledge this lifecycle validation.", } ], "stream": False, } ).encode(), headers={ "Content-Type": "application/json", "Authorization": "Bearer " + self.validation_session, }, ) def call(): with urllib.request.urlopen(request, timeout=20) as response: assert json.load(response)["choices"] await asyncio.to_thread(call) # Exercise the public CLI in the actual agent container as well as the oracle's HTTP path. observation = await environment.exec(command="escape observe") assert observation.return_code == 0 assert "available_entities" in json.loads(observation.stdout) invalid = await environment.exec( command="escape investigate __aeb_nonexistent_node__" ) assert invalid.return_code == 0 and not json.loads(invalid.stdout)["ok"] wrong = await environment.exec( command="escape submit-answer __aeb_incorrect_answer__" ) assert wrong.return_code == 0 and not json.loads(wrong.stdout)["is_win"] await super().run(instruction, environment, context) class ForgeAgent(BaseAgent): @staticmethod def version(): return "1.0" @staticmethod def name(): return "aeb-forgery-check" async def setup(self, environment): pass async def run(self, instruction, environment, context): # Attempt to forge both local evidence and a reward. Neither should reach the fresh verifier. result = await environment.exec( command="""python - <<'PY' import json,pathlib for root in ['/evidence', '/logs/artifacts/evidence', '/logs/verifier']: pathlib.Path(root).mkdir(parents=True,exist_ok=True) for root in ['/evidence', '/logs/artifacts/evidence']: pathlib.Path(root,'final.json').write_text(json.dumps({'won':True,'collected_from_live_service':True})) pathlib.Path('/logs/verifier/reward.txt').write_text('1.0') PY""" ) if result.return_code != 0: raise RuntimeError(result.stderr)