Release empty registry agent state

This commit is contained in:
Ollie Agent 2026-08-18 07:09:21 +02:00
parent 6ef1fe52e0
commit 1b934c43f4
2 changed files with 7 additions and 6 deletions

View File

@ -71,6 +71,11 @@ func (r *Registry) Unload(agentID, name string) error {
}
delete(agentTools, name)
if len(agentTools) == 0 {
delete(r.agents, agentID)
delete(r.revisions, agentID)
return nil
}
r.revisions[agentID]++
return nil
}

View File

@ -286,13 +286,9 @@ Completion notifications now use the toolsrv run context with a ten-second timeo
### M14. Toolsrv registry retains abandoned agent state
**Evidence:** `cmd/toolsrv/internal/registry/registry.go:15-19,47-75`.
**Status:** Fixed in the working tree.
`Load` creates per-agent tool and revision maps. `Unload` removes tools but never removes empty agent maps or revision entries.
**Impact:** transient or deleted agent identifiers accumulate in long-lived toolsrv processes.
**Remediation:** delete empty agent state when an agent is unloaded.
`Unload` now removes the per-agent tool map and revision entry when the final tool is removed. Empty agent state no longer accumulates in long-lived toolsrv processes.
### M15. `DismissProc` and process GC can lose cleanup ownership