Skip to content

Commit bd0afbe

Browse files
authoredJul 4, 2024··
Merge pull request #1044 from Pythagora-io/move-docs-check
Only check for docs if the user wants to run the task.
2 parents de8ae61 + 64e407d commit bd0afbe

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
 

‎core/agents/developer.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from core.agents.convo import AgentConvo
99
from core.agents.response import AgentResponse, ResponseType
1010
from core.db.models.project_state import TaskStatus
11+
from core.db.models.specification import Complexity
1112
from core.llm.parser import JSONParser
1213
from core.log import get_logger
1314
from core.telemetry import telemetry
@@ -77,10 +78,17 @@ async def run(self) -> AgentResponse:
7778

7879
# By default, we want to ask the user if they want to run the task,
7980
# except in certain cases (such as they've just edited it).
80-
if not self.current_state.current_task.get("run_always", False):
81+
# The check for docs is here to prevent us from asking the user whether we should
82+
# run the task twice - we'll only ask if we haven't yet checked for docs.
83+
if not self.current_state.current_task.get("run_always", False) and self.current_state.docs is None:
8184
if not await self.ask_to_execute_task():
8285
return AgentResponse.done(self)
8386

87+
if self.current_state.docs is None and self.current_state.specification.complexity != Complexity.SIMPLE:
88+
# We check for external docs here, to make sure we only fetch the docs
89+
# if the task is actually being done.
90+
return AgentResponse.external_docs_required(self)
91+
8492
return await self.breakdown_current_task()
8593

8694
async def breakdown_current_iteration(self, review_feedback: Optional[str] = None) -> AgentResponse:

‎core/agents/orchestrator.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from core.agents.tech_writer import TechnicalWriter
2020
from core.agents.troubleshooter import Troubleshooter
2121
from core.db.models.project_state import TaskStatus
22-
from core.db.models.specification import Complexity
2322
from core.log import get_logger
2423
from core.telemetry import telemetry
2524
from core.ui.base import ProjectStage
@@ -180,6 +179,8 @@ def create_agent(self, prev_response: Optional[AgentResponse]) -> BaseAgent:
180179
return Developer(self.state_manager, self.ui, prev_response=prev_response)
181180
if prev_response.type == ResponseType.IMPORT_PROJECT:
182181
return Importer(self.state_manager, self.ui, prev_response=prev_response)
182+
if prev_response.type == ResponseType.EXTERNAL_DOCS_REQUIRED:
183+
return ExternalDocumentation(self.state_manager, self.ui, prev_response=prev_response)
183184

184185
if not state.specification.description:
185186
if state.files:
@@ -199,9 +200,6 @@ def create_agent(self, prev_response: Optional[AgentResponse]) -> BaseAgent:
199200
# Ask the Tech Lead to break down the initial project or feature into tasks and apply project templates
200201
return TechLead(self.state_manager, self.ui, process_manager=self.process_manager)
201202

202-
if state.current_task and state.docs is None and state.specification.complexity != Complexity.SIMPLE:
203-
return ExternalDocumentation(self.state_manager, self.ui)
204-
205203
# Current task status must be checked before Developer is called because we might want
206204
# to skip it instead of breaking it down
207205
current_task_status = state.current_task.get("status") if state.current_task else None

‎core/agents/response.py

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ResponseType(str, Enum):
4242
IMPORT_PROJECT = "import-project"
4343
"""User wants to import an existing project."""
4444

45+
EXTERNAL_DOCS_REQUIRED = "external-docs-required"
46+
"""We need to fetch external docs for a task."""
47+
4548

4649
class AgentResponse:
4750
type: ResponseType = ResponseType.DONE
@@ -137,3 +140,7 @@ def task_review_feedback(agent: "BaseAgent", feedback: str) -> "AgentResponse":
137140
@staticmethod
138141
def import_project(agent: "BaseAgent") -> "AgentResponse":
139142
return AgentResponse(type=ResponseType.IMPORT_PROJECT, agent=agent)
143+
144+
@staticmethod
145+
def external_docs_required(agent: "BaseAgent") -> "AgentResponse":
146+
return AgentResponse(type=ResponseType.EXTERNAL_DOCS_REQUIRED, agent=agent)

0 commit comments

Comments
 (0)
Please sign in to comment.