@@ -82,7 +82,7 @@ def extract_text_content_from_content_dict(self, msg):
8282 # },
8383 # ],
8484 # }
85- # or tool_result format:
85+ # or tool_result format?? not observed yet :
8686 # msg = {
8787 # "role": "tool",
8888 # "content": [
@@ -97,31 +97,27 @@ def extract_text_content_from_content_dict(self, msg):
9797
9898 str_content = ""
9999 for item in msg ["content" ]:
100- assert isinstance (item , dict ), f"Unsupported non-dict item in message content: { item } . Full message: { msg } "
101-
100+ # item = {
101+ # "type": "text",
102+ # "text": "some text"
103+ # },
102104 item_type = item .get ("type" , "" )
105+ assert not item_type == "tool_use" , f"never observed such protocal yet"
106+ assert not item_type == "tool_result" , f"never observed such protocal yet"
103107
104- # Handle text content block
105- if "text" in item :
106- if isinstance (item ["text" ], str ):
107- str_content += item ["text" ]
108- # Handle tool_result content block (AgentScope format)
109- elif item_type == "tool_result" and "output" in item :
110- output = item ["output" ]
111- if isinstance (output , str ):
112- str_content += output
113- else :
114- str_content += str (output )
115- # Handle tool_use content block (for completeness)
116- elif item_type == "tool_use" :
117- # tool_use blocks are handled via tool_calls field, skip content extraction
118- continue
119- else :
108+ assert isinstance (item , dict ), f"Unsupported non-dict item in message content: { item } . Full message: { msg } "
109+
110+ if ("text" not in item ):
120111 logger .warning (
121- f"Non-text content in message content detected: { item } . Ignoring this item ."
112+ f"Non-text content in message content detected: { item } . Ignoring."
122113 )
123- # Continue processing other items instead of skipping the entire message
124- continue
114+ should_skip_message = True
115+ return str_content , should_skip_message
116+
117+ if isinstance (item ["text" ], str ):
118+ str_content += str (item ["text" ])
119+ else :
120+ str_content = ""
125121
126122 should_skip_message = False
127123 return str_content , should_skip_message
0 commit comments