Skip to content

fix(trajectory): reset state between agent runs - #453

Open
linhongyu510 wants to merge 1 commit into
bytedance:mainfrom
linhongyu510:fix/reset-trajectory-recorder-state
Open

fix(trajectory): reset state between agent runs#453
linhongyu510 wants to merge 1 commit into
bytedance:mainfrom
linhongyu510:fix/reset-trajectory-recorder-state

Conversation

@linhongyu510

Copy link
Copy Markdown

Summary

Reset completion metadata when a TrajectoryRecorder starts a new run.

TraeAgent.run() reuses the agent's recorder and calls start_recording() for every execution. The method already cleared interactions and agent steps, but retained end_time, success, final_result, and execution_time from 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 passed
  • ruff check on the changed Python files
  • ruff format --check on the changed Python files
  • git diff --check

AI 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.

@linhongyu510

Copy link
Copy Markdown
Author

Friendly follow-up with a fresh verification against current origin/main (e839e55):

  • branch remains 0 behind / 1 ahead
  • pytest tests/utils/test_trajectory_recorder.py tests/agent/test_trae_agent.py -q — 8 passed
  • Ruff check and format check passed
  • git diff --check passed

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.

@linhongyu510

Copy link
Copy Markdown
Author

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.

@linhongyu510

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant