fix(trajectory): reset state between agent runs - #453
Conversation
|
Friendly follow-up with a fresh verification against current
The patch remains limited to resetting run-scoped completion metadata when a reused recorder starts a new run; it does not change the trajectory schema. Could a maintainer take a look when convenient? Happy to adjust anything needed. |
|
Revalidated on the current main (8de9be8 is 0 commits behind). Red phase: applying the regression test to the parent commit fails because the second run retains the first run's end_time, success=True, final_result, and execution_time. Green phase: 8/8 targeted trajectory and TraeAgent tests pass on this PR; Ruff format/check and git diff --check also pass. There are no competing open TrajectoryRecorder reset PRs. Maintainer review would be appreciated.Revalidated on the current main (8de9be8 is 0 commits behind). Red phase: applying the regression test to the parent commit fails because the second run retains the first run's end_time, success=True, final_result, and execution_time. Green phase: 8/8 targeted trajectory and TraeAgent tests pass on this PR; Ruff format/check and git diff --check also pass. There are no competing open TrajectoryRecorder reset PRs. Maintainer review would be appreciated. |
|
Revalidated on the current main (8de9be8 is 0 commits behind). Red phase: applying the regression test to the parent commit fails because the second run retains the first run's end_time, success=True, final_result, and execution_time. Green phase: 8/8 targeted trajectory and TraeAgent tests pass on this PR; Ruff format/check and git diff --check also pass. There are no competing open TrajectoryRecorder reset PRs. Maintainer review would be appreciated. |
Summary
Reset completion metadata when a
TrajectoryRecorderstarts a new run.TraeAgent.run()reuses the agent's recorder and callsstart_recording()for every execution. The method already cleared interactions and agent steps, but retainedend_time,success,final_result, andexecution_timefrom the previous finalized run. Until the second run completed, the saved trajectory could therefore report stale success and result data.This change resets all run-scoped completion fields together with interaction history. The regression test finalizes one run, starts another with the same recorder, and verifies both in-memory and persisted JSON state.
The change is intentionally limited to run-state reset behavior; it does not alter the trajectory schema.
Validation
pytest tests/utils/test_trajectory_recorder.py tests/agent/test_trae_agent.py -q— 8 passedruff checkon the changed Python filesruff format --checkon the changed Python filesgit diff --checkAI assistance
This change was developed with AI assistance. I reviewed the recorder reuse path, split the fix from unrelated schema work, and ran the checks above.