merge main

pull/1160/head
LeonOstrez 2 years ago
commit 3c1c5994e6

@ -0,0 +1,172 @@
from enum import Enum
from pydantic import BaseModel, Field
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse
from core.config import CHECK_LOGS_AGENT_NAME, magic_words
from core.db.models.project_state import IterationStatus
from core.llm.parser import JSONParser
from core.log import get_logger
log = get_logger(__name__)
class StepType(str, Enum):
ADD_LOG = "add_log"
EXPLAIN_PROBLEM = "explain_problem"
GET_ADDITIONAL_FILES = "get_additional_files"
class HuntConclusionType(str, Enum):
ADD_LOGS = magic_words.ADD_LOGS
PROBLEM_IDENTIFIED = magic_words.PROBLEM_IDENTIFIED
class HuntConclusionOptions(BaseModel):
conclusion: HuntConclusionType = Field(
description=f"If more logs are needed to identify the problem, respond with '{magic_words.ADD_LOGS}'. If the problem is identified, respond with '{magic_words.PROBLEM_IDENTIFIED}'."
)
class BugHunter(BaseAgent):
agent_type = "bug-hunter"
display_name = "Bug Hunter"
async def run(self) -> AgentResponse:
current_iteration = self.current_state.current_iteration
if "bug_reproduction_description" not in current_iteration:
await self.get_bug_reproduction_instructions()
if current_iteration["status"] == IterationStatus.HUNTING_FOR_BUG:
# TODO determine how to find a bug (eg. check in db, ask user a question, etc.)
return await self.check_logs()
elif current_iteration["status"] == IterationStatus.AWAITING_USER_TEST:
return await self.ask_user_to_test(False, True)
elif current_iteration["status"] == IterationStatus.AWAITING_BUG_REPRODUCTION:
return await self.ask_user_to_test(True, False)
async def get_bug_reproduction_instructions(self):
llm = self.get_llm()
convo = AgentConvo(self).template(
"get_bug_reproduction_instructions",
current_task=self.current_state.current_task,
user_feedback=self.current_state.current_iteration["user_feedback"],
user_feedback_qa=self.current_state.current_iteration["user_feedback_qa"],
docs=self.current_state.docs,
next_solution_to_try=None,
)
bug_reproduction_instructions = await llm(convo, temperature=0)
self.next_state.current_iteration["bug_reproduction_description"] = bug_reproduction_instructions
async def check_logs(self, logs_message: str = None):
llm = self.get_llm(CHECK_LOGS_AGENT_NAME)
convo = AgentConvo(self).template(
"iteration",
current_task=self.current_state.current_task,
user_feedback=self.current_state.current_iteration["user_feedback"],
user_feedback_qa=self.current_state.current_iteration["user_feedback_qa"],
docs=self.current_state.docs,
magic_words=magic_words,
next_solution_to_try=None,
)
for hunting_cycle in self.current_state.current_iteration.get("bug_hunting_cycles", []):
convo = convo.assistant(hunting_cycle["human_readable_instructions"]).template(
"log_data",
backend_logs=hunting_cycle["backend_logs"],
frontend_logs=hunting_cycle["frontend_logs"],
fix_attempted=hunting_cycle["fix_attempted"],
)
human_readable_instructions = await llm(convo, temperature=0.5)
convo = (
AgentConvo(self)
.template(
"bug_found_or_add_logs",
hunt_conclusion=human_readable_instructions,
)
.require_schema(HuntConclusionOptions)
)
llm = self.get_llm()
hunt_conclusion = await llm(convo, parser=JSONParser(HuntConclusionOptions), temperature=0)
self.next_state.current_iteration["description"] = human_readable_instructions
self.next_state.current_iteration["bug_hunting_cycles"] += [
{
"human_readable_instructions": human_readable_instructions,
"fix_attempted": any(
c["fix_attempted"] for c in self.current_state.current_iteration["bug_hunting_cycles"]
),
}
]
if hunt_conclusion.conclusion == magic_words.PROBLEM_IDENTIFIED:
# if no need for logs, implement iteration same as before
self.next_state.current_iteration["status"] = IterationStatus.AWAITING_BUG_FIX
await self.send_message("The bug is found - I'm attempting to fix it.")
else:
# if logs are needed, add logging steps
self.next_state.current_iteration["status"] = IterationStatus.AWAITING_LOGGING
await self.send_message("Adding more logs to identify the bug.")
self.next_state.flag_iterations_as_modified()
return AgentResponse.done(self)
async def ask_user_to_test(self, awaiting_bug_reproduction: bool = False, awaiting_user_test: bool = False):
await self.send_message(
"You can reproduce the bug like this:\n\n"
+ self.current_state.current_iteration["bug_reproduction_description"]
)
if self.current_state.run_command:
await self.ui.send_run_command(self.current_state.run_command)
if awaiting_user_test:
user_feedback = await self.ask_question(
"Is the bug you reported fixed now?",
buttons={"yes": "Yes, the issue is fixed", "no": "No"},
default="continue",
buttons_only=True,
hint="Instructions for testing:\n\n"
+ self.current_state.current_iteration["bug_reproduction_description"],
)
self.next_state.current_iteration["bug_hunting_cycles"][-1]["fix_attempted"] = True
if user_feedback.button == "yes":
self.next_state.complete_iteration()
else:
awaiting_bug_reproduction = True
if awaiting_bug_reproduction:
# TODO how can we get FE and BE logs automatically?
backend_logs = await self.ask_question(
"Please do exactly what you did in the last iteration, paste **BACKEND** logs here and click CONTINUE.",
buttons={"continue": "Continue", "done": "Bug is fixed"},
default="continue",
hint="Instructions for testing:\n\n"
+ self.current_state.current_iteration["bug_reproduction_description"],
)
if backend_logs.button == "done":
self.next_state.complete_iteration()
else:
frontend_logs = await self.ask_question(
"Please paste **frontend** logs here and click CONTINUE.",
buttons={"continue": "Continue", "done": "Bug is fixed"},
default="continue",
hint="Instructions for testing:\n\n"
+ self.current_state.current_iteration["bug_reproduction_description"],
)
# TODO select only the logs that are new (with PYTHAGORA_DEBUGGING_LOG)
self.next_state.current_iteration["bug_hunting_cycles"][-1]["backend_logs"] = backend_logs.text
self.next_state.current_iteration["bug_hunting_cycles"][-1]["frontend_logs"] = frontend_logs.text
self.next_state.current_iteration["status"] = IterationStatus.HUNTING_FOR_BUG
if frontend_logs.button == "done":
self.next_state.complete_iteration()
return AgentResponse.done(self)

