fix: prevent stalled tool-call traces after Context Surface errors#27
Open
vishal-bala wants to merge 3 commits into
Open
fix: prevent stalled tool-call traces after Context Surface errors#27vishal-bala wants to merge 3 commits into
vishal-bala wants to merge 3 commits into
Conversation
Co-authored-by: Itay Tevel <itay.tevel@redis.com>
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c21bcc. Configure here.
Co-authored-by: Itay Tevel <itay.tevel@redis.com>
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.

Motivation
Context Surface tool calls could fail in ways that left the UI trace in an unfinished state. In particular, validation failures could emit a tool-call event without a terminal tool-result event, so the frontend kept showing the tool as Running even after the SSE stream had completed.
The Reddash prompt also did not clearly tell the model which argument names Context Surface tools expect. That made it more likely for the model to call filter tools with field-specific keys like
customer_id=instead of the requiredvalue=, or to callsearch_policy_by_textwithout the requiredquery=argument.Changes
Updated the Reddash system prompt to explicitly document Context Surface tool argument conventions. Filter tools now instruct the model to pass a single
valueargument, andsearch_policy_by_textis documented as takingquery. The common workflows were also updated to show the correct call shape.Hardened the SSE bridge so tool traces always receive a terminal state when backend tool execution fails. The stream now handles LangGraph
on_tool_errorevents by emitting a terminaltool-resultwith an error payload and duration, and stream-level exceptions flush any pending tool calls as terminal error results before the finalerroranddoneevents.Configured MCP tool wrappers to return structured JSON for validation errors instead of letting schema failures tear down the stream. This gives the agent a useful tool result and keeps the UI trace consistent.
Updated frontend trace rendering so terminal error results are shown as
Error, and calls that still have no result after stream completion are shown asNo responseinstead of continuing to spin.Additional Changes
on_tool_errorhandling.Note
Medium Risk
Moderate risk because it changes SSE event sequencing and tool run-id bookkeeping used by the UI trace; mistakes could break streaming UX or misattribute tool results.
Overview
Prevents tool traces from getting stuck in a perpetual Running state by hardening the chat SSE bridge to always emit a terminal
tool-result.Backend now tracks pending tool calls, normalizes tool outputs, handles LangGraph
on_tool_errorevents, and flushes any still-pending tool calls as errortool-results before emitting the streamerror/done. MCP tool wrappers also return structured JSON on input validation failures viahandle_validation_error.Updates the Reddash prompt to clarify required tool argument names (
valueforfilter_*tools,queryforsearch_policy_by_text), and updates the frontend trace UI to label tool outcomes as Error or No response (with matching CSS) once the stream completes. Adds regression tests coveringon_tool_error, missingrun_idmatching, pending-tool flushing, and validation error formatting.Reviewed by Cursor Bugbot for commit 819baa9. Bugbot is set up for automated code reviews on this repo. Configure here.