Skip to content

Commit 3fedb98

Browse files
Hmbownclaude
andcommitted
fix(subagents): replace 'pending' lease placeholder with real agent id (#660)
Resident-file leases were stamped as "pending" at spawn time because the agent id is only assigned by the manager later. The release function introduced in 2ee926924 matches by agent id, so it could never find those entries and leases would persist for the lifetime of the process. After spawn returns the real agent id, replace any "pending" entry with it so the existing release-on-terminal-state path actually fires. Resolves the documented v0.8.12 caveat noted in the CHANGELOG. Closes the loop with PR #694, which proposed a release-by-file-path API but did not address the placeholder problem itself. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 48d529f commit 3fedb98

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • crates/tui/src/tools/subagent

crates/tui/src/tools/subagent/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,23 @@ impl ToolSpec for AgentSpawnTool {
16831683
)
16841684
.map_err(|e| ToolError::execution_failed(format!("Failed to spawn sub-agent: {e}")))?;
16851685

1686+
// Replace the "pending" lease placeholder with the real agent id now that
1687+
// the manager has assigned one. Without this, `release_resident_leases_for`
1688+
// (which matches by agent id at terminal-state transitions) can never find
1689+
// the entry — leases would stay stamped as "pending" forever, defeating the
1690+
// release machinery added in #660.
1691+
if let Some(ref file_path) = spawn_request.resident_file {
1692+
if let Some(lock) = RESIDENT_LEASES.get() {
1693+
if let Ok(mut guard) = lock.lock() {
1694+
if let Some(owner) = guard.get_mut(file_path) {
1695+
if owner == "pending" {
1696+
*owner = result.agent_id.clone();
1697+
}
1698+
}
1699+
}
1700+
}
1701+
}
1702+
16861703
let mut tool_result = if self.name == "spawn_agent" {
16871704
let mut payload = json!({
16881705
"agent_id": result.agent_id.clone(),

0 commit comments

Comments
 (0)