Skip to content

Commit 89e6c15

Browse files
Merge pull request #78 from Grigorij-Dudnik/dev
release 0.3.11
2 parents 2222d7b + fdf3f2a commit 89e6c15

File tree

14 files changed

+126
-346
lines changed

14 files changed

+126
-346
lines changed

manager.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
from langchain_core.load import dumps
1818
from langgraph.graph import StateGraph
1919
from src.tools.tools_project_manager import add_task, modify_task, finish_project_planning, reorder_tasks
20-
from src.tools.tools_coder_pipeline import prepare_list_dir_tool, prepare_see_file_tool, ask_human_tool, retrieve_files_by_semantic_query
20+
from src.tools.tools_coder_pipeline import (
21+
prepare_list_dir_tool, prepare_see_file_tool, see_image,
22+
ask_human_tool, retrieve_files_by_semantic_query
23+
)
2124
from src.tools.rag.index_file_descriptions import prompt_index_project_files
22-
from src.utilities.util_functions import save_state_history_to_disk, join_paths
25+
from src.utilities.util_functions import save_state_history_to_disk, join_paths, convert_image
2326
from src.utilities.manager_utils import (
2427
actualize_tasks_list_and_progress_description,
2528
setup_todoist_project_if_needed,
@@ -83,6 +86,9 @@ def call_model_manager(self, state):
8386
state = call_tool(state, self.tools)
8487
if len(last_ai_message.tool_calls) == 0:
8588
state["messages"].append(HumanMessage(content=no_tools_msg))
89+
for tool_call in last_ai_message.tool_calls:
90+
if tool_call["name"] == "see_image":
91+
state["messages"].append(HumanMessage(content=convert_image(tool_call["args"]["filename"])))
8692
state = actualize_tasks_list_and_progress_description(state)
8793
return state
8894

@@ -96,6 +102,10 @@ def after_agent_condition(self, state):
96102

97103
# just functions
98104
def cut_off_context(self, state):
105+
"""
106+
Trims the message history in the state to keep only the most recent context for the agent.
107+
Keeps the last ~30 messages, starting from the most recent 'ai' message, and always includes the system message at the beginning.
108+
"""
99109
approx_nr_msgs_to_save = 30
100110
if len(state["messages"]) > approx_nr_msgs_to_save:
101111
last_messages = state["messages"][-approx_nr_msgs_to_save:]
@@ -134,6 +144,7 @@ def prepare_tools(self):
134144
finish_project_planning,
135145
list_dir,
136146
see_file,
147+
see_image,
137148
]
138149
if vdb_available():
139150
tools.append(retrieve_files_by_semantic_query)

non_src/assets/logo_wide_2.png

-73.3 KB
Binary file not shown.

non_src/tests/manual_tests/executor_scenario1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
load_dotenv(find_dotenv())
1313

1414
folder_with_project_files = repo_directory.joinpath(
15-
"non_src/tests/manual_tests/projects_files", "debugger_scenario_1_files"
15+
"non_src/tests/manual_tests/projects_files", "executoro"
16+
"_scenario_1_files"
1617
)
1718
tmp_folder = pathlib.Path(__file__).parent.resolve().joinpath("sandbox_work_dir")
1819
setup_work_dir(manual_tests_folder=tmp_folder, test_files_dir=folder_with_project_files)

