From 2f8d6a3ffba2c003174e9c67dc6f1374a0921368 Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Tue, 7 Apr 2026 12:11:12 +0100 Subject: [PATCH] Fix agent config handler registration, remove debug prints, disable RabbitMQ heartbeats (#764) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix agent react and orchestrator services appending bare methods to config_handlers instead of using register_config_handler() — caused 'method object is not subscriptable' on config notify - Add exc_info to config fetch retry logging for proper tracebacks - Remove debug print statements from collection management dispatcher and translator - Disable RabbitMQ heartbeats (heartbeat=0) to prevent broker closing idle producer connections that can't process heartbeat frames from BlockingConnection --- trustgraph-base/trustgraph/base/async_processor.py | 3 ++- trustgraph-base/trustgraph/base/rabbitmq_backend.py | 1 + .../trustgraph/messaging/translators/collection.py | 3 --- trustgraph-flow/trustgraph/agent/orchestrator/service.py | 4 +++- trustgraph-flow/trustgraph/agent/react/service.py | 4 +++- .../trustgraph/gateway/dispatch/collection_management.py | 2 -- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/trustgraph-base/trustgraph/base/async_processor.py b/trustgraph-base/trustgraph/base/async_processor.py index d59bff59..c805bffa 100644 --- a/trustgraph-base/trustgraph/base/async_processor.py +++ b/trustgraph-base/trustgraph/base/async_processor.py @@ -172,7 +172,8 @@ class AsyncProcessor: except Exception as e: logger.warning( - f"Config fetch failed: {e}, retrying in 2s..." + f"Config fetch failed: {e}, retrying in 2s...", + exc_info=True ) await asyncio.sleep(2) diff --git a/trustgraph-base/trustgraph/base/rabbitmq_backend.py b/trustgraph-base/trustgraph/base/rabbitmq_backend.py index a80efbaf..b9afe741 100644 --- a/trustgraph-base/trustgraph/base/rabbitmq_backend.py +++ b/trustgraph-base/trustgraph/base/rabbitmq_backend.py @@ -288,6 +288,7 @@ class RabbitMQBackend: port=port, virtual_host=vhost, credentials=pika.PlainCredentials(username, password), + heartbeat=0, ) logger.info(f"RabbitMQ backend: {host}:{port} vhost={vhost}") diff --git a/trustgraph-base/trustgraph/messaging/translators/collection.py b/trustgraph-base/trustgraph/messaging/translators/collection.py index c6fd1500..2e39e8c2 100644 --- a/trustgraph-base/trustgraph/messaging/translators/collection.py +++ b/trustgraph-base/trustgraph/messaging/translators/collection.py @@ -79,7 +79,6 @@ class CollectionManagementResponseTranslator(MessageTranslator): def encode(self, obj: CollectionManagementResponse) -> Dict[str, Any]: result = {} - print("COLLECTIONMGMT", obj, flush=True) if obj.error is not None: result["error"] = { @@ -99,6 +98,4 @@ class CollectionManagementResponseTranslator(MessageTranslator): "tags": list(coll.tags) if coll.tags else [] }) - print("RESULT IS", result, flush=True) - return result diff --git a/trustgraph-flow/trustgraph/agent/orchestrator/service.py b/trustgraph-flow/trustgraph/agent/orchestrator/service.py index ea0afd60..5bf8e2fd 100644 --- a/trustgraph-flow/trustgraph/agent/orchestrator/service.py +++ b/trustgraph-flow/trustgraph/agent/orchestrator/service.py @@ -93,7 +93,9 @@ class Processor(AgentService): # Meta-router (initialised on first config load) self.meta_router = None - self.config_handlers.append(self.on_tools_config) + self.register_config_handler( + self.on_tools_config, types=["tool", "tool-service"] + ) self.register_specification( TextCompletionClientSpec( diff --git a/trustgraph-flow/trustgraph/agent/react/service.py b/trustgraph-flow/trustgraph/agent/react/service.py index 0e783349..40857313 100755 --- a/trustgraph-flow/trustgraph/agent/react/service.py +++ b/trustgraph-flow/trustgraph/agent/react/service.py @@ -81,7 +81,9 @@ class Processor(AgentService): # Track active tool service clients for cleanup self.tool_service_clients = {} - self.config_handlers.append(self.on_tools_config) + self.register_config_handler( + self.on_tools_config, types=["tool", "tool-service"] + ) self.register_specification( TextCompletionClientSpec( diff --git a/trustgraph-flow/trustgraph/gateway/dispatch/collection_management.py b/trustgraph-flow/trustgraph/gateway/dispatch/collection_management.py index 544a412d..934f1c99 100644 --- a/trustgraph-flow/trustgraph/gateway/dispatch/collection_management.py +++ b/trustgraph-flow/trustgraph/gateway/dispatch/collection_management.py @@ -28,9 +28,7 @@ class CollectionManagementRequestor(ServiceRequestor): self.response_translator = TranslatorRegistry.get_response_translator("collection-management") def to_request(self, body): - print("REQUEST", body, flush=True) return self.request_translator.decode(body) def from_response(self, message): - print("RESPONSE", message, flush=True) return self.response_translator.encode_with_completion(message)