mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-06 06:52:20 +02:00
skip redundant synthesis after email actions
This commit is contained in:
+32
-1
@@ -6211,6 +6211,34 @@ def _email_fact_lookup_requested(user_text: str) -> bool:
|
||||
))
|
||||
|
||||
|
||||
_EMAIL_TERMINAL_ACTION_TOOLS = {
|
||||
"draft_email",
|
||||
"mcp__email__draft_email",
|
||||
"draft_email_reply",
|
||||
"mcp__email__draft_email_reply",
|
||||
"ai_draft_email_reply",
|
||||
"mcp__email__ai_draft_email_reply",
|
||||
"send_email",
|
||||
"mcp__email__send_email",
|
||||
"reply_to_email",
|
||||
"mcp__email__reply_to_email",
|
||||
}
|
||||
|
||||
|
||||
def _email_lookup_needs_post_synthesis(
|
||||
user_text: str,
|
||||
tool_events: list[dict[str, Any]],
|
||||
) -> bool:
|
||||
"""Avoid a redundant lookup synthesis after a completed email action."""
|
||||
if not _email_fact_lookup_requested(user_text):
|
||||
return False
|
||||
return not any(
|
||||
_resolved_tool_event_name(event) in _EMAIL_TERMINAL_ACTION_TOOLS
|
||||
and tool_result_is_successful(event)
|
||||
for event in (tool_events or [])
|
||||
)
|
||||
|
||||
|
||||
def _email_attachment_summaries_from_tool_events(tool_events: list[dict[str, Any]]) -> list[str]:
|
||||
summaries: list[str] = []
|
||||
for event in tool_events or []:
|
||||
@@ -36447,7 +36475,10 @@ async def stream_agent_loop(
|
||||
if _resolved_tool_event_name(event) in {"read_email", "mcp__email__read_email"}
|
||||
and tool_result_is_successful(event)
|
||||
]
|
||||
if _email_lookup_events and _email_fact_lookup_requested(_email_lookup_request):
|
||||
if _email_lookup_events and _email_lookup_needs_post_synthesis(
|
||||
_email_lookup_request,
|
||||
tool_events,
|
||||
):
|
||||
_email_evidence_parts: list[str] = []
|
||||
_email_evidence_chars = 0
|
||||
for _event in _email_lookup_events[-8:]:
|
||||
|
||||
@@ -4,6 +4,7 @@ from mcp_servers.email_server import _extract_text as mcp_extract_text
|
||||
from routes.email_helpers import _extract_text as route_extract_text
|
||||
from src.agent_loop import (
|
||||
_email_fact_lookup_requested,
|
||||
_email_lookup_needs_post_synthesis,
|
||||
_email_lookup_request_from_messages,
|
||||
_email_read_evidence_from_tool_output,
|
||||
)
|
||||
@@ -45,6 +46,20 @@ def test_email_fact_lookup_does_not_capture_explicit_read_request():
|
||||
assert not _email_fact_lookup_requested("Read the email to me")
|
||||
|
||||
|
||||
def test_successful_draft_suppresses_redundant_email_lookup_synthesis():
|
||||
events = [
|
||||
{"tool": "mcp__email__read_email", "exit_code": 0, "output": "Price: $42"},
|
||||
{"tool": "mcp__email__draft_email", "exit_code": 0, "output": "Draft created"},
|
||||
]
|
||||
|
||||
assert not _email_lookup_needs_post_synthesis(
|
||||
"Read the bid, determine the winner, and draft a recommendation", events
|
||||
)
|
||||
assert _email_lookup_needs_post_synthesis(
|
||||
"What price was quoted in the email?", events[:1]
|
||||
)
|
||||
|
||||
|
||||
def test_email_lookup_evidence_strips_html_and_is_bounded():
|
||||
raw = (
|
||||
"**Subject:** Property settlement\n"
|
||||
|
||||
Reference in New Issue
Block a user