You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
normalize json before deduplicating in ToolEngine.tool_response_to_str #42195
existing_parts is built from the TEXT/LINK/etc. messages as raw strings, and each entry in json_parts is checked against that set with plain string equality. For MCP tools, MCPTool._process_text_content parses the tool's raw text output and re-emits it as a JSON message when it looks like a JSON object or array [2]. So the same data can appear twice: the tool's original compact JSON as text, and the reformatted json.dumps(...) output from the JSON message. Different whitespace or key order makes the two strings byte-for-byte distinct, the set membership check misses, and both land in the observation.
Prior duplicate-output fixes in this function [3][4][5] covered cases like VARIABLE messages and workflow-as-tool JSON/text pairs, but all of them compare raw strings too. Catching compact vs. pretty-printed JSON requires canonicalizing first — json.loads then re-dumps with sorted keys, or comparing the parsed objects directly — which the current implementation doesn't do.
Want me to sketch a fix that parses JSON-looking text parts before building existing_parts?
Activity
dosubot commentedon Sep 11, 2026
Confirmed — the dedup in
ToolEngine.tool_response_to_strcompares raw strings rather than parsed structures [1]:existing_partsis built from the TEXT/LINK/etc. messages as raw strings, and each entry injson_partsis checked against that set with plain string equality. For MCP tools,MCPTool._process_text_contentparses the tool's raw text output and re-emits it as aJSONmessage when it looks like a JSON object or array [2]. So the same data can appear twice: the tool's original compact JSON as text, and the reformattedjson.dumps(...)output from the JSON message. Different whitespace or key order makes the two strings byte-for-byte distinct, the set membership check misses, and both land in the observation.Prior duplicate-output fixes in this function [3] [4] [5] covered cases like VARIABLE messages and workflow-as-tool JSON/text pairs, but all of them compare raw strings too. Catching compact vs. pretty-printed JSON requires canonicalizing first —
json.loadsthen re-dumpswith sorted keys, or comparing the parsed objects directly — which the current implementation doesn't do.Want me to sketch a fix that parses JSON-looking text parts before building
existing_parts?To reply, just mention @dosu.
Docs are dead. Just use Dosu.