Agent Zero AI framework
refactor: remove intervene_soft/hard dispatch actions, simplify to new_chat and continue
linuztx3868c85aee1f
diff --git a/plugins/_email_integration/helpers/dispatcher.py b/plugins/_email_integration/helpers/dispatcher.pyindex 60c01e79a..06d7aa9b7 100644--- a/plugins/_email_integration/helpers/dispatcher.py+++ b/plugins/_email_integration/helpers/dispatcher.py@@ -24,7 +24,7 @@ CTX_EMAIL_ATTACHMENTS = "_email_response_attachments"BODY_PREVIEW_MAX_CHARS: int = 2000-DispatchAction = Literal["new_chat", "continue_chat", "intervene_soft", "intervene_hard"]+DispatchAction = Literal["new_chat", "continue_chat"]@dataclass@@ -96,8 +96,6 @@ def parse_dispatcher_response(response: str) -> DispatchDecision:action_map: dict[str, DispatchAction] = {"NEW_CHAT": "new_chat","CONTINUE": "continue_chat",- "INTERVENE_SOFT": "intervene_soft",- "INTERVENE_HARD": "intervene_hard",}action = action_map.get(action_raw, "new_chat")return DispatchDecision(action=action, context_id=ctx_id, reason=reason)diff --git a/plugins/_email_integration/helpers/handler.py b/plugins/_email_integration/helpers/handler.pyindex 8d2cde586..6376042b3 100644--- a/plugins/_email_integration/helpers/handler.py+++ b/plugins/_email_integration/helpers/handler.py@@ -152,28 +152,23 @@ async def _dispatch_message(agent: Agent, handler_cfg: dict, msg: InboundMessagefor chat in existing:if chat["thread_id"] == thread_id:await _route_to_chat(- agent, handler_cfg, msg, chat["context_id"], "continue_chat",+ agent, handler_cfg, msg, chat["context_id"],)return# Dispatcher AI decidesdecision = await _call_dispatcher(agent, handler_cfg, msg, existing)- if decision.action == "new_chat":- await _start_new_chat(agent, handler_cfg, msg)- elif decision.action in ("continue_chat", "intervene_soft", "intervene_hard"):+ if decision.action == "continue_chat" and decision.context_id:ctx = AgentContext.get(decision.context_id)- if not ctx:- PrintStyle.warning(- f"Dispatcher referenced unknown context {decision.context_id}, starting new chat"- )- await _start_new_chat(agent, handler_cfg, msg)- else:- await _route_to_chat(- agent, handler_cfg, msg, decision.context_id, decision.action,- )- else:- await _start_new_chat(agent, handler_cfg, msg)+ if ctx:+ await _route_to_chat(agent, handler_cfg, msg, decision.context_id)+ return+ PrintStyle.warning(+ f"Dispatcher referenced unknown context {decision.context_id}, starting new chat"+ )++ await _start_new_chat(agent, handler_cfg, msg)async def _call_dispatcher(@@ -253,7 +248,6 @@ async def _route_to_chat(handler_cfg: dict,msg: InboundMessage,context_id: str,- action: disp.DispatchAction,):context = AgentContext.get(context_id)if not context:@@ -263,37 +257,15 @@ async def _route_to_chat(if msg.references:context.data[disp.CTX_EMAIL_REFERENCES] = msg.references- if action == "intervene_soft":- soft_msg = agent.read_prompt(- "fw.email.intervene_soft.md",- sender=msg.sender,- subject=msg.subject,- body=msg.body,- )- mq.add(context, soft_msg, msg.attachments)- PrintStyle.info(f"Email: queued soft intervention for chat {context_id}")-- elif action == "intervene_hard":- user_msg = _build_user_message(agent, msg, handler_cfg)- system_ctx = agent.read_prompt("fw.email.system_context.md")- mq.log_user_message(context, user_msg, msg.attachments or [], source=" (email)")- context.communicate(UserMessage(- message=user_msg,- system_message=[system_ctx],- attachments=msg.attachments,- ))- PrintStyle.info(f"Email: hard intervention on chat {context_id}")-- else:- user_msg = _build_user_message(agent, msg, handler_cfg)- mq.log_user_message(context, user_msg, msg.attachments or [], source=" (email)")- context.communicate(UserMessage(- message=user_msg,- attachments=msg.attachments,- ))- PrintStyle.info(f"Email: continuing chat {context_id}")+ user_msg = _build_user_message(agent, msg, handler_cfg)+ mq.log_user_message(context, user_msg, msg.attachments or [], source=" (email)")+ context.communicate(UserMessage(+ message=user_msg,+ attachments=msg.attachments,+ ))save_tmp_chat(context)+ PrintStyle.info(f"Email: continuing chat {context_id}")# ------------------------------------------------------------------diff --git a/plugins/_email_integration/prompts/fw.email.dispatcher_system.md b/plugins/_email_integration/prompts/fw.email.dispatcher_system.mdindex 43932d4a6..cd133153b 100644--- a/plugins/_email_integration/prompts/fw.email.dispatcher_system.md+++ b/plugins/_email_integration/prompts/fw.email.dispatcher_system.md@@ -3,8 +3,6 @@ You receive: the new email (sender, subject, body) and a list of existing chatsRules:- If the email content clearly relates to an existing chat (same topic, same sender), reply with CONTINUE and that chat's context_id-- If the email is a status question or low-priority follow-up on a running chat, reply with INTERVENE_SOFT and the context_id — the agent will receive it after current step-- If the email is urgent and requires immediate attention on a running chat, reply with INTERVENE_HARD and the context_id- Otherwise reply with NEW_CHATUse conversation history to determine topic relevance when matching emails to chats.@@ -15,5 +13,3 @@ ACTION context_id reasonExamples:NEW_CHAT _ new request from userCONTINUE ctx_abc123 same sender discussing AWS deployment-INTERVENE_SOFT ctx_abc123 user asking for status update-INTERVENE_HARD ctx_abc123 urgent correction neededdiff --git a/plugins/_email_integration/prompts/fw.email.intervene_soft.md b/plugins/_email_integration/prompts/fw.email.intervene_soft.mddeleted file mode 100644index b3115d890..000000000--- a/plugins/_email_integration/prompts/fw.email.intervene_soft.md+++ /dev/null@@ -1,5 +0,0 @@-[Email from {{sender}}] user following up, respond and continue current work--Subject: {{subject}}--{{body}}