mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-29 01:02:25 +01:00
Consolidate Odysseus agent harness and tool contracts
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from src.agent_evidence import (
|
||||
CompletionRequirements,
|
||||
CompletionStatus,
|
||||
@@ -17,6 +19,27 @@ def test_infers_only_explicit_output_or_edit_paths():
|
||||
assert requirements.verifier_required is True
|
||||
|
||||
|
||||
def test_infers_artifact_from_common_past_participle_request():
|
||||
requirements = infer_completion_requirements(
|
||||
"Build a digest saved to /workspace/results/ops_digest.md."
|
||||
)
|
||||
|
||||
assert requirements.required_artifacts == (
|
||||
"/workspace/results/ops_digest.md",
|
||||
)
|
||||
|
||||
|
||||
def test_inference_ignores_negated_edits_and_callable_names():
|
||||
requirements = infer_completion_requirements(
|
||||
"Write /workspace/results/predictions.json serialized with "
|
||||
"`json.dumps(..., indent=2)`. Do not modify `segmenter.py` or `cases.jsonl`."
|
||||
)
|
||||
|
||||
assert requirements.required_artifacts == (
|
||||
"/workspace/results/predictions.json",
|
||||
)
|
||||
|
||||
|
||||
def test_inference_ignores_prose_abbreviations_that_look_like_paths():
|
||||
requirements = infer_completion_requirements(
|
||||
"Generate statistics, e.g. token counts and timing totals."
|
||||
@@ -25,6 +48,14 @@ def test_inference_ignores_prose_abbreviations_that_look_like_paths():
|
||||
assert requirements.required_artifacts == ()
|
||||
|
||||
|
||||
def test_inference_ignores_bare_existence_helper_as_artifact():
|
||||
requirements = infer_completion_requirements(
|
||||
"Write /workspace/results/answer.json, then verify it with os.path.exists or ls."
|
||||
)
|
||||
|
||||
assert requirements.required_artifacts == ("/workspace/results/answer.json",)
|
||||
|
||||
|
||||
def test_inference_recognizes_named_output_file():
|
||||
requirements = infer_completion_requirements(
|
||||
"Put the implementation in a file called /workspace/worker.py."
|
||||
@@ -33,6 +64,16 @@ def test_inference_recognizes_named_output_file():
|
||||
assert requirements.required_artifacts == ("/workspace/worker.py",)
|
||||
|
||||
|
||||
def test_inference_recognizes_output_into_a_single_file():
|
||||
requirements = infer_completion_requirements(
|
||||
"Reconcile reliable facts into a single file "
|
||||
"/tmp_workspace/results/profile.md. Save only that file in "
|
||||
"/tmp_workspace/results/."
|
||||
)
|
||||
|
||||
assert requirements.required_artifacts == ("/tmp_workspace/results/profile.md",)
|
||||
|
||||
|
||||
def test_output_directory_outranks_relative_example_filenames():
|
||||
requirements = infer_completion_requirements(
|
||||
"Save the results into `/tmp_workspace/results`. Save each recovered table "
|
||||
@@ -477,6 +518,45 @@ def test_python_artifact_write_is_detected_against_declared_path():
|
||||
assert any(event.kind == EvidenceKind.ARTIFACT_MUTATION for event in ledger.events)
|
||||
|
||||
|
||||
def test_json_write_file_then_read_records_required_artifact_mutation():
|
||||
"""Native compact tool events carry write_file arguments as JSON."""
|
||||
|
||||
requirements = CompletionRequirements(
|
||||
required_artifacts=("/workspace/results/paper_digest.md",)
|
||||
)
|
||||
ledger = EvidenceLedger.from_tool_events(
|
||||
[
|
||||
{
|
||||
"round": 1,
|
||||
"tool": "write_file",
|
||||
"command": json.dumps({
|
||||
"path": "/workspace/results/paper_digest.md",
|
||||
"content": "# Verified digest\n",
|
||||
}),
|
||||
"output": "wrote /workspace/results/paper_digest.md",
|
||||
"exit_code": 0,
|
||||
},
|
||||
{
|
||||
"round": 2,
|
||||
"tool": "read_file",
|
||||
"command": json.dumps({
|
||||
"path": "/workspace/results/paper_digest.md",
|
||||
}),
|
||||
"output": "# Verified digest\n",
|
||||
"exit_code": 0,
|
||||
},
|
||||
],
|
||||
requirements,
|
||||
)
|
||||
|
||||
assert ledger.evaluate().status == CompletionStatus.SATISFIED
|
||||
assert any(
|
||||
event.kind == EvidenceKind.ARTIFACT_MUTATION
|
||||
and event.artifact_path == "/workspace/results/paper_digest.md"
|
||||
for event in ledger.events
|
||||
)
|
||||
|
||||
|
||||
def test_inspect_media_export_satisfies_declared_artifact():
|
||||
requirements = infer_completion_requirements("Save /workspace/frame.png")
|
||||
ledger = EvidenceLedger.from_tool_events(
|
||||
|
||||
Reference in New Issue
Block a user