Repository navigation
fix: guard repeated ASR noise and ground reminders and recap outcomes - #24415
Merged
Merged
Conversation
# Conflicts: # backend/tests/unit/test_conversation_relevance.py # backend/tests/unit/test_conversation_relevance_rules.py
There was a problem hiding this comment.
3 issues found across 11 files
Confidence score: 3/5
backend/utils/conversations/relevance_rules.pystrips quote markers before matching, so quoted outro phrases can be discarded despite the contract that they should abstain. Preserve or reject the quote markers before matching.backend/tests/unit/test_conversation_relevance_rules.pyonly checks that this rule did not fire, so another rule could still discard the utterance and the test would pass. Assert the expected verdict too.backend/utils/llm/external_integrations.pyasks the daily-summary model to preserve transcript-supported outcomes, but the prompt supplies no transcripts. Align that instruction with the supplied notes and events so cancellation and delay outcomes are grounded in the available input.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/test_conversation_relevance_rules.py">
<violation number="1" location="backend/tests/unit/test_conversation_relevance_rules.py:148">
P3: This test only asserts the rule is not `repeated_asr_outro`, so a verdict flip to `discard` via another rule would pass. Assert the verdict as well, e.g. `in (None, 'keep')`, to match the verdict-based style of `test_verdict`.</violation>
</file>
<file name="backend/utils/conversations/relevance_rules.py">
<violation number="1" location="backend/utils/conversations/relevance_rules.py:219">
P2: `repeated_asr_outros` strips quote characters before matching, so three quoted outro utterances are discarded even though the contract says quoted phrases abstain. Preserve or reject quote markers before matching.</violation>
</file>
<file name="backend/utils/llm/external_integrations.py">
<violation number="1" location="backend/utils/llm/external_integrations.py:544">
P3: The daily-summary prompt has no raw transcripts, but this addition asks the model to preserve “transcript-supported” outcomes. Refer to supplied notes/events or include transcripts so cancellations and delays remain verifiable.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
|
|
||
| def repeated_asr_outros(texts: Sequence[str]) -> bool: | ||
| utterances = [re.sub(r'[^\w\s]', '', unicodedata.normalize('NFKC', text).casefold()).strip() for text in texts] |
There was a problem hiding this comment.
P2: repeated_asr_outros strips quote characters before matching, so three quoted outro utterances are discarded even though the contract says quoted phrases abstain. Preserve or reject quote markers before matching.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/conversations/relevance_rules.py, line 219:
<comment>`repeated_asr_outros` strips quote characters before matching, so three quoted outro utterances are discarded even though the contract says quoted phrases abstain. Preserve or reject quote markers before matching.</comment>
<file context>
@@ -204,6 +204,23 @@ def _tokenise(texts: Sequence[str]) -> Tuple[List[str], List[str], List[str]]:
+
+
+def repeated_asr_outros(texts: Sequence[str]) -> bool:
+ utterances = [re.sub(r'[^\w\s]', '', unicodedata.normalize('NFKC', text).casefold()).strip() for text in texts]
+ utterances = [' '.join(text.split()) for text in utterances if text]
+ return len(utterances) >= 3 and all(text in _ASR_OUTROS for text in utterances)
</file context>
Suggested change
| utterances = [re.sub(r'[^\w\s]', '', unicodedata.normalize('NFKC', text).casefold()).strip() for text in texts] | |
| if any( | |
| mark in text | |
| for text in texts | |
| for mark in ('"', "'", '`', '“', '”', '‘', '’', '«', '»', '‹', '›') | |
| ): | |
| return False | |
| utterances = [ | |
| re.sub(r'[^\w\s]', '', unicodedata.normalize('NFKC', text).casefold()).strip() for text in texts | |
| ] |
| ], | ||
| ) | ||
| def test_outro_rule_preserves_real_or_uncertain_speech(texts): | ||
| assert deterministic_relevance(texts, None)[1] != 'repeated_asr_outro' |
There was a problem hiding this comment.
P3: This test only asserts the rule is not repeated_asr_outro, so a verdict flip to discard via another rule would pass. Assert the verdict as well, e.g. in (None, 'keep'), to match the verdict-based style of test_verdict.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_conversation_relevance_rules.py, line 148:
<comment>This test only asserts the rule is not `repeated_asr_outro`, so a verdict flip to `discard` via another rule would pass. Assert the verdict as well, e.g. `in (None, 'keep')`, to match the verdict-based style of `test_verdict`.</comment>
<file context>
@@ -121,3 +121,28 @@ def test_cjk_only_tiebreak_never_discards_unknown_content(text):
+ ],
+)
+def test_outro_rule_preserves_real_or_uncertain_speech(texts):
+ assert deterministic_relevance(texts, None)[1] != 'repeated_asr_outro'
</file context>
Suggested change
| assert deterministic_relevance(texts, None)[1] != 'repeated_asr_outro' | |
| assert deterministic_relevance(texts, None)[0] in (None, 'keep') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by: @dazheng
Implemented by: Codex
What changed and why
Weekly quality dogfooding found repeated ASR outro cards, reminder requests becoming durable memories, and calendar plans described as completed events. The shared deterministic relevance rule now rejects repeated exact outro-only runs while preserving mixed speech and existing restore/photo/calendar protections. Notes/task/memory/daily-summary prompts distinguish explicit reminders, current-session agent instructions, background meetings, and calendar plans versus observed outcomes.
Addresses the scoped safeguards in quality 02, 05, 06, 07; closes the prompt-contract portions of 05 (calendar as context) and 07 (explicit reminder admission). These changes are on by default. Model recall and real-world quality have not been scored, and this PR does not claim those whole categories fixed.
The proposal in
backend/docs/weekly-dogfooding-quality-proposal.mdgives one-line disposition for every API/quality item plus acceptance evidence for wearer identity, cross-device merges, settled-day summaries, visible-memory counters, and producer watermarks. No heuristic relabeling, broad transcript deletion, or fuzzy time-only merge is introduced.Companion API/MCP PR: #24418.
Product invariants affected
INV-MEM-4. Reminder-only requests are excluded from fact extraction at the existing extractor boundary; canonical intake and promotion remain owned by their existing authorities.
How it was verified
BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/weekly-quality-tests.txt bash backend/test.shthroughomi-heavy; repositorymake preflightand PR metadata preflight.Tests
CI follow-up: all baseline static prompt variants are refreshed for the intentional reminder/calendar rules. Both fixture consumers pass locally (9 episode tests and 80 title tests), as does the 27-test notes suite. Hermetic Backend E2E passed in CI at
11d71cd8082(run 41497006845), after an initial provider-startup WebSocket teardown cancellation. Full local and isolated provider-startup E2E runs hit the harness's 120-second timeout; local E2E remains a validation limitation. The Sync Cloud Tasks gauntlet on that CI run failed its five-minute checkout timeout before executing tests. Final-head CI at5595762c916settled green with no failed or pending checks (unit/hermetic CI, not live production validation).Regression coverage: test_conversation_relevance_rules, test_conversation_relevance, test_conversation_notes_v2, test_daily_summary_depth_prompt, and test_working_observations_extractor. Existing owner-neutral prompt tests also pass.
UI-Evidence: none -- backend relevance and prompt contracts only
Failure-Class: none