1212 "incident_description:" ,
1313)
1414
15+ _ON_SCREEN_FRAMING = (
16+ "A read-only discovery command was just run to answer the user's question; "
17+ "its output is below. Summarize it to answer the user's question directly, "
18+ "citing the relevant status. The output is already on screen, so keep "
19+ "**Here's what that looks like:** brief or omit it when it would repeat "
20+ "what the user just saw. Still end with **Want me to:** and a specific "
21+ "next step tied to the finding (for integration questions: connect another "
22+ "integration, verify a failed service, or set up a missing one)."
23+ )
24+
25+ _ON_SCREEN_FRAMING_NO_WANT_ME_TO = (
26+ "A read-only discovery command was just run to answer the user's question; "
27+ "its output is below. Summarize it to answer the user's question directly, "
28+ "citing the relevant status. The output is already on screen, so keep "
29+ "**Here's what that looks like:** brief or omit it when it would repeat "
30+ "what the user just saw."
31+ )
32+
33+ _OFF_SCREEN_FRAMING = (
34+ "Live data was just gathered from the connected integrations to answer the "
35+ "user's question; the tool results are below and are NOT otherwise shown to "
36+ "the user. Answer using the three-part response shape from the system "
37+ "prompt: **I found:**, **Here's what that looks like:**, and **Want me to:** "
38+ "with a specific next step. Cite concrete findings (issues, log lines, or "
39+ "metrics). If the data does not contain the answer, say so plainly. You have "
40+ "ALREADY queried the connected sources, so do NOT tell the user to paste an "
41+ "alert or to run `opensre investigate`; instead report what each source "
42+ "returned and, if you need more signal, ask for the specific detail (error "
43+ "string, service, version, or time window) that would let you narrow it down "
44+ "here."
45+ )
46+
47+ _OFF_SCREEN_FRAMING_NO_WANT_ME_TO = (
48+ "Live data was just gathered from the connected integrations to answer the "
49+ "user's question; the tool results are below and are NOT otherwise shown to "
50+ "the user. Answer using **I found:** and **Here's what that looks like:** — "
51+ "omit **Want me to:** entirely (an outer session goal owns continuation). "
52+ "Cite concrete findings (issues, log lines, or metrics). If the data does "
53+ "not contain the answer, say so plainly. You have ALREADY queried the "
54+ "connected sources, so do NOT tell the user to paste an alert or to run "
55+ "`opensre investigate`; instead report what each source returned and, if "
56+ "you need more signal, ask for the specific detail (error string, service, "
57+ "version, or time window) that would let you narrow it down here."
58+ )
59+
60+ _CLOSER_WANT_ME_TO = (
61+ "Do NOT request, plan, or emit any further tool calls or actions in this "
62+ "turn — phrase next steps only as prose in **Want me to:**."
63+ )
64+
65+ _CLOSER_NO_WANT_ME_TO = (
66+ "Do NOT request, plan, or emit any further tool calls or actions in this "
67+ "turn. Do NOT close with **Want me to:** — phrase any next diagnostic step "
68+ "as plain prose in the body if the goal asks for it."
69+ )
70+
1571
1672def _guidance_for_handoff_tag (tag : str ) -> str | None :
1773 """Resolve exact handoff tags, then known prefixes (e.g. ``database_query:``)."""
@@ -33,40 +89,25 @@ def build_handoff_guidance_block(handoff_contents: tuple[str, ...]) -> str:
3389 return "" .join (blocks )
3490
3591
36- def build_observation_block (tool_observation : str | None , * , on_screen : bool = True ) -> str :
37- """Wrap freshly-gathered tool output so the assistant summarizes it directly."""
92+ def build_observation_block (
93+ tool_observation : str | None ,
94+ * ,
95+ on_screen : bool = True ,
96+ omit_want_me_to : bool = False ,
97+ ) -> str :
98+ """Wrap freshly-gathered tool output so the assistant summarizes it directly.
99+
100+ When ``omit_want_me_to`` is true (outer session goal active), skip the
101+ Want-me-to closer — the host loop owns continuation.
102+ """
38103 if not tool_observation or not tool_observation .strip ():
39104 return ""
40105 if on_screen :
41- framing = (
42- "A read-only discovery command was just run to answer the user's question; "
43- "its output is below. Summarize it to answer the user's question directly, "
44- "citing the relevant status. The output is already on screen, so keep "
45- "**Here's what that looks like:** brief or omit it when it would repeat "
46- "what the user just saw. Still end with **Want me to:** and a specific "
47- "next step tied to the finding (for integration questions: connect another "
48- "integration, verify a failed service, or set up a missing one)."
49- )
106+ framing = _ON_SCREEN_FRAMING_NO_WANT_ME_TO if omit_want_me_to else _ON_SCREEN_FRAMING
50107 else :
51- framing = (
52- "Live data was just gathered from the connected integrations to answer the "
53- "user's question; the tool results are below and are NOT otherwise shown to "
54- "the user. Answer using the three-part response shape from the system "
55- "prompt: **I found:**, **Here's what that looks like:**, and **Want me to:** "
56- "with a specific next step. Cite concrete findings (issues, log lines, or "
57- "metrics). If the data does not contain the answer, say so plainly. You have "
58- "ALREADY queried the connected sources, so do NOT tell the user to paste an "
59- "alert or to run `opensre investigate`; instead report what each source "
60- "returned and, if you need more signal, ask for the specific detail (error "
61- "string, service, version, or time window) that would let you narrow it down "
62- "here."
63- )
64- return (
65- f"{ framing } Do NOT request, plan, or emit any further tool calls or "
66- "actions in this turn — phrase next steps only as prose in "
67- "**Want me to:**.\n \n "
68- f"--- tool_results ---\n { tool_observation } \n \n "
69- )
108+ framing = _OFF_SCREEN_FRAMING_NO_WANT_ME_TO if omit_want_me_to else _OFF_SCREEN_FRAMING
109+ closer = _CLOSER_NO_WANT_ME_TO if omit_want_me_to else _CLOSER_WANT_ME_TO
110+ return f"{ framing } { closer } \n \n --- tool_results ---\n { tool_observation } \n \n "
70111
71112
72113# Legacy private name used by older tests.
0 commit comments