@@ -63,15 +63,15 @@ def _resolve_headers(headers: dict[str, str | Secret] | None) -> dict[str, str]
6363 return resolved_headers
6464
6565
66- def extract_first_text_element ( result : str ) -> str | dict [str , Any ]:
66+ def _extract_first_text_element ( tool_call_result : str ) -> str | dict [str , Any ]:
6767 """
68- Return the first text content block from an MCP tool response .
68+ Return the first text content block from an MCP tool call result .
6969
70- MCP tool responses may include mixed content types such as text, image, or
70+ MCP tool call results may include mixed content types such as text, image, or
7171 audio blocks. This helper extracts the first text block because the tool
7272 invoker expects a single parsed payload rather than the full content list.
7373 """
74- parsed : dict = json .loads (result )
74+ parsed : dict = json .loads (tool_call_result )
7575 content : list = parsed .get ("content" , [])
7676 for block in content :
7777 if isinstance (block , dict ) and block .get ("type" ) == "text" :
@@ -1109,7 +1109,7 @@ async def invoke() -> Any:
11091109 # Parse JSON to dict only when outputs_to_state is configured.
11101110 # ToolInvoker requires dict for _merge_tool_outputs(); ToolCallResult.result expects str otherwise.
11111111 if self .outputs_to_state :
1112- return extract_first_text_element (result )
1112+ return _extract_first_text_element (result )
11131113
11141114 return result
11151115 except (MCPError , TimeoutError ) as e :
@@ -1140,7 +1140,7 @@ async def ainvoke(self, **kwargs: Any) -> str | dict[str, Any]:
11401140 # Parse JSON to dict only when outputs_to_state is configured.
11411141 # ToolInvoker requires dict for _merge_tool_outputs(); ToolCallResult.result expects str otherwise.
11421142 if self .outputs_to_state :
1143- return extract_first_text_element (result )
1143+ return _extract_first_text_element (result )
11441144
11451145 return result
11461146 except asyncio .TimeoutError as e :
0 commit comments