-
Notifications
You must be signed in to change notification settings - Fork 0
fix: ignore unknown resolved warning IDs #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| import logging | ||
| from collections import deque | ||
| from collections.abc import Callable | ||
| from dataclasses import dataclass | ||
| from dataclasses import dataclass, replace | ||
| from typing import Literal, Protocol | ||
|
|
||
| import pendulum | ||
|
|
@@ -374,6 +374,8 @@ async def _run( | |
| historical_context_payload, | ||
| active_warnings, | ||
| ) | ||
| active_warning_ids = {warning.id for warning in active_warnings} | ||
| payload["allowed_resolved_warning_ids"] = sorted(active_warning_ids) | ||
| briefing_limit = self._delivery.briefing_limit(self._settings.briefing_max_characters) | ||
| payload["output_constraints"] = {"briefing_max_characters": briefing_limit} | ||
| required_advice_topics = _required_advice_topics(kind, context) | ||
|
|
@@ -385,14 +387,8 @@ async def _run( | |
| ) | ||
| allergen_source_ids = {document.id for document in context if document.has_allergen_information} | ||
| valid_source_ids = {article.id for article in source_articles} | {document.id for document in reference_context} | ||
| active_warning_ids = {warning.id for warning in active_warnings} | ||
|
|
||
| def validate_result(candidate: BriefingResult) -> None: | ||
| unknown_resolved_warning_ids = set(candidate.resolved_warning_ids) - active_warning_ids | ||
| if unknown_resolved_warning_ids: | ||
| raise LLMError( | ||
| f"resolved_warning_ids contains unknown warning IDs: {sorted(unknown_resolved_warning_ids)}" | ||
| ) | ||
| candidate_message = self._delivery.render_briefing(candidate, source_articles, reference_context) | ||
| if kind == "briefing" and candidate.advice: | ||
| raise LLMError("briefing must not repeat lifestyle advice") | ||
|
|
@@ -413,6 +409,18 @@ def validate_result(candidate: BriefingResult) -> None: | |
| ) | ||
|
|
||
| result = await self._summarize(payload, now, valid_source_ids, validator=validate_result) | ||
| unknown_resolved_warning_ids = set(result.resolved_warning_ids) - active_warning_ids | ||
| if unknown_resolved_warning_ids: | ||
| _LOGGER.warning( | ||
| "Ignoring %d distinct resolved warning ID(s) that are not currently active", | ||
| len(unknown_resolved_warning_ids), | ||
| ) | ||
| result = replace( | ||
| result, | ||
| resolved_warning_ids=tuple( | ||
| warning_id for warning_id in result.resolved_warning_ids if warning_id in active_warning_ids | ||
| ), | ||
| ) | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Comment on lines
+412
to
+423
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Raw_payload diverges after filtering After filtering out unknown resolved warning IDs, the service updates only BriefingResult.resolved_warning_ids but leaves BriefingResult.raw_payload containing the original (unfiltered) resolved_warning_ids. This makes raw_payload inconsistent with the persisted/effective result and unsafe to treat as the canonical post-normalization representation. Agent Prompt
|
||
| message = self._delivery.render_briefing( | ||
| result, | ||
| source_articles, | ||
|
|
@@ -547,6 +555,7 @@ async def _summarize( | |
| repair_payload: dict[str, object] = { | ||
| "original_input": payload, | ||
| "allowed_source_ids": sorted(valid_source_ids), | ||
| "allowed_resolved_warning_ids": payload["allowed_resolved_warning_ids"], | ||
| } | ||
| if raw_result is not None: | ||
| repair_payload["previous_invalid_response"] = raw_result | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.