Skip to content

Fix Time Travel stale index.lock cleanup and await progress updates#1612

Open
zayzay109 wants to merge 1 commit into
agent0ai:mainfrom
zayzay109:blanca/time-travel-lock-cleanup-await-progress-20260507
Open

Fix Time Travel stale index.lock cleanup and await progress updates#1612
zayzay109 wants to merge 1 commit into
agent0ai:mainfrom
zayzay109:blanca/time-travel-lock-cleanup-await-progress-20260507

Conversation

@zayzay109
Copy link
Copy Markdown

Summary

This PR fixes two small stability issues observed in Agent Zero runtime paths:

  1. Time Travel can leave a stale repo.git/index.lock when a Git subprocess is killed by subprocess.TimeoutExpired, poisoning later snapshots for that workspace.
  2. code_execution_tool calls async Tool.set_progress() without await in two output-progress paths, producing coroutine warnings and potential progress/update instability under load.

Changes

Time Travel

Adds a best-effort _cleanup_git_index_lock() helper and calls it when Git subprocesses time out in:

  • _run_git_dir()
  • _git()
  • _git_bytes()

The timeout exception is re-raised. The patch does not change GIT_TIMEOUT_SECONDS, does not suppress errors, and does not alter normal successful Git behavior.

Code execution tool

Changes two bare calls:

self.set_progress(truncated_output)

to:

await self.set_progress(truncated_output)

Why

If a Time Travel Git command times out, the killed Git process may leave index.lock behind. Later snapshot attempts then fail with:

fatal: Unable to create '.../repo.git/index.lock': File exists.

Cleaning the lock after timeout prevents one failed snapshot from permanently poisoning that workspace.

The set_progress calls are in async functions and should await the coroutine.

Validation

Validated locally with:

python -m py_compile plugins/_time_travel/helpers/time_travel.py
python -m py_compile plugins/_code_execution/tools/code_execution_tool.py

Also validated in a live Agent Zero environment with a Time Travel stability guard after remediation:

{
  "verdict": "PASS",
  "workspace_count": 9
}

No current stale Time Travel index.lock files remained after the fix.

Notes

This is intentionally minimal defensive cleanup. It does not disable Time Travel, change timeout values, or add environment-specific behavior.

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