From 67e6eff534f5da61fe3d037e412eeb1a6e45f683 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 24 Apr 2026 23:12:51 -0400 Subject: [PATCH] fix(agent): use plain substitution for master_system prompt The prompt template contains a literal JSON example block ({"needs_clarification": ...}) which str.format() tried to interpret as format fields, raising KeyError on every Discuss DM. Switch to .replace() so braces in the template are taken literally. --- agent_service/agents/master_agent.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agent_service/agents/master_agent.py b/agent_service/agents/master_agent.py index d2e4acd..c8a8334 100644 --- a/agent_service/agents/master_agent.py +++ b/agent_service/agents/master_agent.py @@ -67,7 +67,9 @@ class MasterAgent: template = _load_prompt('master_system.txt') agent_list = chr(10).join( f'- {a["agent_key"]}: {a["capabilities_summary"]}' for a in active_agents) - return template.format(agent_list=agent_list) + # Plain substitution — the template contains literal { } from a JSON + # example block, so str.format would treat them as fields. + return template.replace('{agent_list}', agent_list) async def handle_message(self, user_id, channel_id, message, directive_id) -> MasterResponse: try: