mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
feat: add max_budget_per_task configuration to control task cost (#2070)
* feat: add max_budget_per_task configuration to control task cost * Fix test_arg_parser.py * Use the config.max_budget_per_task as default value * Add max_budget_per_task to core/main.py as well * Update opendevin/controller/agent_controller.py Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk> --------- Co-authored-by: Boxuan Li <liboxuan@connect.hku.hk>
This commit is contained in:
@@ -10,8 +10,8 @@ def test_help_message(capsys):
|
||||
captured = capsys.readouterr()
|
||||
expected_help_message = """
|
||||
usage: pytest [-h] [-d DIRECTORY] [-t TASK] [-f FILE] [-c AGENT_CLS]
|
||||
[-m MODEL_NAME] [-i MAX_ITERATIONS] [-n MAX_CHARS]
|
||||
[--eval-output-dir EVAL_OUTPUT_DIR]
|
||||
[-m MODEL_NAME] [-i MAX_ITERATIONS] [-b MAX_BUDGET_PER_TASK]
|
||||
[-n MAX_CHARS] [--eval-output-dir EVAL_OUTPUT_DIR]
|
||||
[--eval-n-limit EVAL_N_LIMIT]
|
||||
[--eval-num-workers EVAL_NUM_WORKERS] [--eval-note EVAL_NOTE]
|
||||
[-l LLM_CONFIG]
|
||||
@@ -31,6 +31,9 @@ options:
|
||||
The (litellm) model name to use
|
||||
-i MAX_ITERATIONS, --max-iterations MAX_ITERATIONS
|
||||
The maximum number of iterations to run the agent
|
||||
-b MAX_BUDGET_PER_TASK, --max-budget-per-task MAX_BUDGET_PER_TASK
|
||||
The maximum budget allowed per task, beyond which the
|
||||
agent will stop.
|
||||
-n MAX_CHARS, --max-chars MAX_CHARS
|
||||
The maximum number of characters to send to and
|
||||
receive from LLM per task
|
||||
|
||||
@@ -285,3 +285,20 @@ def test_api_keys_repr_str():
|
||||
assert (
|
||||
'token' not in attr_name.lower() or 'tokens' in attr_name.lower()
|
||||
), f"Unexpected attribute '{attr_name}' contains 'token' in AppConfig"
|
||||
|
||||
|
||||
def test_max_iterations_and_max_budget_per_task_from_toml(temp_toml_file):
|
||||
temp_toml = """
|
||||
[core]
|
||||
max_iterations = 100
|
||||
max_budget_per_task = 4.0
|
||||
"""
|
||||
|
||||
config = AppConfig()
|
||||
with open(temp_toml_file, 'w') as f:
|
||||
f.write(temp_toml)
|
||||
|
||||
load_from_toml(config, temp_toml_file)
|
||||
|
||||
assert config.max_iterations == 100
|
||||
assert config.max_budget_per_task == 4.0
|
||||
|
||||
Reference in New Issue
Block a user