-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(session): propagate extractor failures to async task error #511
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
Changes from all commits
dd13b68
798a7d1
645bcc8
769b31f
39c036d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,8 +231,14 @@ async def extract( | |
| context: dict, | ||
| user: UserIdentifier, | ||
| session_id: str, | ||
| *, | ||
| strict: bool = False, | ||
| ) -> List[CandidateMemory]: | ||
| """Extract memory candidates from messages.""" | ||
| """Extract memory candidates from messages. | ||
|
|
||
| When ``strict`` is True, extraction failures are re-raised as | ||
| ``RuntimeError`` so async task tracking can mark tasks as failed. | ||
| """ | ||
| user = user | ||
| vlm = get_openviking_config().vlm | ||
| if not vlm or not vlm.is_available(): | ||
|
|
@@ -342,8 +348,19 @@ async def extract( | |
|
|
||
| except Exception as e: | ||
| logger.error(f"Memory extraction failed: {e}") | ||
| if strict: | ||
| raise RuntimeError(f"memory_extraction_failed: {e}") from e | ||
| return [] | ||
|
|
||
| async def extract_strict( | ||
| self, | ||
| context: dict, | ||
| user: UserIdentifier, | ||
| session_id: str, | ||
| ) -> List[CandidateMemory]: | ||
| """Compatibility wrapper: strict mode delegates to ``extract``.""" | ||
| return await self.extract(context, user, session_id, strict=True) | ||
|
|
||
| async def create_memory( | ||
| self, | ||
| candidate: CandidateMemory, | ||
|
Collaborator
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. [Bug] 这意味着后续对 建议通过在 async def extract(
self, context, user, session_id, *, strict: bool = False
) -> List[CandidateMemory]:
# ... existing logic ...
except Exception as e:
logger.error(f"Memory extraction failed: {e}")
if strict:
raise RuntimeError(f"memory_extraction_failed: {e}") from e
return []然后 |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion]
strict_extract_errors=True时异常会直接从extract_long_term_memories抛出,调用方commit_async()(session.py:338)没有 try/catch,而是依赖外层 task tracker 来捕获。这个假设本身是合理的,但建议至少在此处或
commit_async中加一行注释说明 "extraction errors intentionally propagate to caller (task tracker)",避免后续维护者误以为遗漏了异常处理而加上 try/catch 吞掉错误。