Commit 2606e52
committed
fix(agents): restore controller.dispose() and clear prompt turn on teardown
ClawSweeper review on the previous force-push found that the rebase that
dropped the kesslerio drain commit also removed unrelated infrastructure:
the EmbeddedAttemptSessionLockController.dispose() method, its outer-
finally call site in runEmbeddedAttempt, and two existing test cases on
main that exercise it. Without dispose() the eager session lock leaks on
post-prompt error paths (the original #86014 fix). The new
activePromptSessionTurn introduced by this PR makes the gap worse —
teardown after releaseForPrompt without going through reacquireAfterPrompt
leaves the file-scoped queue tail unresolved and the next same-file
controller waits forever (bot finding, confidence 0.9).
Restored:
- EmbeddedAttemptSessionLockController.dispose(): Promise<void> back on
the type and implementation. Behavior: vacate activePromptSessionTurn
first (new), then release heldLock if held (the original main behavior).
Idempotent — both heldLock and activePromptSessionTurn are cleared
after first call.
- releaseRetainedSessionLock infrastructure in runEmbeddedAttempt:
declaration before the try block, assignment after the controller
constructor, and the outer-finally invocation with the log.error
fallback. Restored from main as it was before this branch's rebase.
- The two existing dispose tests from main (#86014):
"releases the eagerly-held attempt lock on dispose when cleanup is
skipped" and "dispose does not double-release a lock already handed to
cleanup".
New regression for the prompt-turn cleanup invariant:
- "dispose-after-releaseForPrompt vacates the prompt turn so the next
same-file controller does not hang". Verifies the case the bot
flagged: controller A calls releaseForPrompt, then dispose without
going through reacquireAfterPrompt. Controller B on the same session
file must be able to releaseForPrompt without hanging. The test races
releaseForPrompt against a 200 ms timeout and asserts the release
resolves first.
80 cases across 2 test files green.
Closes #85913.1 parent c4dacdc commit 2606e52
2 files changed
Lines changed: 53 additions & 0 deletions
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1431 | 1431 | | |
1432 | 1432 | | |
1433 | 1433 | | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1434 | 1475 | | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
981 | 981 | | |
982 | 982 | | |
983 | 983 | | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
984 | 996 | | |
985 | 997 | | |
986 | 998 | | |
| |||
0 commit comments