Просмотр исходного кода

(fix) CodeActAgent: use `content` of AgentDelegateObservation (#3970)

Co-authored-by: Ryan H. Tran <descience.thh10@gmail.com>
tobitege 1 год назад
Родитель
Сommit
6682e0f1dd

+ 4 - 1
agenthub/codeact_agent/codeact_agent.py

@@ -153,7 +153,10 @@ class CodeActAgent(Agent):
             text = truncate_content(text, max_message_chars)
             return Message(role='user', content=[TextContent(text=text)])
         elif isinstance(obs, AgentDelegateObservation):
-            text = obs_prefix + truncate_content(str(obs.outputs), max_message_chars)
+            text = obs_prefix + truncate_content(
+                obs.outputs['content'] if 'content' in obs.outputs else '',
+                max_message_chars,
+            )
             return Message(role='user', content=[TextContent(text=text)])
         elif isinstance(obs, ErrorObservation):
             text = obs_prefix + truncate_content(obs.content, max_message_chars)

+ 6 - 0
tests/integration/mock/eventstream_runtime/CodeActAgent/test_browse_internet/prompt_001.log

@@ -402,7 +402,13 @@ The server is running on port 5000 with PID 126. You can access the list of numb
 
 
 NOW, LET'S START!
+
+----------
+
 Browse localhost:8000, and tell me the ultimate answer to life. Do not ask me for confirmation at any point.
 
+----------
+
+
 
 ENVIRONMENT REMINDER: You have 19 turns left to complete the task. When finished reply with <finish></finish>.

+ 7 - 1
tests/integration/mock/eventstream_runtime/CodeActAgent/test_browse_internet/prompt_005.log

@@ -402,6 +402,9 @@ The server is running on port 5000 with PID 126. You can access the list of numb
 
 
 NOW, LET'S START!
+
+----------
+
 Browse localhost:8000, and tell me the ultimate answer to life. Do not ask me for confirmation at any point.
 
 ----------
@@ -414,7 +417,10 @@ Browse localhost:8000, and tell me the ultimate answer to life. Do not ask me fo
 ----------
 
 OBSERVATION:
-{'content': 'The answer to life, the universe, and everything has been revealed: OpenHands is all you need!'}
+The answer to life, the universe, and everything has been revealed: OpenHands is all you need!
+
+----------
+
 
 
 ENVIRONMENT REMINDER: You have 13 turns left to complete the task. When finished reply with <finish></finish>.