This is an automated email from the ASF dual-hosted git repository.

sxnan pushed a commit to branch release-0.1
in repository https://gitbox.apache.org/repos/asf/flink-agents.git


The following commit(s) were added to refs/heads/release-0.1 by this push:
     new 3b30e56  [hotfix] Fix the type mismatch issue in the format_messages 
method (#322)
3b30e56 is described below

commit 3b30e5694efb5ca8788a5e244c97b401a4b6f9b5
Author: Eugene <[email protected]>
AuthorDate: Thu Nov 20 09:43:28 2025 +0800

    [hotfix] Fix the type mismatch issue in the format_messages method (#322)
---
 python/flink_agents/api/agents/react_agent.py              | 4 +++-
 python/flink_agents/api/chat_models/chat_model.py          | 4 +++-
 python/flink_agents/runtime/tests/test_built_in_actions.py | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/python/flink_agents/api/agents/react_agent.py 
b/python/flink_agents/api/agents/react_agent.py
index 67cb0df..a637ec5 100644
--- a/python/flink_agents/api/agents/react_agent.py
+++ b/python/flink_agents/api/agents/react_agent.py
@@ -217,7 +217,9 @@ class ReActAgent(Agent):
                 usr_input = usr_input.as_dict(recursive=True)
             else:  # regard as pojo
                 usr_input = usr_input.__dict__
-            usr_msgs = prompt.format_messages(role=MessageRole.USER, 
**usr_input)
+            # Convert Any values to str to match format_messages signature
+            str_usr_input = {k: str(v) for k, v in usr_input.items()}
+            usr_msgs = prompt.format_messages(role=MessageRole.USER, 
**str_usr_input)
 
         try:
             schema_prompt = cast(
diff --git a/python/flink_agents/api/chat_models/chat_model.py 
b/python/flink_agents/api/chat_models/chat_model.py
index 5a0671a..9614edd 100644
--- a/python/flink_agents/api/chat_models/chat_model.py
+++ b/python/flink_agents/api/chat_models/chat_model.py
@@ -185,7 +185,9 @@ class BaseChatModelSetup(Resource):
 
             # fill the prompt template
             for msg in messages:
-                input_variable.update(msg.extra_args)
+                # Convert Any values to str to match format_messages signature
+                str_extra_args = {k: str(v) for k, v in msg.extra_args.items()}
+                input_variable.update(str_extra_args)
             prompt_messages = prompt.format_messages(**input_variable)
 
             # append meaningful messages
diff --git a/python/flink_agents/runtime/tests/test_built_in_actions.py 
b/python/flink_agents/runtime/tests/test_built_in_actions.py
index 74a72ac..560a625 100644
--- a/python/flink_agents/runtime/tests/test_built_in_actions.py
+++ b/python/flink_agents/runtime/tests/test_built_in_actions.py
@@ -94,7 +94,9 @@ class MockChatModel(BaseChatModelSetup):
             if "sum" in messages[-1].content:
                 input_variable = {}
                 for msg in messages:
-                    input_variable.update(msg.extra_args)
+                    # Convert Any values to str to match format_messages 
signature
+                    str_extra_args = {k: str(v) for k, v in 
msg.extra_args.items()}
+                    input_variable.update(str_extra_args)
                 messages = prompt.format_messages(**input_variable)
 
         # Bind tools

Reply via email to