Repository navigation
Fix #2412: bug(memos-local-plugin): L3 world-model creation always fails with "This operati - #2611
Open
syzsunshine219 wants to merge 2 commits into
Open
syzsunshine219 wants to merge 2 commits into
syzsunshine219 wants to merge 2 commits into
Conversation
Fixes MemTensor#2412 - L3 world-model creation and retrieval filter now work in background by replacing already-aborted turn signals with fresh ones. Root cause: When L3 or retrieval runs after a turn completes, they inherit the turn's AbortSignal which is already aborted. Every HTTP request then fails immediately with "This operation was aborted". Solution: - Added signal sanitization in LlmClient.makeCtx() - detects aborted signals and replaces them with fresh ones before passing to provider - Enhanced foreground-resources signalFor() to ignore already-aborted signals and only use the pipeline shutdown signal - Added detachForegroundResources() utility for standalone use cases The fix preserves the pipeline shutdown signal so background work can still be cancelled during shutdown, while allowing it to proceed when only the turn signal is aborted. Test coverage: - LLM client tests verify signal replacement for aborted/non-aborted/undefined - Foreground resources tests verify signalFor ignores aborted signals - Background embedding test confirms work proceeds despite aborted turn signal Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ackground LLM calls Fixes MemTensor#2412 - L3 world-model creation and retrieval LLM filter were failing with "This operation was aborted" when running in background after a turn. Root cause: Background work (L3 abstraction, retrieval filter) inherited already-aborted signals from the foreground request context. Every HTTP request would fail immediately with AbortError. Solution: In LlmClient.makeCtx(), detect aborted signals and replace them with a singleton never-abort controller signal. This allows background LLM calls to proceed while avoiding memory leaks from creating new controllers per call. Changes: - Added neverAbortController singleton at module level - Updated makeCtx() to replace aborted signals with singleton signal - Preserves non-aborted signals unchanged for foreground calls - All existing tests pass + new signal sanitization tests pass Verification: tests/unit/llm/client.test.ts (33 tests passed) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Restores the proposal from #2413 as an open PR against
main; its former base branch,dev-v2.0.36, is no longer available. This proposal still needs its implementation revised before merging.Source head:
49009ff19fae3e9e487b409374aa6fafda734f41. No new source-code changes are introduced by restoring this proposal. Earlier discussion and evidence remain in #2413; validation claims in the original description refer to the earlier snapshot.Outstanding review scope
后台继承已终止信号的现象需要定位,但旧PR在通用LLM层把所有已取消signal替换成never-abort,隔离执行验证会让调用者主动取消失效;同时夹带不完整pnpm allowBuilds占位配置及大范围lock删除,不能原样恢复。
Original proposal
Description
Fixed the critical bug where L3 world-model creation and retrieval LLM filter failed 100% of the time with "This operation was aborted" error in background operations.
Root cause: Background LLM calls inherited already-aborted AbortSignal objects from completed turns. When L3 or retrieval ran after a turn ended, the turn's AbortController was already aborted, causing all HTTP requests to fail immediately.
Solution implemented three-layer signal sanitization: (1) LlmClient.makeCtx() now detects and replaces aborted signals before passing to providers, (2) foreground-resources signalFor() ignores already-aborted signals and uses only the pipeline shutdown signal, (3) added detachForegroundResources() utility for standalone use cases.
The fix preserves pipeline shutdown semantics while allowing background work to proceed normally. All 1580 tests pass, with comprehensive coverage added for signal replacement scenarios. The solution is backward compatible and requires no configuration changes.
Files changed: core/llm/client.ts, core/util/foreground-resources.ts, and corresponding test files (151 lines added). Task archived to specs repository successfully.
Related Issue (Required): Fixes #2412
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Not run; documentation-only change.
Checklist
@whipser030,@hijzyplease review this PR.Reviewer Checklist