wenjin272 commented on code in PR #1185: URL: https://github.com/apache/flink-agents/pull/1185#discussion_r4237047241
########## python/flink_agents/plan/actions/tool_result_utils.py: ########## @@ -34,6 +34,24 @@ from pydantic import TypeAdapter +from flink_agents.api.tools import ToolResponse + + +def to_tool_response(value: Any) -> ToolResponse: + """Convert ordinary tool returns to text, preserving explicit responses.""" + if isinstance(value, ToolResponse): + return value + try: + text = ( + value + if isinstance(value, str) + else json.dumps(value, ensure_ascii=False, allow_nan=False) + ) + except (TypeError, ValueError) as error: Review Comment: Fixed as suggested: both embedded-resource URI fields now use `str(uri)`, and the generic fallback uses `model_dump(mode="json")`. Added tests for text resources, blob resources and resource links, checking the JSON content after tool-response conversion. This preserves structured JSON output for MCP resources even with the new string fallback for ordinary tool returns. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
