router: enforce direct image inputs for plant tools and inject runtime image_data

This commit is contained in:
NODA1 System
2026-02-21 11:52:50 +01:00
parent f3d2aa6499
commit 50dfcd7390
2 changed files with 63 additions and 4 deletions

View File

@@ -2007,6 +2007,19 @@ async def agent_infer(agent_id: str, request: InferRequest):
tool_args = {"params": {"count": 3, "timezone": "Europe/Kyiv"}}
logger.info("🛠️ oneok: auto-filled schedule_propose_slots.params")
# Plant tools: inject runtime image payload from current request to avoid
# hallucinated page URLs (e.g. t.me/<chat>/<msg>) that are not direct images.
if tool_name in {"nature_id_identify", "plantnet_lookup"}:
if not isinstance(tool_args, dict):
tool_args = {}
runtime_image_data = None
if isinstance(request.images, list) and request.images:
first_image = request.images[0]
if isinstance(first_image, str) and first_image.startswith("data:image/") and ";base64," in first_image:
runtime_image_data = first_image
if runtime_image_data:
tool_args["_runtime_image_data"] = runtime_image_data
result = await tool_manager.execute_tool(
tool_name,
tool_args,