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

Co-authored-by: Ryan H. Tran <descience.thh10@gmail.com>
This commit is contained in:
tobitege
2024-09-20 18:31:11 +02:00
committed by GitHub
parent 031b91457a
commit 6682e0f1dd
3 changed files with 17 additions and 2 deletions

View File

@@ -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)

View File

@@ -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>.

View File

@@ -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>.