Fix agent tool results on text-only DeepSeek engines - #982
Open
zhangjun8823-gif wants to merge 1 commit into
Open
Fix agent tool results on text-only DeepSeek engines#982zhangjun8823-gif wants to merge 1 commit into
zhangjun8823-gif wants to merge 1 commit into
Conversation
agent_tool_observation_build() always appended tool observations via ds4_chat_append_multimodal_message(), which rejects engines that are neither GLM nor DeepSeek-with-vision. On a plain text-only DeepSeek model every tool result append therefore failed; the failure was misread as 'tool result would exceed context', triggering a compaction that could never help and ending in a bogus 'context full after compaction' error that idled the agent. Regression introduced in 4771329 (GLM 5.3 Flash vision support). Fix: when the observation carries no images, append it through the plain ds4_chat_append_message() tool path, as before.
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.
Problem
Since 4771329 ("Add GLM 5.3 Flash vision support"),
agent_tool_observation_build()inds4_agent.cappends every tool observation throughds4_chat_append_multimodal_message(). That function rejects any engine that is neither GLM nor DeepSeek-with-vision:On a plain text-only DeepSeek V4 Flash/Pro engine (no
--visionencoder loaded), every tool result append therefore fails. The failure is swallowed byagent_tool_observation_fits()and misread as "tool result would exceed context", which triggers a context compaction that can never help. After compaction the append still fails, and the agent dies with a bogus error:...even with a 1M-token context and only ~2k tokens in use. The agent then sits idle; tool use (bash, web, file edits) is completely broken on text-only DeepSeek models.
Reproduce
The bash call executes, but appending its observation fails and the run ends with the error above.
Fix
When the observation carries no images, append it through the plain
ds4_chat_append_message()tool path — the same path used before 4771329. The multimodal path is kept for image-carrying observations (GLM / DeepSeek vision engines).Tested
make ds4-agentbuilds warning-free.