fix(api): correct ToolUse/ToolResult correlation for session display#360
Open
tuzkier wants to merge 2 commits intoRightNow-AI:mainfrom
Open
fix(api): correct ToolUse/ToolResult correlation for session display#360tuzkier wants to merge 2 commits intoRightNow-AI:mainfrom
tuzkier wants to merge 2 commits intoRightNow-AI:mainfrom
Conversation
added 2 commits
March 6, 2026 09:06
Adds a WebSocket-based DingTalk Stream channel adapter as an alternative to the existing webhook-based DingTalk adapter. DingTalk Stream Mode uses a long-lived WebSocket connection to the DingTalk Gateway, eliminating the need for a public webhook endpoint. Changes: - `openfang-types`: add `DingTalkStreamConfig` struct and wire into `ChannelsConfig` alongside the existing `DingTalkConfig` - `openfang-channels`: implement `DingTalkStreamAdapter` (WebSocket connection management, ping/pong, token refresh, send via batchSend API) - `openfang-api`: register `dingtalk_stream` in the channel registry, `is_channel_configured`, and `channel_config_values` - `openfang-api`: wire adapter startup in `channel_bridge.rs` - `openfang-cli`: add `dingtalk_stream` entry to the TUI channels list Configuration: ```toml [channels.dingtalk_stream] app_key_env = "DINGTALK_APP_KEY" # Enterprise Internal App Key app_secret_env = "DINGTALK_APP_SECRET" # Enterprise Internal App Secret robot_code_env = "DINGTALK_ROBOT_CODE" # optional, defaults to app_key ``` Requires an Enterprise Internal App in the DingTalk Open Platform with Stream Mode enabled. No public endpoint needed. Made-with: Cursor
ToolUse and ToolResult live in separate messages (Assistant then User) per Anthropic protocol. The old code tried to attach results to tools in the same message, so ToolResult was silently discarded. Two-pass approach: build tool_use_id→(msg_idx,tool_idx) map, then when processing ToolResult blocks, attach to the correct ToolUse in a previous message. Also adds 'input' field and increases result preview to 2000 chars. Made-with: Cursor
6 tasks
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
In the chat UI, tool calls when expanded show empty content. Tool results were not displayed. This PR fixes the serialization logic in
get_agent_session.Root Cause
Per Anthropic protocol,
ToolUseandToolResultlive in separate messages (Assistant message and User message respectively). The old code tried to attachToolResultto tools in the same message viatools.last_mut(), which was alwaysNonefor User messages.Changes
tool_use_id→(msg_idx, tool_idx)map, then attachToolResultto the correctToolUsein a previous messageinputfield to tool display so expanded view shows call parametersTesting
cargo clippy --workspace --all-targets -- -D warningspassescargo test --workspacepassesSecurity
Notes
get_agent_session