You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added exception_to_raise variable to capture exceptions when no fallback is provided
Added re-raise logic after the finally block to propagate the original exception while still emitting the FAILED status log
Preserves exception identity and chain (no synthetic wrapping)
Also fixed timed decorator to use @functools.wraps to preserve function metadata
tests/test_utils_timing.py - Updated tests:
Modified test_failure_logging_no_fallback to assert that exceptions propagate (added pytest.raises)
Added test_failure_no_fallback_preserves_original_exception to verify exception identity is preserved
Added test_preserves_function_metadata for the @timed decorator fix
Root cause: The previous fix (commit 77eeb31 on branch autodev/MemOS-1845) was never merged into dev-20260604-v2.0.19. This fix reapplies that solution.
Verification: Manual logic testing confirms the fix works correctly - exceptions now propagate when no fallback is provided, while fallback behavior remains unchanged. Python syntax validation passed.
Activity
Memtensor-AI commentedon Jun 1, 2026
✅ AutoDev task
792038493a2f4ee7completed.Summary: 修复
src/memos/utils.py::timed_with_status的静默吞异常 bug。原行为:当未传fallback时,被装饰函数抛出的异常会被except捕获后丢失,包装器返回None——这正是format_utils.py:1410-1415里那条"clean_json_response received None — upstream LLM call likely failed silently"防御注释指控的源头。新行为:未传fallback时,先在finally内照常打[TIMER_WITH_STATUS] ... status: FAILED日志,再把原异常重新抛出,traceback /__cause__/__context__保持不变;传了fallback时路径完全不变。顺手给timed装饰器补了functools.wraps,停止把__name__/__doc__弄丢。生产侧受影响的两个调用点
OpenAILLM.generate/generate_stream函数体内本来就有raise,装饰器现在终于把这个意图传到上层;另外三个用了fallback的调用点 (UniversalAPIEmbedder.get_embeddings、HttpBGEReranker.rerank) 行为零变化。测试改动:把原
test_failure_logging_no_fallback(之前以"应静默"为契约)改成断言异常需向上传播且 FAILED 日志仍要打;新增test_failure_no_fallback_preserves_original_exception(同对象身份 + 无合成链)和test_preserves_function_metadata(@timed元数据)。沙箱内无法跑make test(缺transformers等大依赖),用最小化memos命名空间桩跑pytest tests/test_utils_timing.py得33 passed;并把修复回滚为旧实现重跑两条新用例,两条均按预期DID NOT RAISE红——TDD 证据完整。ruff check/ruff format --check在改动文件上均通过;本地分支已 push 到origin/autodev/MemOS-1845。specs 仓库归档了00-decision.md/01-clarification.md/03-fix.md/04-integration-report.md。Base branch:
dev-20260604-v2.0.19Branch:
autodev/MemOS-1845Commit:
77eeb31PR: #1846
Assigned to: @CarltonXiang, @syzsunshine219
Reviewers: @CarltonXiang, @syzsunshine219
Memtensor-AI commentedon Jun 4, 2026
🤖 AutoDev has picked up this issue and started working on it.
Task ID:
792038493a2f4ee7Working branch:
bugfix/autodev-1845Target branch:
dev-20260604-v2.0.19Workflow: opsp (analysis → coding → testing → PR)
I will post the PR link here once done. If I need more information, I will ask in the comments.
fix(utils): re-raise exception in timed_with_status when no fallback (#…
Memtensor-AI commentedon Jun 4, 2026
✅ AutoDev task
792038493a2f4ee7completed.Summary: Fixed the
timed_with_statusdecorator bug where exceptions were silently swallowed when no fallback was provided.Changes made:
src/memos/utils.py - Fixed
timed_with_statusdecorator:exception_to_raisevariable to capture exceptions when no fallback is providedfinallyblock to propagate the original exception while still emitting the FAILED status logtimeddecorator to use@functools.wrapsto preserve function metadatatests/test_utils_timing.py - Updated tests:
test_failure_logging_no_fallbackto assert that exceptions propagate (addedpytest.raises)test_failure_no_fallback_preserves_original_exceptionto verify exception identity is preservedtest_preserves_function_metadatafor the@timeddecorator fixRoot cause: The previous fix (commit 77eeb31 on branch autodev/MemOS-1845) was never merged into dev-20260604-v2.0.19. This fix reapplies that solution.
Verification: Manual logic testing confirms the fix works correctly - exceptions now propagate when no fallback is provided, while fallback behavior remains unchanged. Python syntax validation passed.
Base branch:
dev-20260604-v2.0.19Branch:
bugfix/autodev-1845Commit:
c3fdf3bPR: #1881
Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219
Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219