mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
CodeActAgent: Fix iteration reminder (#1803)
This PR includes three changes: 1) Iteration reminder should start with MAX_ITERATIONS from config rather than default value 100 2) In the first prompt, we should tell the LLM it has `MAX_ITERATIONS - 1` turns left, rather than `MAX_ITERATIONS - 2` 3) Remove legacy ITERATION_REMINDER config
This commit is contained in:
parent
d1fd277ad4
commit
6714000b2c
1
.github/workflows/run-integration-tests.yml
vendored
1
.github/workflows/run-integration-tests.yml
vendored
@ -57,7 +57,6 @@ jobs:
|
||||
AGENT: ${{ matrix.agent }}
|
||||
MAX_ITERATIONS: 10
|
||||
LLM_EMBEDDING_MODEL: ${{ matrix.embedding-model }}
|
||||
REMIND_ITERATIONS: ${{ (matrix.agent == 'CodeActAgent') && 'true' || 'false' }}
|
||||
run: |
|
||||
rm -rf workspace
|
||||
mkdir workspace
|
||||
|
||||
@ -209,7 +209,7 @@ class CodeActAgent(Agent):
|
||||
latest_user_message = [m for m in self.messages if m['role'] == 'user'][-1]
|
||||
if latest_user_message:
|
||||
latest_user_message['content'] += (
|
||||
f'\n\nENVIRONMENT REMINDER: You have {state.max_iterations - state.iteration - 1} turns left to complete the task.'
|
||||
f'\n\nENVIRONMENT REMINDER: You have {state.max_iterations - state.iteration} turns left to complete the task.'
|
||||
)
|
||||
|
||||
response = self.llm.completion(
|
||||
|
||||
@ -68,7 +68,7 @@ class AgentController:
|
||||
"""
|
||||
self.id = sid
|
||||
self.agent = agent
|
||||
self.state = State(inputs=inputs or {})
|
||||
self.state = State(inputs=inputs or {}, max_iterations=max_iterations)
|
||||
self.event_stream = event_stream
|
||||
self.event_stream.subscribe(
|
||||
EventStreamSubscriber.AGENT_CONTROLLER, self.on_event
|
||||
|
||||
@ -31,7 +31,6 @@ class ConfigType(str, Enum):
|
||||
AGENT_MEMORY_MAX_THREADS = 'AGENT_MEMORY_MAX_THREADS'
|
||||
AGENT_MEMORY_ENABLED = 'AGENT_MEMORY_ENABLED'
|
||||
MAX_ITERATIONS = 'MAX_ITERATIONS'
|
||||
REMIND_ITERATIONS = 'REMIND_ITERATIONS'
|
||||
MAX_CHARS = 'MAX_CHARS'
|
||||
AGENT = 'AGENT'
|
||||
E2B_API_KEY = 'E2B_API_KEY'
|
||||
|
||||
@ -224,4 +224,4 @@ NOW, LET'S START!
|
||||
|
||||
Fix typos in bad.txt. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
@ -224,7 +224,7 @@ NOW, LET'S START!
|
||||
|
||||
Fix typos in bad.txt. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
----------
|
||||
|
||||
@ -244,4 +244,4 @@ OBSERVATION:
|
||||
4:Enjoy!
|
||||
[Command -1 finished with exit code 0]]
|
||||
|
||||
ENVIRONMENT REMINDER: You have 97 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
|
||||
@ -224,7 +224,7 @@ NOW, LET'S START!
|
||||
|
||||
Fix typos in bad.txt. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
----------
|
||||
|
||||
@ -244,7 +244,7 @@ OBSERVATION:
|
||||
4:Enjoy!
|
||||
[Command -1 finished with exit code 0]]
|
||||
|
||||
ENVIRONMENT REMINDER: You have 97 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
|
||||
----------
|
||||
|
||||
@ -276,4 +276,4 @@ File updated. Please review the changes and make sure they are correct (correct
|
||||
File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.
|
||||
[Command -1 finished with exit code 0]]
|
||||
|
||||
ENVIRONMENT REMINDER: You have 96 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 7 turns left to complete the task.
|
||||
|
||||
@ -224,4 +224,4 @@ NOW, LET'S START!
|
||||
|
||||
Use Jupyter IPython to write a text file containing 'hello world' to '/workspace/test.txt'. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
@ -224,7 +224,7 @@ NOW, LET'S START!
|
||||
|
||||
Use Jupyter IPython to write a text file containing 'hello world' to '/workspace/test.txt'. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
----------
|
||||
|
||||
@ -241,4 +241,4 @@ with open('/workspace/test.txt', 'w') as file:
|
||||
OBSERVATION:
|
||||
[Code executed successfully with no output]
|
||||
|
||||
ENVIRONMENT REMINDER: You have 97 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
|
||||
@ -224,4 +224,4 @@ NOW, LET'S START!
|
||||
|
||||
Write a shell script 'hello.sh' that prints 'hello'. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
@ -224,7 +224,7 @@ NOW, LET'S START!
|
||||
|
||||
Write a shell script 'hello.sh' that prints 'hello'. Do not ask me for confirmation at any point.
|
||||
|
||||
ENVIRONMENT REMINDER: You have 98 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 9 turns left to complete the task.
|
||||
|
||||
----------
|
||||
|
||||
@ -240,4 +240,4 @@ OBSERVATION:
|
||||
|
||||
[Command -1 finished with exit code 0]]
|
||||
|
||||
ENVIRONMENT REMINDER: You have 97 turns left to complete the task.
|
||||
ENVIRONMENT REMINDER: You have 8 turns left to complete the task.
|
||||
|
||||
@ -4,7 +4,6 @@ set -eo pipefail
|
||||
run_test() {
|
||||
SANDBOX_TYPE=$SANDBOX_TYPE \
|
||||
WORKSPACE_BASE=$WORKSPACE_BASE \
|
||||
REMIND_ITERATIONS=$remind_iterations \
|
||||
MAX_ITERATIONS=$MAX_ITERATIONS \
|
||||
WORKSPACE_MOUNT_PATH=$WORKSPACE_MOUNT_PATH \
|
||||
AGENT=$agent \
|
||||
@ -27,7 +26,6 @@ SANDBOX_TYPE="ssh"
|
||||
MAX_ITERATIONS=10
|
||||
|
||||
agents=("MonologueAgent" "CodeActAgent" "PlannerAgent" "SWEAgent")
|
||||
remind_iterations_config=(false true false false)
|
||||
tasks=(
|
||||
"Fix typos in bad.txt."
|
||||
"Write a shell script 'hello.sh' that prints 'hello'."
|
||||
@ -42,11 +40,6 @@ test_names=(
|
||||
num_of_tests=${#test_names[@]}
|
||||
num_of_agents=${#agents[@]}
|
||||
|
||||
if [ "$num_of_agents" -ne "${#remind_iterations_config[@]}" ]; then
|
||||
echo "Every agent must have its own remind_iterations_config"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$num_of_tests" -ne "${#test_names[@]}" ]; then
|
||||
echo "Every task must correspond to one test case"
|
||||
exit 1
|
||||
@ -109,9 +102,6 @@ for ((i = 0; i < num_of_tests; i++)); do
|
||||
WORKSPACE_BASE=$WORKSPACE_BASE \
|
||||
DEBUG=true \
|
||||
WORKSPACE_MOUNT_PATH=$WORKSPACE_MOUNT_PATH AGENT=$agent \
|
||||
REMIND_ITERATIONS=$remind_iterations \
|
||||
WORKSPACE_MOUNT_PATH=$WORKSPACE_MOUNT_PATH \
|
||||
AGENT=$agent \
|
||||
poetry run python ./opendevin/core/main.py \
|
||||
-i $MAX_ITERATIONS \
|
||||
-t "$task Do not ask me for confirmation at any point." \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user