Skip to content

Commit 93ccfac

Browse files
stevehaertelSteve Haertelautofix-ci[bot]jordanrfrazier
authored
feat: stream_tool_updates option to show tool calls in playground chat (langflow-ai#10928)
* feat: add stream_tool_updates option to show tool calls in playground chat - Add stream_tool_updates boolean input to agent configuration - Make stream_tool_updates a keyword-only parameter in event handlers - Update event processing to support real-time tool invocation visibility - Add comprehensive unit tests for stream_tool_updates functionality - Fix linting issues (line length, boolean arguments, whitespace) * Fix AsyncMock lambda parameters in stream_tool_updates tests - Changed lambda parameters from 'skip_db_update' to '**_kwargs' - Fixes TypeError where handlers pass 'skip_db_update' but lambda expected different name - Using underscore prefix to indicate intentionally unused parameter - Affects 6 tests: test_handle_on_tool_start_with_stream_tool_updates_true/false, test_handle_on_tool_end_with_stream_tool_updates, test_handle_on_tool_error_with_stream_tool_updates, test_process_agent_events_with_stream_tool_updates (2 instances), test_handle_on_tool_start_keyword_only_parameter - Addresses CodeRabbitAI feedback on PR * Apply CodeRabbitAI recommendation for AsyncMock lambda parameters - Use explicit 'skip_db_update=False' parameter instead of **_kwargs - Add '# noqa: ARG005, FBT002' to suppress linter warnings - ARG005: Unused lambda argument - FBT002: Boolean default value in function definition - Matches actual parameter name passed by event handlers - Affects 6 tests in test_agent_events.py - Follows CodeRabbitAI's recommended pattern for test mocks * Rebuilt component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Add component index * [autofix.ci] apply automated fixes * Update component index * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * chore: trigger build * [autofix.ci] apply automated fixes * chore: trigger build * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Fix message serialization to correctly include content blocks before sending event * skip db update on tool error * revert events changes * revert agent changes * revert agent changes * revert starter projcets * starter / comp index updates * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * chore: trigger build --------- Co-authored-by: Steve Haertel <shaertel@ca.ibm.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
1 parent 637f653 commit 93ccfac

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/lfx/src/lfx/custom/custom_component/component.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,7 @@ async def send_message(self, message: Message, id_: str | None = None, *, skip_d
16661666
"The message must have been stored in the database previously."
16671667
)
16681668
raise ValueError(msg)
1669+
16691670
# Create a fresh Message instance for consistency with normal flow
16701671
stored_message = await Message.create(**message.model_dump())
16711672
self._stored_message_id = stored_message.get_id()
@@ -1721,9 +1722,15 @@ async def _store_message(self, message: Message) -> Message:
17211722

17221723
async def _send_message_event(self, message: Message, id_: str | None = None, category: str | None = None) -> None:
17231724
if hasattr(self, "_event_manager") and self._event_manager:
1724-
data_dict = message.model_dump()["data"] if hasattr(message, "data") else message.model_dump()
1725-
if id_ and not data_dict.get("id"):
1726-
data_dict["id"] = id_
1725+
# Use full model_dump() to include all Message fields (content_blocks, properties, etc.)
1726+
data_dict = message.model_dump()
1727+
1728+
# The message ID is stored in message.data["id"], which ends up in data_dict["data"]["id"]
1729+
# But the frontend expects it at data_dict["id"], so we need to copy it to the top level
1730+
message_id = id_ or data_dict.get("data", {}).get("id") or getattr(message, "id", None)
1731+
if message_id and not data_dict.get("id"):
1732+
data_dict["id"] = message_id
1733+
17271734
category = category or data_dict.get("category", None)
17281735

17291736
def _send_event():

0 commit comments

Comments
 (0)