@ -8,7 +8,7 @@ from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.mixins import RelevantFilesMixin
from core.agents.response import AgentResponse, ResponseType
from core.db.models.project_state import TaskStatus
from core.db.models.project_state import IterationStatus, TaskStatus
from core.db.models.specification import Complexity
from core.llm.parser import JSONParser
from core.log import get_logger
@ -58,6 +58,10 @@ class TaskSteps(BaseModel):
steps: list[Step]
class RelevantFiles(BaseModel):
relevant_files: list[str] = Field(description="List of relevant files for the current task.")
class Developer(RelevantFilesMixin, BaseAgent):
agent_type = "developer"
display_name = "Developer"
@ -106,6 +110,19 @@ class Developer(RelevantFilesMixin, BaseAgent):
n_tasks = 1
log.debug(f"Breaking down the task review feedback {task_review_feedback}")
await self.send_message("Breaking down the task review feedback...")
elif self.current_state.current_iteration["status"] in (
IterationStatus.AWAITING_BUG_FIX,
IterationStatus.AWAITING_LOGGING,
):
iteration = self.current_state.current_iteration
current_task["task_review_feedback"] = None
description = iteration["bug_hunting_cycles"][-1]["human_readable_instructions"]
user_feedback = iteration["user_feedback"]
source = "bug_hunt"
n_tasks = len(self.next_state.iterations)
log.debug(f"Breaking down the logging cycle {description}")
await self.send_message("Breaking down the current iteration logging cycle ...")
else:
iteration = self.current_state.current_iteration
current_task["task_review_feedback"] = None
@ -152,8 +169,22 @@ class Developer(RelevantFilesMixin, BaseAgent):
self.set_next_steps(response, source)
if iteration:
self.next_state.complete_iteration()
self.next_state.action = f"Troubleshooting #{len(self.current_state.iterations)}"
if "status" not in iteration or (
iteration["status"] in (IterationStatus.AWAITING_USER_TEST, IterationStatus.AWAITING_BUG_REPRODUCTION)
):
# This is just a support for old iterations that don't have status
self.next_state.complete_iteration()
self.next_state.action = f"Troubleshooting #{len(self.current_state.iterations)}"
elif iteration["status"] == IterationStatus.IMPLEMENT_SOLUTION:
# If the user requested a change, then, we'll implement it and go straight back to testing
self.next_state.complete_iteration()
self.next_state.action = f"Troubleshooting #{len(self.current_state.iterations)}"
elif iteration["status"] == IterationStatus.AWAITING_BUG_FIX:
# If bug fixing is done, ask user to test again
self.next_state.current_iteration["status"] = IterationStatus.AWAITING_USER_TEST
elif iteration["status"] == IterationStatus.AWAITING_LOGGING:
# If logging is done, ask user to reproduce the bug
self.next_state.current_iteration["status"] = IterationStatus.AWAITING_BUG_REPRODUCTION
else:
self.next_state.action = "Task review feedback"
@ -236,7 +267,14 @@ class Developer(RelevantFilesMixin, BaseAgent):
}
for step in response.steps
]
if len(self.next_state.unfinished_steps) > 0 and source != "review":
if (
len(self.next_state.unfinished_steps) > 0
and source != "review"
and (
self.next_state.current_iteration is None
or self.next_state.current_iteration["status"] != IterationStatus.AWAITING_LOGGING
)
):
self.next_state.steps += [
# TODO: add refactor step here once we have the refactor agent
{

@ -3,6 +3,7 @@ from uuid import uuid4
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse
from core.db.models.project_state import IterationStatus
from core.log import get_logger
log = get_logger(__name__)
@ -110,7 +111,8 @@ class ErrorHandler(BaseAgent):
"description": llm_response,
"alternative_solutions": [],
"attempts": 1,
"completed": False,
"status": IterationStatus.HUNTING_FOR_BUG,
"bug_hunting_cycles": [],
}
]
# TODO: maybe have ProjectState.finished_steps as well? would make the debug/ran_command prompts nicer too

