Spaces:
Running on Zero
Running on Zero
File size: 1,751 Bytes
8fb1ae9 e12a049 8fb1ae9 e12a049 8fb1ae9 e12a049 8fb1ae9 fbdb1e5 8fb1ae9 4c42dea 8fb1ae9 fbdb1e5 4c42dea 9e8a876 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import json
from pathlib import Path
from tests.helpers import load_test_index
from hackathon_advisor.agent import AdvisorEngine
from hackathon_advisor.data import ProjectIndex
from hackathon_advisor.trace_export import build_trace_jsonl, trace_metadata
def test_trace_jsonl_contains_manifest_and_turns() -> None:
index = load_test_index()
engine = AdvisorEngine(index)
state = engine.turn("A local-first archive cartographer for family photos", {}).state
state = engine.turn("make a build plan", state).state
lines = [json.loads(line) for line in build_trace_jsonl(state, trace_metadata(index)).splitlines()]
assert lines[0]["type"] == "trace_manifest"
assert lines[0]["turn_count"] == 2
assert lines[0]["index"]["algorithm"] == "llama-cpp-embedding-v1"
assert lines[1]["type"] == "agent_turn"
assert lines[1]["tools"]
assert lines[1]["tool_resolution"]["call"]["name"] == "save_idea"
assert lines[2]["plan_steps"] > 0
def test_checked_in_sample_trace_matches_schema() -> None:
lines = [
json.loads(line)
for line in Path("data/sample_trace.jsonl").read_text(encoding="utf-8").splitlines()
]
sample_text = "\n".join(json.dumps(line) for line in lines)
assert lines[0]["type"] == "trace_manifest"
assert lines[0]["turn_count"] >= 3
assert all(line["schema_version"] == 1 for line in lines)
assert lines[1]["tool_resolution"]["status"] == "valid"
assert "Mothback" not in sample_text
assert "Add one prize" not in sample_text
assert "set_target" not in sample_text
assert "side_quests" not in sample_text
assert "Record the trace" not in sample_text
assert "Write build notes from the exact decisions" in lines[-1]["response"]
|