The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): keep auto vision preprocess concise
gnanirahulnutakkie6b168855b40
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..015c9cd4726--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+gnanirahulnutakkidiff --git a/gateway/run.py b/gateway/run.pyindex 8522d45984a..75f424ef6f6 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -21843,9 +21843,11 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatewfrom agent.memory_manager import sanitize_contextanalysis_prompt = (- "Describe everything visible in this image in thorough detail. "- "Include any text, code, data, objects, people, layout, colors, "- "and any other notable visual information."+ "Concisely describe this image in 2-4 sentences "+ "(~200 Chinese characters or ~150 English words). "+ "Cover the main subject, key visible text/data/code, and overall context. "+ "If it is a chart, diagram, or scientific figure, include the important "+ "labels, legend, and key values. Skip decorative details.")enriched_parts = []diff --git a/tests/gateway/test_vision_preprocess.py b/tests/gateway/test_vision_preprocess.pynew file mode 100644index 00000000000..fb9886f10e9--- /dev/null+++ b/tests/gateway/test_vision_preprocess.py@@ -0,0 +1,34 @@+"""Gateway vision pre-process prompt should stay concise."""++import json+from unittest.mock import AsyncMock, patch++import pytest+++async def test_enrich_message_with_vision_uses_concise_prompt():+ from gateway.run import GatewayRunner++ runner = GatewayRunner.__new__(GatewayRunner)++ with patch(+ "tools.vision_tools.vision_analyze_tool",+ new_callable=AsyncMock,+ return_value=json.dumps({"success": True, "analysis": "A cat on a chair."}),+ ) as mock_vision:+ result = await runner._enrich_message_with_vision(+ user_text="What is happening here?",+ image_paths=["/tmp/cat.png"],+ )++ assert "A cat on a chair." in result+ assert "What is happening here?" in result+ assert (+ "Concisely describe this image in 2-4 sentences"+ in mock_vision.await_args.kwargs["user_prompt"]+ )+ assert "Skip decorative details." in mock_vision.await_args.kwargs["user_prompt"]+ # No output cap is forwarded: per the max-tokens-knob policy the aux+ # client decides token handling; conciseness comes from the prompt.+ assert "max_tokens" not in mock_vision.await_args.kwargs