mirror of
https://github.com/Pythagora-io/gpt-pilot.git
synced 2026-01-10 13:37:55 -05:00
Merge pull request #956 from Pythagora-io/cache-user-instructions
cache user test instructions between iterations
This commit is contained in:
@@ -63,6 +63,7 @@ class TechLead(BaseAgent):
|
||||
"name": "Initial Project",
|
||||
"source": "app",
|
||||
"description": self.current_state.specification.description,
|
||||
"test_instructions": None,
|
||||
"summary": None,
|
||||
"completed": False,
|
||||
"complexity": self.current_state.specification.complexity,
|
||||
@@ -104,6 +105,7 @@ class TechLead(BaseAgent):
|
||||
{
|
||||
"id": uuid4().hex,
|
||||
"name": f"Feature #{len(self.current_state.epics)}",
|
||||
"test_instructions": None,
|
||||
"source": "feature",
|
||||
"description": response.text,
|
||||
"summary": None,
|
||||
|
||||
@@ -28,10 +28,18 @@ class Troubleshooter(IterationPromptMixin, BaseAgent):
|
||||
|
||||
async def run(self) -> AgentResponse:
|
||||
run_command = await self.get_run_command()
|
||||
user_instructions = await self.get_user_instructions()
|
||||
if user_instructions is None:
|
||||
# LLM decided we don't need to test anything, so we're done with the task
|
||||
return await self.complete_task()
|
||||
|
||||
user_instructions = self.current_state.current_task.get("test_instructions")
|
||||
if not user_instructions:
|
||||
user_instructions = await self.get_user_instructions()
|
||||
if user_instructions is None:
|
||||
# LLM decided we don't need to test anything, so we're done with the task
|
||||
return await self.complete_task()
|
||||
|
||||
# Save the user instructions for future iterations and rerun
|
||||
self.next_state.current_task["test_instructions"] = user_instructions
|
||||
self.next_state.flag_tasks_as_modified()
|
||||
return AgentResponse.done(self)
|
||||
|
||||
# Developer sets iteration as "completed" when it generates the step breakdown, so we can't
|
||||
# use "current_iteration" here
|
||||
|
||||
@@ -203,6 +203,7 @@ class ProjectState(Base):
|
||||
files=[],
|
||||
relevant_files=deepcopy(self.relevant_files),
|
||||
modified_files=deepcopy(self.modified_files),
|
||||
run_command=self.run_command,
|
||||
)
|
||||
|
||||
session: AsyncSession = inspect(self).async_session
|
||||
@@ -263,7 +264,7 @@ class ProjectState(Base):
|
||||
|
||||
def flag_iterations_as_modified(self):
|
||||
"""
|
||||
Flag the iteration field as having been modified
|
||||
Flag the iterations field as having been modified
|
||||
|
||||
Used by Agents that perform modifications within the mutable iterations field,
|
||||
to tell the database that it was modified and should get saved (as SQLalchemy
|
||||
@@ -271,6 +272,16 @@ class ProjectState(Base):
|
||||
"""
|
||||
flag_modified(self, "iterations")
|
||||
|
||||
def flag_tasks_as_modified(self):
|
||||
"""
|
||||
Flag the tasks field as having been modified
|
||||
|
||||
Used by Agents that perform modifications within the mutable tasks field,
|
||||
to tell the database that it was modified and should get saved (as SQLalchemy
|
||||
can't detect changes in mutable fields by itself).
|
||||
"""
|
||||
flag_modified(self, "tasks")
|
||||
|
||||
def get_file_by_path(self, path: str) -> Optional["File"]:
|
||||
"""
|
||||
Get a file from the current project state, by the file path.
|
||||
|
||||
Reference in New Issue
Block a user