src/agents/debugger_agent.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
read_coderrules,
2222
convert_images,
2323
list_directory_tree,
24+
exchange_file_contents,
25+
TOOL_NOT_EXECUTED_WORD,
2426
)
2527
from src.utilities.llms import init_llms_medium_intelligence
2628
from src.utilities.langgraph_common_functions import (
@@ -106,6 +108,10 @@ def call_model_debugger(self, state):
106108
new_file = CodeFile(tool_call["args"]["filename"], is_modified=True)
107109
self.files.add(new_file)
108110
elif tool_call["name"] in ["replace_code", "insert_code"]:
111+
last_tool_message = [msg for msg in state["messages"] if msg.type == "tool"][-1]
112+
# do not mark as modified if tool was not executed
113+
if last_tool_message.content.startswith(TOOL_NOT_EXECUTED_WORD):
114+
continue
109115
filename = tool_call["args"]["filename"]
110116
for file in self.files:
111117
if file.filename == filename:
@@ -117,6 +123,7 @@ def call_model_debugger(self, state):
117123
if analysis_result:
118124
state["messages"].append(HumanMessage(content=analysis_result))
119125

126+
state = exchange_file_contents(state, self.files, self.work_dir)
120127

121128
return state
122129

src/agents/executor_agent.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from langchain.tools import tool
1313
from src.utilities.llms import init_llms_medium_intelligence
1414
from src.utilities.print_formatters import print_formatted
15-
from src.utilities.util_functions import check_file_contents, exchange_file_contents, bad_tool_call_looped, load_prompt
15+
from src.utilities.util_functions import check_file_contents, exchange_file_contents, bad_tool_call_looped, load_prompt, TOOL_NOT_EXECUTED_WORD
1616
from src.utilities.langgraph_common_functions import (
1717
call_model,
1818
call_tool,
@@ -71,8 +71,8 @@ def call_model_executor(self, state):
7171
state = call_tool(state, self.tools)
7272

7373
# auxiliary actions depending on tools called
74-
messages = [msg for msg in state["messages"] if msg.type == "ai"]
75-
last_ai_message = messages[-1]
74+
ai_messages = [msg for msg in state["messages"] if msg.type == "ai"]
75+
last_ai_message = ai_messages[-1]
7676
if len(last_ai_message.tool_calls) > 1:
7777
for tool_call in last_ai_message.tool_calls:
7878
state["messages"].append(ToolMessage(content="too much tool calls", tool_call_id=tool_call["id"]))
@@ -84,6 +84,10 @@ def call_model_executor(self, state):
8484
new_file = CodeFile(tool_call["args"]["filename"], is_modified=True)
8585
self.files.add(new_file)
8686
elif tool_call["name"] in ["replace_code", "insert_code"]:
87+
last_tool_message = [msg for msg in state["messages"] if msg.type == "tool"][-1]
88+
# do not mark as modified if tool was not executed
89+
if last_tool_message.content.startswith(TOOL_NOT_EXECUTED_WORD):
90+
continue
8791
filename = tool_call["args"]["filename"]
8892
for file in self.files:
8993
if file.filename == filename:

src/linters/static_analisys.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ def python_static_analysis(files):
1818
return outputs
1919

2020

21+
def js_ts_static_analysis(files):
22+
outputs = ""
23+
for file in files:
24+
command = [
25+
"npx",
26+
"biome",
27+
"check",
28+
join_paths(os.getenv("WORK_DIR"), file.filename),
29+
#"--config-path", "src/linters/biome-config.json" # only if you want non-default settings
30+
]
31+
result = subprocess.run(command, capture_output=True, text=True, encoding="utf-8")
32+
if result.stdout.strip() != "All checks passed!":
33+
outputs += f"\n\n---\n{file.filename}:\n\n{result.stdout}"
34+
35+
return outputs
36+
2137
# Print results
2238
# print("STDOUT:", result.stdout)
2339
# print("STDERR:", result.stderr)

src/prompts/manager_system.prompt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ When you unsure how some feature need to be implemented, ask human.
33

44
Make good file research before creating a task to understand how to implement task the best and to describe it in all details.
55

6-
Tasks you are creating are always very concrete and concise, showing programmer how he can implement the change. If you unsure which technologies to use, ask human.
7-
Hovewer, do not write code in your task, just overview from above.
6+
Tasks you are creating are always very concrete and concise, showing programmer how he can implement the change. If you unsure which technologies to use, ask human first.
87
Avoid creating flaky tasks, where it's unclear how to do task and if it is needed at all.
98

10-
Never make up information when describing task. Ask human or make file research to get more info instead.
9+
- Never make up information when describing task. Ask human or make file research to get more info instead.
10+
- Do not write code inside of the task - it's job of programmer.
1111

1212

1313
Here is description of changes in the project you work on:
@@ -20,7 +20,3 @@ Some important project informations and rules:
2020
'''
2121
{project_rules}
2222
'''
23-
24-
First, provide step by step reasoning about what do you need to find in order to accomplish the task. Ensure, you have
25-
long and thoughtful reasoning before every tool call. Remember, you are brain worker.
26-
Next, call appropriate tool.

0 commit comments

Comments
 (0)