The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(api): preserve profile context for disconnect reapers
NanPan33a47679ba21
diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.pyindex dc97d7f7912..b1ad438bc98 100644--- a/gateway/platforms/api_server.py+++ b/gateway/platforms/api_server.py@@ -14,7 +14,7 @@ import hmacimport itertoolsimport jsonfrom contextlib import contextmanager, nullcontext, suppress-from contextvars import ContextVar+from contextvars import ContextVar, copy_contextfrom functools import wrapsimport loggingimport os@@ -580,7 +580,7 @@ def _reap_disconnected_agent_processes(is_still_current = _epoch_still_currentfrom gateway.run import _reap_gateway_turn_processesthreading.Thread(- target=_reap_gateway_turn_processes, args=(process_task_id, process_baseline),+ target=copy_context().run, args=(_reap_gateway_turn_processes, process_task_id, process_baseline),kwargs={"source": source, "is_still_current": is_still_current},name=f"api-turn-reaper-{process_task_id[:12]}", daemon=True).start()@@ -4006,7 +4006,7 @@ class APIServerAdapter(OpenAICompatRoutesMixin, BasePlatformAdapter):return Falseasync def disconnect(self) -> None:- """Stop the aiohttp server and release every owned resource, including the ResponseStore+ """Stop the aiohttp web server and release every owned resource, including the ResponseStoreconnection (the reconnect loop builds a fresh adapter per retry; leaked fds hit EMFILE).Without this, every adapter instance leaks 2 file descriptors (the database file and its WAL