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.
This commit is contained in:
Carlos Garcia
2026-04-24 23:12:51 -04:00
parent 4cbc4cc0f1
commit 67e6eff534

View File

@@ -67,7 +67,9 @@ class MasterAgent:
template = _load_prompt('master_system.txt') template = _load_prompt('master_system.txt')
agent_list = chr(10).join( agent_list = chr(10).join(
f'- {a["agent_key"]}: {a["capabilities_summary"]}' for a in active_agents) 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: async def handle_message(self, user_id, channel_id, message, directive_id) -> MasterResponse:
try: try: