refactor(agent): move document media logic out of AgentLoop into document.py

Extract is_image_file() and reference_non_image_attachments() from
AgentLoop private static methods into nanobot/utils/document.py where
they belong alongside extract_documents(). Simplify config lookup by
removing dead isinstance(dict) branch.
This commit is contained in:
chengyongru
2026-05-29 15:31:03 +08:00
committed by Xubin Ren
parent ec4f9e9857
commit 672fabe5be
3 changed files with 54 additions and 51 deletions
@@ -10,6 +10,7 @@ from nanobot.bus.events import InboundMessage
from nanobot.bus.queue import MessageBus
from nanobot.config.schema import ChannelsConfig
from nanobot.providers.base import LLMResponse
from nanobot.utils.document import reference_non_image_attachments
def _make_loop(tmp_path: Path, channels_config: ChannelsConfig | None = None) -> AgentLoop:
@@ -159,7 +160,7 @@ def test_document_extraction_disabled_still_preserves_images(tmp_path: Path) ->
doc_path = tmp_path / "report.txt"
doc_path.write_text("manual extraction target", encoding="utf-8")
content, media = AgentLoop._reference_non_image_attachments(
content, media = reference_non_image_attachments(
"review these",
[str(image_path), str(doc_path)],
)