Consolidate Odysseus agent harness and tool contracts

This commit is contained in:
pewdiepie-archdaemon
2026-09-17 10:07:40 +00:00
parent 84aa9a91de
commit 218d762427
229 changed files with 28899 additions and 1551 deletions
@@ -39,3 +39,54 @@ async def test_filesystem_tools_reject_invalid_structured_arguments_before_disk_
assert result["exit_code"] == 1
assert error_fragment in result["error"]
assert resolved == []
@pytest.mark.asyncio
async def test_write_file_preserves_existing_binary_artifact(tmp_path, monkeypatch):
import src.tool_execution as tool_execution
target = tmp_path / "output.pdf"
original = b"%PDF-1.7\nvalid binary payload\x00\xff"
target.write_bytes(original)
monkeypatch.setattr(tool_execution, "_resolve_tool_path", lambda _path: str(target))
result = await WriteFileTool().execute(
'{"path":"output.pdf","content":"The PDF is already complete."}', {}
)
assert result["exit_code"] == 1
assert result["binary_artifact_preserved"] is True
assert "binary artifact path" in result["error"]
assert target.read_bytes() == original
@pytest.mark.asyncio
async def test_write_file_rejects_new_binary_artifact_path(tmp_path, monkeypatch):
import src.tool_execution as tool_execution
target = tmp_path / "new.pdf"
monkeypatch.setattr(tool_execution, "_resolve_tool_path", lambda _path: str(target))
result = await WriteFileTool().execute(
'{"path":"new.pdf","content":"not really a PDF"}', {}
)
assert result["exit_code"] == 1
assert result["binary_artifact_preserved"] is False
assert not target.exists()
@pytest.mark.asyncio
async def test_write_file_still_rewrites_existing_text_file(tmp_path, monkeypatch):
import src.tool_execution as tool_execution
target = tmp_path / "notes.txt"
target.write_text("old", encoding="utf-8")
monkeypatch.setattr(tool_execution, "_resolve_tool_path", lambda _path: str(target))
result = await WriteFileTool().execute(
'{"path":"notes.txt","content":"new"}', {}
)
assert result["exit_code"] == 0
assert target.read_text(encoding="utf-8") == "new"