Skip to content

Commit e75b48e

Browse files
committed
fix(investigations): Make generated summaries friendlier
Ask for one or two short, conversational summary sentences while continuing to accept the previous three-line format during rollout.
1 parent a02a221 commit e75b48e

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/sentry/investigations/agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,9 +977,10 @@ def _maybe_start_title_generation(investigation: Investigation, user_id: int | N
977977
"Describe a completed Sentry investigation. Do not use tools. Return exactly one raw JSON "
978978
"object with the keys title, summary, and summary_description and no other text. title "
979979
"must identify the incident in at most 5 words. summary must state what happened in at "
980-
"most 10 words. summary_description must be 2 or 3 newline-separated, concise lines covering "
981-
"the investigation's key evidence and the most useful next steps for a human fixing the "
982-
"issue. Distinguish established facts from hypotheses and do not invent a cause. Put title "
980+
"most 10 words. summary_description must use casual, plain language in 1 or 2 short "
981+
"newline-separated sentences: lead with the strongest evidence and optionally add the most "
982+
"useful next step. Avoid headings and jargon. Distinguish established facts from hypotheses "
983+
"and do not invent a cause. Put title "
983984
"first in the JSON object. Do not call any function to write or save the result.\n"
984985
"<source_context>\n"
985986
f"{json.dumps(investigation_source(investigation))}\n</source_context>\n"
@@ -1121,7 +1122,7 @@ def _parse_completion_metadata(content: str) -> dict[str, str] | None:
11211122
if not (
11221123
1 <= len(title.split()) <= TITLE_WORD_LIMIT
11231124
and SUMMARY_MIN_WORDS <= len(summary.split()) <= SUMMARY_WORD_LIMIT
1124-
and 2 <= len(description_lines) <= 3
1125+
and 1 <= len(description_lines) <= 3
11251126
):
11261127
return None
11271128
summary_description = "\n".join(description_lines)

tests/sentry/investigations/test_agent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ def test_completion_metadata_accepts_concise_variable_summary_lengths() -> None:
5858
)
5959

6060

61+
def test_completion_metadata_accepts_single_line_description() -> None:
62+
assert (
63+
_parse_completion_metadata(
64+
completion_metadata(description="Checkout errors came from one endpoint.")
65+
)
66+
is not None
67+
)
68+
69+
6170
def test_completion_metadata_ignores_extra_keys() -> None:
6271
payload = json.loads(completion_metadata())
6372
payload["confidence"] = 0.9
@@ -1117,6 +1126,9 @@ def test_title_prompt_uses_specific_incident_source_context(
11171126
assert "checkout-api" in prompt
11181127
assert "at most 5 words" in prompt
11191128
assert "summary_description" in prompt
1129+
assert "casual, plain language" in prompt
1130+
assert "1 or 2 short" in prompt
1131+
assert "Avoid headings and jargon" in prompt
11201132

11211133
@patch("sentry.investigations.agent.record_investigation_completed")
11221134
@patch("sentry.investigations.agent.SeerAgentClient")

0 commit comments

Comments
 (0)