fix(agent): keep image tool results from poisoning text-only sessions#25903
Closed
helix4u wants to merge 1 commit into
Closed
fix(agent): keep image tool results from poisoning text-only sessions#25903helix4u wants to merge 1 commit into
helix4u wants to merge 1 commit into
Conversation
ec5ae8b to
ae3e796
Compare
Contributor
|
Merged via #25925 — your commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Prevents
computer_usescreenshot results from poisoning text-only model sessions.When
computer_usereturns a screenshot result while the active model/provider does not support image input, Hermes now stores a clean tool error instead of appending rawimage_urlcontent to the canonical conversation history. That avoids the repeated 400 loop where every later user turn resends the rejected image message before the agent can recover.This is intentionally narrower than the existing provider-profile image fallback PRs. It does not try to make a text-only model operate the desktop from an auxiliary vision description; it fails cleanly and tells the model/user to switch to a vision-capable model for desktop computer use.
Related Issue
Related: #23733
Related but not duplicate:
computer_usecaptures throughauxiliary.vision; this PR takes the safer text-only behavior for desktop control by returning a tool error instead of giving the main text-only model a generated screenshot description to act on.Type of Change
Changes Made
run_agent.py: added_tool_result_content_for_active_model()so multimodal tool results are adapted before they enter session history.run_agent.py: convertscomputer_usescreenshot results into a clear tool error for text-only active models/providers.run_agent.py: preserves screenshot/image tool results for vision-capable active models.run_agent.py: recognizes DeepSeek's exact text-only image rejection wording in adaptive recovery.tests/tools/test_computer_use.py: covers text-only and vision-capable handling forcomputer_usemultimodal results.How to Test
computer_usewith a text-only OpenAI-compatible provider such as direct DeepSeek.image_urltool result.Targeted tests run locally:
pytest -q tests/tools/test_computer_use.py::TestRunAgentMultimodalHelpers tests/run_agent/test_vision_aware_preprocessing.pyResult:
19 passed in 2.89sFull suite run locally:
scripts/run_tests.shResult: failed in
0:11:36with62 failed, 22918 passed, 61 skipped, 244 warnings, 19 errors.The full-suite failures/errors are broad existing/global areas outside this PR's two touched files. Examples include
tests/cli/test_cli_save_config_value.py,tests/agent/lsp/test_client_e2e.py,tests/gateway/test_approve_deny_commands.py,tests/run_agent/test_compression_feasibility.py, process/terminal timeout cleanup tests, andtests/tools/test_browser_supervisor.pyteardown errors from the live-system guard blockingos.kill(...)on spawned Chrome PIDs.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A
Screenshots / Logs
Support repro showed direct DeepSeek rejecting the post-
computer_userequest with:messages[10]: unknown variant image_url, expected text