diff --git a/core/agents/spec_writer.py b/core/agents/spec_writer.py index 01ff95156..1e2a9a249 100644 --- a/core/agents/spec_writer.py +++ b/core/agents/spec_writer.py @@ -54,6 +54,14 @@ async def run(self) -> AgentResponse: spec = response.text complexity = await self.check_prompt_complexity(spec) + await telemetry.trace_code_event( + "project-description", + { + "initial_prompt": spec, + "complexity": complexity, + }, + ) + if len(spec) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE: spec = await self.analyze_spec(spec) spec = await self.review_spec(spec) @@ -111,6 +119,8 @@ async def analyze_spec(self, spec: str) -> str: llm = self.get_llm() convo = AgentConvo(self).template("ask_questions").user(spec) + n_questions = 0 + n_answers = 0 while True: response: str = await llm(convo) @@ -125,12 +135,21 @@ async def analyze_spec(self, spec: str) -> str: buttons={"continue": "continue"}, ) if confirm.cancelled or confirm.button == "continue" or confirm.text == "": + await self.telemetry.trace_code_event( + "spec-writer-questions", + { + "num_questions": n_questions, + "num_answers": n_answers, + "new_spec": spec, + }, + ) return spec convo.user(confirm.text) else: convo.assistant(response) + n_questions += 1 user_response = await self.ask_question( response, buttons={"skip": "Skip questions"}, @@ -143,6 +162,7 @@ async def analyze_spec(self, spec: str) -> str: response: str = await llm(convo) return response + n_answers += 1 convo.user(user_response.text) async def review_spec(self, spec: str) -> str: diff --git a/core/state/state_manager.py b/core/state/state_manager.py index bcdc405d0..a7eac3a98 100644 --- a/core/state/state_manager.py +++ b/core/state/state_manager.py @@ -77,6 +77,7 @@ async def create_project(self, name: str, folder_name: Optional[str] = None) -> f'with default branch "{branch.name}" (id={branch.id}) ' f"and initial state id={state.id} (step_index={state.step_index})" ) + await telemetry.trace_code_event("create-project", {"name": name}) self.current_session = session self.current_state = state