refactor: remove dead image media attachment code
- Remove generated_image_paths_from_messages() and _extract_text_payload() from artifacts.py (no runtime callers) - Remove session_attachments.py entirely (merge_turn_media_into_last_assistant and stage_media_paths_for_session_replay had no runtime callers) - Remove test_session_media_persist.py and the orphaned test in test_artifacts.py
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
"""Tests for staging attachment paths into the media bucket for session replay."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from nanobot.config.loader import set_config_path
|
||||
from nanobot.config.paths import get_media_dir
|
||||
from nanobot.utils.session_attachments import stage_media_paths_for_session_replay
|
||||
|
||||
|
||||
def test_persist_media_stages_workspace_file(tmp_path: Path) -> None:
|
||||
set_config_path(tmp_path / "config.json")
|
||||
outside = tmp_path / "workspace" / "report.md"
|
||||
outside.parent.mkdir(parents=True)
|
||||
outside.write_text("body", encoding="utf-8")
|
||||
|
||||
out = stage_media_paths_for_session_replay([str(outside)])
|
||||
|
||||
assert len(out) == 1
|
||||
staged = Path(out[0])
|
||||
assert staged.is_file()
|
||||
assert staged.read_text(encoding="utf-8") == "body"
|
||||
assert staged.resolve().is_relative_to(get_media_dir().resolve())
|
||||
|
||||
|
||||
def test_persist_media_keeps_files_already_under_media_root(tmp_path: Path) -> None:
|
||||
set_config_path(tmp_path / "config.json")
|
||||
media = get_media_dir("websocket")
|
||||
media.mkdir(parents=True, exist_ok=True)
|
||||
inside = media / "keep-me.txt"
|
||||
inside.write_text("x", encoding="utf-8")
|
||||
|
||||
out = stage_media_paths_for_session_replay([str(inside.resolve())])
|
||||
|
||||
assert out == [str(inside.resolve())]
|
||||
@@ -10,8 +10,6 @@ from nanobot.config.loader import set_config_path
|
||||
from nanobot.utils.artifacts import (
|
||||
ArtifactError,
|
||||
decode_image_data_url,
|
||||
generated_image_paths_from_messages,
|
||||
generated_image_tool_result,
|
||||
store_generated_image_artifact,
|
||||
)
|
||||
|
||||
@@ -66,22 +64,3 @@ def test_store_generated_image_artifact_rejects_unsafe_save_dir(tmp_path: Path)
|
||||
model="m",
|
||||
save_dir="../outside",
|
||||
)
|
||||
|
||||
|
||||
def test_generated_image_paths_from_tool_results() -> None:
|
||||
result = generated_image_tool_result(
|
||||
[
|
||||
{"id": "img_1", "path": "/tmp/one.png"},
|
||||
{"id": "img_2", "path": "/tmp/two.png"},
|
||||
]
|
||||
)
|
||||
payload = json.loads(result)
|
||||
|
||||
assert generated_image_paths_from_messages(
|
||||
[
|
||||
{"role": "tool", "name": "generate_image", "content": result},
|
||||
{"role": "tool", "name": "other", "content": result},
|
||||
]
|
||||
) == ["/tmp/one.png", "/tmp/two.png"]
|
||||
assert "Call the message tool" in payload["next_step"]
|
||||
assert "media parameter" in payload["next_step"]
|
||||
|
||||
Reference in New Issue
Block a user