Todo 49.2 Session Load Race and Visible Repair Plan
Status: done
Goal
Close reviewed session restoration races without changing the completed Todo 49/49.1 records.
Scope
- Guard asynchronous session replay with a monotonically increasing load token and the selected session id so stale responses cannot overwrite current UI state.
- Ignore stale success and failure status updates from superseded loads.
- Treat whitespace-only assistant content with
tool_calls as protocol-only in replay.
- When repairing an incomplete persisted tool-call group, retain non-blank assistant content as a provider-valid assistant message without
tool_calls; continue dropping orphan tool replies.
Files
- Modify:
src/agent_lab/application/runtime.py
- Modify:
src/agent_lab/presentation/static/app.js
- Modify:
tests/test_debug_runtime.py
- Modify:
tests/test_websocket_api.py
Requirement Execution Loop
Plan
- Add RED tests for out-of-order session replay, whitespace-only protocol messages, and incomplete tool rounds with visible text.
- Add the smallest load-token and transcript-repair changes.
- Run focused tests, JS syntax, full tests, diff check, and bounded review.
Verification
uv run pytest tests/test_debug_runtime.py tests/test_websocket_api.py -q
node --check src/agent_lab/presentation/static/app.js
uv run pytest
git diff --check
Observe / Update
- Superseded replay success/failure responses cannot mutate the selected session UI.
- Whitespace-only protocol assistant records are hidden, while incomplete protocol records with visible text are restored without
tool_calls.
- Focused tests passed (
132 passed); full suite passed (387 passed) before the directional token follow-up.