mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(delegate): close child agent after delegation completes
Call child.close() in the _run_single_child finally block after unregistering the child from the parent's active children list. Previously child AIAgent instances were only removed from the tracking list but never had their resources released — the OpenAI/httpx client and any tool subprocesses relied entirely on garbage collection. Ref: #7131
This commit is contained in:
@@ -578,6 +578,15 @@ def _run_single_child(
|
||||
except (ValueError, UnboundLocalError) as e:
|
||||
logger.debug("Could not remove child from active_children: %s", e)
|
||||
|
||||
# Close tool resources (terminal sandboxes, browser daemons,
|
||||
# background processes, httpx clients) so subagent subprocesses
|
||||
# don't outlive the delegation.
|
||||
try:
|
||||
if hasattr(child, 'close'):
|
||||
child.close()
|
||||
except Exception:
|
||||
logger.debug("Failed to close child agent after delegation")
|
||||
|
||||
def delegate_task(
|
||||
goal: Optional[str] = None,
|
||||
context: Optional[str] = None,
|
||||
|
||||
Reference in New Issue
Block a user