agent, engine: restore text tool observation path for non-GLM models - #924
Open
vanantwerp wants to merge 1 commit into
Open
agent, engine: restore text tool observation path for non-GLM models#924vanantwerp wants to merge 1 commit into
vanantwerp wants to merge 1 commit into
Conversation
Contributor
|
Hit the same thing independently on an M5 Max with DeepSeek V4 Flash 0731, no |
…-vision Since 4771329 the agent builds every tool observation with ds4_chat_append_multimodal_message, whose guard rejects any model that is not GLM unless a DeepSeek vision encoder is loaded. On a text-only DeepSeek model the observation never builds; agent_tool_observation_fits reports the failure as a context overflow, triggering compaction and ending with 'context full after compaction' on the first tool call. A message with zero images is an ordinary chat message: delegate it to ds4_chat_append_message, keeping the per-family rendering. Add --chat-multimodal-text-only regression test in tests/ds4_test.c. Co-Authored-By: rinaldofesta <festarinaldo@gmail.com>
vanantwerp
force-pushed
the
fix-tool-observation-deepseek
branch
from
September 3, 2026 16:23
97a2bb9 to
f44b32f
Compare
Author
|
Thanks @rinaldofesta! I have rebased onto current |
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.
Summary
Fixes an issue introduced in
47713296dwhere executing any tool inds4-agentunder DeepSeek V4 models immediately failed withds4-agent: context full after compaction.Root Cause
ds4_agent.c:agent_tool_observation_build()was refactored to route all tool observations throughds4_chat_append_multimodal_message().ds4.c,ds4_chat_append_multimodal_message()enforcedif (DS4_MODEL_FAMILY != DS4_MODEL_FAMILY_GLM_DSA) return 0;, failing unconditionally for DeepSeek V4 even on text-only tool results.agent_tool_observation_fits()receivedfalsefrom the failed build and treated it as a context-capacity overflow, triggering context compaction and ultimately reporting a falsecontext full after compactionerror.Changes
ds4.c: Inds4_chat_append_multimodal_message(), handleimage_count == 0by delegating tods4_chat_append_message()so zero-image messages are valid across all model families.ds4_agent.c: Inagent_tool_observation_build(), fast-pathobs->image_count == 0directly tods4_chat_append_message(), avoiding unnecessary heap allocations and keeping the text-only path clean.Validation
ds4-agent -m ds4flash.ggufon web search (google_search) and shell tools (bash), confirming tool execution succeeds without triggering compaction or context errors.make clean && make,make cpu, andmake test(all 8 test suites passed on macOS Metal Apple M5 Max).