Skip to content

Commit

Permalink
Merge pull request #1052 from Pythagora-io/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
LeonOstrez authored Jul 12, 2024
2 parents aed454a + 4fd5ed5 commit cf61a96
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
4 changes: 3 additions & 1 deletion core/agents/code_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ async def implement_changes(self) -> AgentResponse:
user_feedback_qa = None
llm = self.get_llm()

if iterations:
if "task_review_feedback" in task and task["task_review_feedback"]:
instructions = task.get("task_review_feedback")
elif iterations:
last_iteration = iterations[-1]
instructions = last_iteration.get("description")
user_feedback = last_iteration.get("user_feedback")
Expand Down
41 changes: 27 additions & 14 deletions core/agents/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,27 @@ async def run(self) -> AgentResponse:

return await self.breakdown_current_task()

async def breakdown_current_iteration(self, review_feedback: Optional[str] = None) -> AgentResponse:
async def breakdown_current_iteration(self, task_review_feedback: Optional[str] = None) -> AgentResponse:
"""
Breaks down current iteration or task review into steps.
:param review_feedback: If provided, the task review feedback is broken down instead of the current iteration
:param task_review_feedback: If provided, the task review feedback is broken down instead of the current iteration
:return: AgentResponse.done(self) when the breakdown is done
"""
current_task = self.current_state.current_task

if review_feedback is not None:
if task_review_feedback is not None:
iteration = None
description = review_feedback
current_task["task_review_feedback"] = task_review_feedback
description = task_review_feedback
user_feedback = ""
source = "review"
n_tasks = 1
log.debug(f"Breaking down the task review feedback {review_feedback}")
log.debug(f"Breaking down the task review feedback {task_review_feedback}")
await self.send_message("Breaking down the task review feedback...")
else:
iteration = self.current_state.current_iteration
current_task["task_review_feedback"] = None
if iteration is None:
log.error("Iteration breakdown called but there's no current iteration or task review, possible bug?")
return AgentResponse.done(self)
Expand All @@ -125,7 +128,7 @@ async def breakdown_current_iteration(self, review_feedback: Optional[str] = Non
await self.ui.send_task_progress(
n_tasks, # iterations and reviews can be created only one at a time, so we are always on last one
n_tasks,
self.current_state.current_task["description"],
current_task["description"],
source,
"in-progress",
self.current_state.get_source_index(source),
Expand All @@ -138,7 +141,7 @@ async def breakdown_current_iteration(self, review_feedback: Optional[str] = Non
AgentConvo(self)
.template(
"iteration",
current_task=self.current_state.current_task,
current_task=current_task,
user_feedback=user_feedback,
user_feedback_qa=None,
next_solution_to_try=None,
Expand All @@ -158,39 +161,49 @@ async def breakdown_current_iteration(self, review_feedback: Optional[str] = Non
else:
self.next_state.action = "Task review feedback"

current_task_index = self.current_state.tasks.index(current_task)
self.next_state.tasks[current_task_index] = {
**current_task,
}
self.next_state.flag_tasks_as_modified()
return AgentResponse.done(self)

async def breakdown_current_task(self) -> AgentResponse:
task = self.current_state.current_task
current_task = self.current_state.current_task
current_task["task_review_feedback"] = None
source = self.current_state.current_epic.get("source", "app")
await self.ui.send_task_progress(
self.current_state.tasks.index(self.current_state.current_task) + 1,
self.current_state.tasks.index(current_task) + 1,
len(self.current_state.tasks),
self.current_state.current_task["description"],
current_task["description"],
source,
"in-progress",
self.current_state.get_source_index(source),
self.current_state.tasks,
)

log.debug(f"Breaking down the current task: {task['description']}")
log.debug(f"Breaking down the current task: {current_task['description']}")
await self.send_message("Thinking about how to implement this task ...")

log.debug(f"Current state files: {len(self.current_state.files)}, relevant {self.current_state.relevant_files}")
# Check which files are relevant to the current task
if self.current_state.files and self.current_state.relevant_files is None:
await self.get_relevant_files()

current_task_index = self.current_state.tasks.index(task)
current_task_index = self.current_state.tasks.index(current_task)

llm = self.get_llm()
convo = AgentConvo(self).template(
"breakdown", task=task, iteration=None, current_task_index=current_task_index, docs=self.current_state.docs
"breakdown",
task=current_task,
iteration=None,
current_task_index=current_task_index,
docs=self.current_state.docs,
)
response: str = await llm(convo)

self.next_state.tasks[current_task_index] = {
**task,
**current_task,
"instructions": response,
}
self.next_state.flag_tasks_as_modified()
Expand Down
2 changes: 1 addition & 1 deletion core/agents/task_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def review_code_changes(self) -> AgentResponse:
)
llm_response: str = await llm(convo, temperature=0.7)

if llm_response.strip().lower() == "done":
if "done" in llm_response.strip().lower()[-6:]:
return AgentResponse.done(self)
else:
return AgentResponse.task_review_feedback(self, llm_response)
2 changes: 1 addition & 1 deletion core/prompts/partials/coding_rules.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You must implement everything mentioned in the instructions that is related to t

## Rule 2: Output format
You must output the COMPLETE NEW VERSION of this file in following format:
---format---
---start_of_format---
```
the full contents of the updated file, without skipping over any content
```
Expand Down

0 comments on commit cf61a96

Please sign in to comment.