@ -29,6 +29,7 @@ class IterationPromptMixin:
*,
user_feedback_qa: Optional[list[str]] = None,
next_solution_to_try: Optional[str] = None,
bug_hunting_cycles: Optional[dict] = None,
) -> str:
"""
Generate a new solution for the problem the user reported.
@ -36,6 +37,7 @@ class IterationPromptMixin:
:param user_feedback: User feedback about the problem.
:param user_feedback_qa: Additional q/a about the problem provided by the user (optional).
:param next_solution_to_try: Hint from ProblemSolver on which solution to try (optional).
:param bug_hunting_cycles: Data about logs that need to be added to the code (optional).
:return: The generated solution to the problem.
"""
llm = self.get_llm()
@ -44,6 +46,7 @@ class IterationPromptMixin:
user_feedback=user_feedback,
user_feedback_qa=user_feedback_qa,
next_solution_to_try=next_solution_to_try,
bug_hunting_cycles=bug_hunting_cycles,
)
llm_solution: str = await llm(convo)
return llm_solution

@ -2,6 +2,7 @@ from typing import Optional
from core.agents.architect import Architect
from core.agents.base import BaseAgent
from core.agents.bug_hunter import BugHunter
from core.agents.code_monkey import CodeMonkey
from core.agents.code_reviewer import CodeReviewer
from core.agents.developer import Developer
@ -18,7 +19,7 @@ from core.agents.task_reviewer import TaskReviewer
from core.agents.tech_lead import TechLead
from core.agents.tech_writer import TechnicalWriter
from core.agents.troubleshooter import Troubleshooter
from core.db.models.project_state import TaskStatus
from core.db.models.project_state import IterationStatus, TaskStatus
from core.log import get_logger
from core.telemetry import telemetry
from core.ui.base import ProjectStage
@ -226,12 +227,30 @@ class Orchestrator(BaseAgent):
return self.create_agent_for_step(state.current_step)
if state.unfinished_iterations:
if state.current_iteration["description"]:
# Break down the next iteration into steps
current_iteration_status = state.current_iteration["status"]
if current_iteration_status == IterationStatus.HUNTING_FOR_BUG:
# Triggering the bug hunter to start the hunt
return BugHunter(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.AWAITING_LOGGING:
# Get the developer to implement logs needed for debugging
return Developer(self.state_manager, self.ui)
else:
# We need to iterate over the current task but there's no solution, as Pythagora
# is stuck in a loop, and ProblemSolver needs to find alternative solutions.
elif current_iteration_status == IterationStatus.AWAITING_BUG_FIX:
# Get the developer to implement the bug fix for debugging
return Developer(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.IMPLEMENT_SOLUTION:
# Get the developer to implement the "change" requested by the user
return Developer(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.AWAITING_USER_TEST:
# Getting the bug hunter to ask the human to test the bug fix
return BugHunter(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.AWAITING_BUG_REPRODUCTION:
# Getting the bug hunter to ask the human to reproduce the bug
return BugHunter(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.FIND_SOLUTION:
# Find solution to the iteration problem
return Troubleshooter(self.state_manager, self.ui)
elif current_iteration_status == IterationStatus.PROBLEM_SOLVER:
# Call Problem Solver if the user said "I'm stuck in a loop"
return ProblemSolver(self.state_manager, self.ui)
# We have just finished the task, call Troubleshooter to ask the user to review

@ -6,6 +6,7 @@ from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse
from core.agents.troubleshooter import IterationPromptMixin
from core.db.models.project_state import IterationStatus
from core.llm.parser import JSONParser
from core.log import get_logger
@ -98,6 +99,7 @@ class ProblemSolver(IterationPromptMixin, BaseAgent):
self.next_state_iteration["alternative_solutions"][index]["tried"] = True
self.next_state_iteration["description"] = llm_solution
self.next_state_iteration["attempts"] = self.iteration["attempts"] + 1
self.next_state_iteration["status"] = IterationStatus.PROBLEM_SOLVER
self.next_state.flag_iterations_as_modified()
return AgentResponse.done(self)

@ -47,7 +47,7 @@ class TaskReviewer(BaseAgent):
)
llm_response: str = await llm(convo, temperature=0.7)
if "done" in llm_response.strip().lower()[-6:]:
if "done" in llm_response.strip().lower()[-7:]:
return AgentResponse.done(self)
else:
return AgentResponse.task_review_feedback(self, llm_response)

@ -8,7 +8,7 @@ from core.agents.convo import AgentConvo
from core.agents.mixins import IterationPromptMixin, RelevantFilesMixin
from core.agents.response import AgentResponse
from core.db.models.file import File
from core.db.models.project_state import TaskStatus
from core.db.models.project_state import IterationStatus, TaskStatus
from core.llm.parser import JSONParser, OptionalCodeBlockParser
from core.log import get_logger
from core.telemetry import telemetry
@ -33,6 +33,30 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
display_name = "Troubleshooter"
async def run(self) -> AgentResponse:
if self.current_state.unfinished_iterations:
if self.current_state.current_iteration.get("status") == IterationStatus.FIND_SOLUTION:
return await self.propose_solution()
else:
raise ValueError("There is unfinished iteration but it's not in FIND_SOLUTION state.")
else:
return await self.create_iteration()
async def propose_solution(self) -> AgentResponse:
user_feedback = self.current_state.current_iteration.get("user_feedback")
user_feedback_qa = self.current_state.current_iteration.get("user_feedback_qa")
bug_hunting_cycles = self.current_state.current_iteration.get("bug_hunting_cycles")
llm_solution = await self.find_solution(
user_feedback, user_feedback_qa=user_feedback_qa, bug_hunting_cycles=bug_hunting_cycles
)
self.next_state.current_iteration["description"] = llm_solution
self.next_state.current_iteration["status"] = IterationStatus.IMPLEMENT_SOLUTION
self.next_state.flag_iterations_as_modified()
return AgentResponse.done(self)
async def create_iteration(self) -> AgentResponse:
run_command = await self.get_run_command()
user_instructions = self.current_state.current_task.get("test_instructions")
@ -53,7 +77,7 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
# use "current_iteration" here
last_iteration = self.current_state.iterations[-1] if len(self.current_state.iterations) >= 3 else None
should_iterate, is_loop, user_feedback = await self.get_user_feedback(
should_iterate, is_loop, bug_report, change_description = await self.get_user_feedback(
run_command,
user_instructions,
last_iteration is not None,
@ -62,6 +86,7 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
# User tested and reported no problems, we're done with the task
return await self.complete_task()
user_feedback = bug_report or change_description
user_feedback_qa = await self.generate_bug_report(run_command, user_instructions, user_feedback)
if is_loop:
@ -69,26 +94,33 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
# If we already have alternative solutions, it means we were already in a loop.
return self.try_next_alternative_solution(user_feedback, user_feedback_qa)
else:
# Newly detected loop, set up an empty new iteration to trigger ProblemSolver
llm_solution = ""
# Newly detected loop
iteration_status = IterationStatus.PROBLEM_SOLVER
await self.trace_loop("loop-feedback")
elif bug_report is not None:
iteration_status = IterationStatus.HUNTING_FOR_BUG
else:
# should be - elif change_description is not None: - but to prevent bugs with the extension
# this might be caused if we show the input field instead of buttons
await self.get_relevant_files(user_feedback)
llm_solution = await self.find_solution(user_feedback, user_feedback_qa=user_feedback_qa)
iteration_status = IterationStatus.FIND_SOLUTION
self.next_state.iterations = self.current_state.iterations + [
{
"id": uuid4().hex,
"user_feedback": user_feedback,
"user_feedback_qa": user_feedback_qa,
"description": llm_solution,
"description": change_description,
"alternative_solutions": [],
# FIXME - this is incorrect if this is a new problem; otherwise we could
# just count the iterations
"attempts": 1,
"completed": False,
"status": iteration_status,
"bug_hunting_cycles": [],
}
]
self.next_state.flag_iterations_as_modified()
if len(self.next_state.iterations) == LOOP_THRESHOLD:
await self.trace_loop("loop-start")
@ -187,6 +219,11 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
feedback (eg. if they just clicked on "Continue" or "I'm stuck in a loop").
"""
bug_report = None
change_description = None
is_loop = False
should_iterate = True
test_message = "Can you check if the app works please?"
if user_instructions:
hint = " Here is a description of what should be working:\n\n" + user_instructions
@ -194,15 +231,17 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
if run_command:
await self.ui.send_run_command(run_command)
buttons = {"continue": "continue"}
buttons = {"continue": "Everything works", "change": "I want to make a change", "bug": "There is an issue"}
if last_iteration:
buttons["loop"] = "I'm stuck in a loop"
user_response = await self.ask_question(test_message, buttons=buttons, default="continue", hint=hint)
user_response = await self.ask_question(
test_message, buttons=buttons, default="continue", buttons_only=True, hint=hint
)
if user_response.button == "continue" or user_response.cancelled:
return False, False, ""
should_iterate = False
if user_response.button == "loop":
elif user_response.button == "loop":
await telemetry.trace_code_event(
"stuck-in-loop",
{
@ -218,16 +257,25 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
},
},
)
return True, True, ""
is_loop = True
elif user_response.button == "change":
user_description = await self.ask_question(
"Please describe the change you want to make (one at the time please)"
)
change_description = user_description.text
elif user_response.button == "bug":
user_description = await self.ask_question("Please describe the issue you found (one at the time please)")
bug_report = user_description.text
return True, False, user_response.text
return should_iterate, is_loop, bug_report, change_description
def try_next_alternative_solution(self, user_feedback: str, user_feedback_qa: list[str]) -> AgentResponse:
"""
Call the ProblemSolver to try an alternative solution.
Stores the user feedback and sets iteration state (not completed, no description)
so that ProblemSolver will be triggered.
Stores the user feedback and sets iteration state so that ProblemSolver will be triggered.
:param user_feedback: User feedback to store in the iteration state.
:param user_feedback_qa: Additional questions/answers about the problem.
@ -238,7 +286,7 @@ class Troubleshooter(IterationPromptMixin, RelevantFilesMixin, BaseAgent):
next_state_iteration["user_feedback"] = user_feedback
next_state_iteration["user_feedback_qa"] = user_feedback_qa
next_state_iteration["attempts"] += 1
next_state_iteration["completed"] = False
next_state_iteration["status"] = IterationStatus.PROBLEM_SOLVER
self.next_state.flag_iterations_as_modified()
self.next_state.action = f"Alternative solution (attempt #{next_state_iteration['attempts']})"
return AgentResponse.done(self)

@ -36,6 +36,7 @@ IGNORE_SIZE_THRESHOLD = 50000 # 50K+ files are ignored by default
DEFAULT_AGENT_NAME = "default"
CODE_MONKEY_AGENT_NAME = "CodeMonkey"
DESCRIBE_FILES_AGENT_NAME = "CodeMonkey.describe_files"
CHECK_LOGS_AGENT_NAME = "BugHunter.check_logs"
# Endpoint for the external documentation
EXTERNAL_DOCUMENTATION_API = "http://docs-pythagora-io-439719575.us-east-1.elb.amazonaws.com"
@ -305,12 +306,18 @@ class Config(_StrictModel):
Pythagora Core configuration
"""
llm: dict[LLMProvider, ProviderConfig] = Field(default={LLMProvider.OPENAI: ProviderConfig()})
llm: dict[LLMProvider, ProviderConfig] = Field(
default={
LLMProvider.OPENAI: ProviderConfig(),
LLMProvider.ANTHROPIC: ProviderConfig(),
}
)
agent: dict[str, AgentLLMConfig] = Field(
default={
DEFAULT_AGENT_NAME: AgentLLMConfig(),
CODE_MONKEY_AGENT_NAME: AgentLLMConfig(model="gpt-4-0125-preview", temperature=0.0),
DESCRIBE_FILES_AGENT_NAME: AgentLLMConfig(model="gpt-3.5-turbo", temperature=0.0),
CHECK_LOGS_AGENT_NAME: AgentLLMConfig(model="claude-3-5-sonnet-20240620", temperature=0.0),
}
)
prompt: PromptConfig = PromptConfig()

@ -0,0 +1,2 @@
PROBLEM_IDENTIFIED = "PROBLEM_IDENTIFIED"
ADD_LOGS = "ADD_LOGS"

@ -30,6 +30,20 @@ class TaskStatus:
SKIPPED = "skipped"
class IterationStatus:
"""Status of an iteration."""
HUNTING_FOR_BUG = "check_logs"
AWAITING_LOGGING = "awaiting_logging"
AWAITING_USER_TEST = "awaiting_user_test"
AWAITING_BUG_FIX = "awaiting_bug_fix"
AWAITING_BUG_REPRODUCTION = "awaiting_bug_reproduction"
IMPLEMENT_SOLUTION = "implement_solution"
FIND_SOLUTION = "find_solution"
PROBLEM_SOLVER = "problem_solver"
DONE = "done"
class ProjectState(Base):
__tablename__ = "project_states"
__table_args__ = (
@ -105,7 +119,9 @@ class ProjectState(Base):
:return: List of unfinished iterations.
"""
return [iteration for iteration in self.iterations if not iteration.get("completed")]
return [
iteration for iteration in self.iterations if iteration.get("status") not in (None, IterationStatus.DONE)
]
@property
def current_iteration(self) -> Optional[dict]:
@ -285,7 +301,7 @@ class ProjectState(Base):
raise ValueError("Current state is read-only (already has a next state).")
log.debug(f"Completing iteration {self.unfinished_iterations[0]}")
self.unfinished_iterations[0]["completed"] = True
self.unfinished_iterations[0]["status"] = IterationStatus.DONE
self.flag_iterations_as_modified()
def flag_iterations_as_modified(self):

@ -0,0 +1,6 @@
We are working on a solving a technical problem in a codebase and here is a conclusion from a team member:
--- TEAM_MEMBER_CONCLUSION ---
{{ hunt_conclusion }}
--- END_OF_TEAM_MEMBER_CONCLUSION ---
Please tell me if the conclusion from the team member is to add more logs around the code or if the conclusion is that there are all information needed to fix the issue.

@ -0,0 +1,30 @@
You are working on an app called "{{ state.branch.project.name }}" and you need to write code for the entire application.
{% include "partials/project_details.prompt" %}
{% if state.tasks and state.current_task %}
Development process of this app was split into smaller tasks. Here is the list of all tasks:
```{% for task in state.tasks %}
{{ loop.index }}. {{ task.description }}
{% endfor %}
```
You are currently working on, and have to focus only on, this task:
```
{{ current_task.description }}
```
{% endif %}
A part of the app is already finished.
{% include "partials/files_list.prompt" %}
{% include "partials/user_feedback.prompt" %}
{% if next_solution_to_try is not none %}
Focus on solving this issue in the following way:
```
{{ next_solution_to_try }}
```
{% endif %}
Based on this information, you need to tell me in 2-3 sentences how can I reproduce the issue that the user experienced.

@ -0,0 +1,34 @@
You are working on an app called "{{ state.branch.project.name }}" and you need to write code for the entire application.
{% include "partials/project_details.prompt" %}
{% if state.tasks and state.current_task %}
Development process of this app was split into smaller tasks. Here is the list of all tasks:
```{% for task in state.tasks %}
{{ loop.index }}. {{ task.description }}
{% endfor %}
```
You are currently working on, and have to focus only on, this task:
```
{{ current_task.description }}
```
{% endif %}
A part of the app is already finished.
{% include "partials/files_list.prompt" %}
{% include "partials/user_feedback.prompt" %}
{% if next_solution_to_try is not none %}
Focus on solving this issue in the following way:
```
{{ next_solution_to_try }}
```
{% endif %}
Based on this information, you need to figure out where is the problem that the user described. You have 2 options - to tell me exactly where is the problem happening or to add more logs to better determine where is the problem.
If you think we should add more logs around the code to better understand the problem, tell me code snippets in which we should add the logs. If you think you know where the issue is, don't add any new logs but explain what log print tell point you to the problem, what the problem is, what is the solution to this problem and how the solution will fix the problem. What is your answer?
**IMPORTANT**
You cannot answer with "Ensure that...", "Make sure that...", etc. In these cases, explain how should the reader of your message ensure what you want them to ensure. In most cases, they will need to add some logs to ensure something in which case tell them where to add them.

@ -0,0 +1,12 @@
{% if backend_logs is not none %}Here are the logs we added to the backend:
```
{{ backend_logs }}
```
{% endif %}{% if frontend_logs is not none %}
Here are the logs we added to the frontend:
```
{{ frontend_logs }}
```
{% endif %}{% if fix_attempted %}
The problem wasn't solved with the last changes. You have 2 options - to tell me exactly where is the problem happening or to add more logs to better determine where is the problem. If you think we should add more logs around the code to better understand the problem, tell me code snippets in which we should add the logs. If you think you know where the issue is, don't add any new logs but explain what log print tell point you to the problem, what the problem is, what is the solution to this problem and how the solution will fix the problem. What is your answer? Make sure not to repeat mistakes from before that didn't work.
{% endif %}

@ -10,6 +10,13 @@
"connect_timeout": 60.0,
"read_timeout": 10.0
},
// Example config for Anthropic (see https://docs.anthropic.com/docs/api-reference)
"anthropic": {
"base_url": "https://api.anthropic.com",
"api_key": "your-api-key",
"connect_timeout": 60.0,
"read_timeout": 10.0
},
// Example config for Azure OpenAI (see https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions)
"azure": {
"base_url": "https://your-resource-name.openai.azure.com/",
@ -40,6 +47,11 @@
"provider": "openai",
"model": "gpt-3.5-turbo",
"temperature": 0.0
},
"BugHunter.check_logs": {
"provider": "anthropic",
"model": "claude-3-5-sonnet-20240620",
"temperature": 0.0
}
},
// Logging configuration outputs debug log to "pythagora.log" by default. If you set this to null,

@ -2,6 +2,7 @@ import pytest
from sqlalchemy import select
from core.db.models import Branch, File, FileContent, Project, ProjectState
from core.db.models.project_state import IterationStatus
from .factories import create_project_state
@ -150,7 +151,7 @@ async def test_completing_unfinished_iterations(testdb):
{
"id": "abc",
"description": "LLM breakdown of the iteration",
"completed": False,
"status": IterationStatus.HUNTING_FOR_BUG,
}
]
testdb.add(state)

Loading…
Cancel
Save