Skip to content

Commit 933cac7

Browse files
authored
Merge pull request #1072 from Pythagora-io/spec-writer-fix
Fixed wrong original description initialization
2 parents 4259df9 + 5595016 commit 933cac7

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Diff for: core/agents/spec_writer.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,27 @@ async def initialize_spec(self) -> AgentResponse:
6262
# nothing but repeat the question. We reproduce this bug for bug here.
6363
return AgentResponse.done(self)
6464

65-
spec = response.text.strip()
65+
user_description = response.text.strip()
6666

67-
complexity = await self.check_prompt_complexity(spec)
67+
complexity = await self.check_prompt_complexity(user_description)
6868
await telemetry.trace_code_event(
6969
"project-description",
7070
{
71-
"initial_prompt": spec,
71+
"initial_prompt": user_description,
7272
"complexity": complexity,
7373
},
7474
)
7575

76-
if len(spec) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE:
77-
spec = await self.analyze_spec(spec)
78-
spec = await self.review_spec(spec)
76+
if len(user_description) < ANALYZE_THRESHOLD and complexity != Complexity.SIMPLE:
77+
initial_spec = await self.analyze_spec(user_description)
78+
reviewed_spec = await self.review_spec(desc=user_description, spec=initial_spec)
7979

8080
self.next_state.specification = self.current_state.specification.clone()
81-
self.next_state.specification.original_description = spec
82-
self.next_state.specification.description = spec
81+
self.next_state.specification.original_description = user_description
82+
self.next_state.specification.description = reviewed_spec
8383
self.next_state.specification.complexity = complexity
84-
telemetry.set("initial_prompt", spec)
84+
telemetry.set("initial_prompt", user_description)
85+
telemetry.set("updated_prompt", reviewed_spec)
8586
telemetry.set("is_complex_app", complexity != Complexity.SIMPLE)
8687

8788
self.next_state.action = SPEC_STEP_NAME
@@ -203,11 +204,11 @@ async def analyze_spec(self, spec: str) -> str:
203204
n_answers += 1
204205
convo.user(user_response.text)
205206

206-
async def review_spec(self, spec: str) -> str:
207-
convo = AgentConvo(self).template("review_spec", spec=spec)
207+
async def review_spec(self, desc: str, spec: str) -> str:
208+
convo = AgentConvo(self).template("review_spec", desc=desc, spec=spec)
208209
llm = self.get_llm(SPEC_WRITER_AGENT_NAME)
209210
llm_response: str = await llm(convo, temperature=0)
210211
additional_info = llm_response.strip()
211212
if additional_info and len(additional_info) > 6:
212-
spec += "\nAdditional info/examples:\n" + additional_info
213+
spec += "\n\nAdditional info/examples:\n\n" + additional_info
213214
return spec

Diff for: core/prompts/spec-writer/review_spec.prompt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This might include:
99

1010
Here is the client brief:
1111
---CLIENT-BRIEF-START---
12-
{{ state.specification.description }}
12+
{{ desc }}
1313
---CLIENT-BRIEF-END---
1414

1515
Here is the specification your team came up with:

0 commit comments

Comments
 (0)