Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/swf_common_lib/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ def run(self):
import traceback
traceback.print_exc()
finally:
# Report exit status before disconnecting
try:
self.report_agent_status("EXITED", "Agent shutdown")
except Exception as e:
logging.warning(f"Failed to report exit status: {e}")

if self.conn and self.conn.is_connected():
self.conn.disconnect()
self.mq_connected = False
Expand Down Expand Up @@ -397,11 +403,18 @@ def send_message(self, destination, message_body):
Sends a JSON message to a specific destination.

Auto-injects 'sender' (agent_name) and 'namespace' (if configured) into message.
Warns if namespace is not configured - messages without namespace cannot be
filtered by namespace-aware agents.
"""
# Auto-inject sender and namespace
message_body['sender'] = self.agent_name
if self.namespace:
message_body['namespace'] = self.namespace
else:
logging.warning(
f"Sending message without namespace (msg_type={message_body.get('msg_type', 'unknown')}). "
"Configure namespace in testbed.toml to enable namespace filtering."
)
Comment on lines +413 to +417
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning will be logged on every message sent when namespace is not configured. For deployments that intentionally don't use namespaces (which is valid since config_path is optional), this creates excessive log noise. Consider either: (1) logging this once during initialization instead of on every send_message call, (2) changing to logging.debug() or logging.info() level since it's informational rather than a warning about a problem, or (3) adding a flag to suppress repeated warnings.

Copilot uses AI. Check for mistakes.

try:
self.conn.send(body=json.dumps(message_body), destination=destination)
Expand Down
Loading