fix(openclaw-plugin): run afterTurn auto-capture in background queue#875
Open
imleon wants to merge 1 commit intovolcengine:mainfrom
Open
fix(openclaw-plugin): run afterTurn auto-capture in background queue#875imleon wants to merge 1 commit intovolcengine:mainfrom
imleon wants to merge 1 commit intovolcengine:mainfrom
Conversation
Move OpenViking auto-capture out of the synchronous afterTurn path so message delivery is not blocked by extraction latency. Keep capture behavior/logging intact and process capture jobs sequentially per session via an in-memory queue to avoid concurrent session contention. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Failed to generate code suggestions for PR |
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.
Summary
This PR makes OpenViking auto-capture non-blocking in the OpenClaw context-engine path.
Previously,
afterTurnawaited the full auto-capture pipeline (createSession -> addSessionMessage -> extractSessionMemories -> deleteSession), which could delay final message delivery in chatchannels when extraction was slow.
This change moves auto-capture to an in-memory background queue keyed by session, so user-facing reply completion is no longer blocked by capture latency.
What changed
examples/openclaw-plugin/context-engine.tssessionKey?: stringtoafterTurnparams typing.runAutoCapture(...)(behavior/logging kept intact).enqueueAutoCapture(...)with per-session sequential queue:afterTurn(...)to enqueue and return immediately (no synchronous wait on extraction).Why
In real traffic, slow capture/extraction could create a visible gap between model completion and final message/card completion.
By decoupling capture from the synchronous
afterTurnreturn path, we preserve memory capture while removing user-visible blocking.Behavior impact
capture-check,auto-captured,capture-detail, error/warn logs)Validation
Manual log-based validation in Feishu/OpenClaw integration:
agent endcould be followed by several seconds ofopenviking auto-captureactivity before finaldeliver calleddeliver called/ finalization proceeds immediately; auto-capture runs in background and logs later if neededRisks / trade-offs
中文说明(简版)
1) 问题背景
当前
afterTurn会同步等待 auto-capture 全流程(创建会话、写入消息、提取记忆、删除会话)。当提取较慢时,会拖慢用户可见的最终回包/卡片完成时机,出现“模型结束后还要等几秒”的体验问题。2) 本次改动
将 auto-capture 从同步链路改为后台队列执行:
afterTurn只负责入队并立即返回;实际提取逻辑在后台运行。队列按sessionKey/sessionId串行,确保同会话内不并发冲突;原有日志与捕获逻辑保持不变。3) 效果与取舍
效果是显著降低用户侧感知延迟,最终回包不再被 auto-capture 阻塞。取舍是队列为内存态,进程异常退出时未完成任务可能丢失;本 PR 优先保障在线响应时延,不引入更重的持久化任务系统。