Skip to content

Commit 3579712

Browse files
committed
fix: remove duplicate step output from post-hoc trajectory replay
DSPy's verbose=True already shows each RLM iteration's reasoning and code in real-time. The post-hoc on_step trajectory callback was replaying all steps again after completion, causing every step to appear twice in output. Agent-Id: agent-01069cef-6b08-41f1-a15d-29feb2ccaea1
1 parent ab6ba84 commit 3579712

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

npx/python/cli/virtual_runner.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,9 @@ async def review(self, url: str, question: str) -> tuple[str, list[str], dict]:
263263
if isinstance(sources, str):
264264
sources = [s.strip() for s in sources.split(",") if s.strip()]
265265

266-
# Handle on_step callback with trajectory if available
267-
if self.on_step and hasattr(result, 'trajectory') and result.trajectory:
268-
for i, step in enumerate(result.trajectory):
269-
reasoning = step.get('reasoning', '')
270-
code = step.get('code', '')
271-
output = step.get('output', '')
272-
self.on_step(i + 1, reasoning, code, output)
266+
# Note: DSPy's verbose=True already shows step-by-step progress in real-time.
267+
# Post-hoc trajectory replay via on_step is intentionally removed to avoid
268+
# duplicate output (steps were being shown twice).
273269
finally:
274270
# Cleanup
275271
if self._repo_tools:
@@ -321,13 +317,9 @@ async def review_local(self, path: str, question: str) -> tuple[str, list[str],
321317
if isinstance(sources, str):
322318
sources = [s.strip() for s in sources.split(",") if s.strip()]
323319

324-
# Handle on_step callback with trajectory if available
325-
if self.on_step and hasattr(result, 'trajectory') and result.trajectory:
326-
for i, step in enumerate(result.trajectory):
327-
reasoning = step.get('reasoning', '')
328-
code = step.get('code', '')
329-
output = step.get('output', '')
330-
self.on_step(i + 1, reasoning, code, output)
320+
# Note: DSPy's verbose=True already shows step-by-step progress in real-time.
321+
# Post-hoc trajectory replay via on_step is intentionally removed to avoid
322+
# duplicate output (steps were being shown twice).
331323
finally:
332324
# Cleanup
333325
if self._repo_tools:

0 commit comments

Comments
 (0)