10000 Agent update ablation code by nanjiangwill · Pull Request #108 · commit-0/commit0 · GitHub
[go: up one dir, main page]

Skip to content

Agent update ablation code #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pass precommit
  • Loading branch information
nanjiangwill committed Mar 7, 2025
commit 543ef7af656889e68f57b6d4e5567a860cc440e8
9 changes: 7 additions & 2 deletions agent/agent_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ def get_message_function_by_function(
f"Invalid implementation strategy: {agent_config.implementation_strategy}"
)

messages_to_agent = [context + uf for uf in unimplemented_functions]
if agent_config.implementation_strategy == "function_by_function":
messages_to_agent = [context + uf for uf in function_info if len(uf) > 0]
else:
messages_to_agent = []

return messages_to_agent

Expand Down Expand Up @@ -577,7 +580,9 @@ def get_changed_files_from_commits(


def run_eval_after_each_commit(
branch: str, backend: str, commit0_config_file: str, repo_name: str
branch: str,
backend: str,
commit0_config_file: str,
) -> str:
"""Run the eval command after each commit."""
eval_cmd = f"python -m commit0 evaluate --branch {branch} --backend {backend} --commit0-config-file {commit0_config_file} --timeout 100"
Expand Down
20 changes: 10 additions & 10 deletions agent/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import typer
from agent.run_agent_no_rich import run_agent as run_agent_no_rich
from agent.run_agent import run_agent
from commit0.harness.constants import RUN_AGENT_LOG_DIR
import subprocess
Expand Down Expand Up @@ -242,12 +241,13 @@ def run(
display_repo_progress_num,
)
else:
run_agent_no_rich(
branch,
override_previous_changes,
backend,
agent_config_file,
commit0_config_file,
log_dir,
max_parallel_repos,
)
# run_agent_no_rich(
# branch,
# override_previous_changes,
# backend,
# agent_config_file,
# commit0_config_file,
# log_dir,
# max_parallel_repos,
# )
raise NotImplementedError("Currently not supported")
25 changes: 19 additions & 6 deletions agent/run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
get_lint_cmd,
read_yaml_config,
)
from agent.agents import AgentReturn
import json
import subprocess
from agent.agents import AiderAgents
Expand Down Expand Up @@ -62,7 +63,7 @@ def run_agent_multiple_times_on_same_inquiry(
repeat_times_for_each_inquiry: int,
backend: str,
commit0_config_file: str,
) -> None:
) -> AgentReturn | None:
"""Run agent multiple times on the same inquiry and return the best performing agent return"""
if repeat_times_for_each_inquiry == 1:
return agent.run(
Expand All @@ -71,10 +72,9 @@ def run_agent_multiple_times_on_same_inquiry(
else:
commit_before_run = repo.head.commit.hexsha
commit_results = {}
best_commit_diff = None
best_commit_diff = ""
best_eval_result = float("-inf")
best_agent_return = None

for attempt in range(repeat_times_for_each_inquiry):
agent_return = agent.run(
message,
Expand Down Expand Up @@ -221,6 +221,7 @@ def run_agent_for_repo(
if agent_config is None:
raise ValueError("Invalid input")

agent_return = None
if agent_config.run_tests:
update_queue.put(("start_repo", (repo_name, len(test_files))))
# when unit test feedback is available, iterate over test files
Expand Down Expand Up @@ -260,7 +261,11 @@ def run_agent_for_repo(
update_queue.put(
(
"update_money_display",
(repo_name, test_file, agent_return.last_cost),
(
repo_name,
test_file,
agent_return.last_cost if agent_return is not None else 0,
),
)
)
elif agent_config.run_entire_dir_lint:
Expand Down Expand Up @@ -300,7 +305,11 @@ def run_agent_for_repo(
update_queue.put(
(
"update_money_display",
(repo_name, lint_file, agent_return.last_cost),
(
repo_name,
lint_file,
agent_return.last_cost if agent_return is not None else 0,
),
)
)
else:
Expand Down Expand Up @@ -373,7 +382,11 @@ def run_agent_for_repo(
update_queue.put(
(
"update_money_display",
(repo_name, file_name, agent_return.last_cost),
(
repo_name,
file_name,
agent_return.last_cost if agent_return is not None else 0,
),
)
)
if agent_config.record_test_for_each_commit:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies = [
"strenum>=0.4.15",
"e2b-code-interpreter>=1.0.4",
"python-dotenv>=1.0.1",
"rank_bm25>=0.2.1",
]
classifiers = [
"License :: OSI Approved :: MIT License",
Expand Down
Loading
0