-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Labels
automatedIssues created by cagentIssues created by cagentkind/bugSomething isn't workingSomething isn't working
Description
🟡 medium - bug
File: cmd/root/run.go (line 236)
Code
defer func() {
if err := rt.Close(); err != nil {
slog.Error("Failed to close runtime", "error", err)
}
}()Problem
In the runOrExec function, there's a defer call to rt.Close() which logs an error if it occurs. However, this is for the initial local runtime. When new sessions are spawned via createSessionSpawner, each new localRt also needs to be closed. The cleanup function in createSessionSpawner only calls team.StopToolSets, but not localRt.Close(). This could lead to resource leaks if the localRt in spawned sessions holds open resources.
Suggested Fix
Modify the cleanup function within createSessionSpawner to also close the localRt that it creates. For example:
cleanup := func() {
cleanupCtx := context.WithoutCancel(spawnCtx)
if err := team.StopToolSets(cleanupCtx); err != nil {
slog.Error("Failed to stop tool sets during cleanup", "error", err)
}
if err := localRt.Close(); err != nil {
slog.Error("Failed to close runtime during spawned session cleanup", "error", err)
}
}Found by nightly codebase scan
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
automatedIssues created by cagentIssues created by cagentkind/bugSomething isn't workingSomething isn't working