Repository navigation
fix(core): null-guard SessionRecorder on the legacy-history path (#3771) - #3832
Merged
Merged
Conversation
BUILDER_AGENT_API_LEGACY_HISTORY=true(走 AgentStateStore 槽位, 无 SessionLog)时,RuntimeContext 可挂载 SessionExecution 而无 SessionRecorder。三处在 recorder 上无条件解引用: - SessionExecution.beforeStep(recorder, state):acceptedMessageIds() NPE——报错的直接来源(栈上由中间件的 doOnError 记录,归因前缀是 trace 中间件名,实际抛点在 core) - settleSession 的 execution.continueOrClose(recorder) - closeFailedSessionExecution 的 recorder.close()(错误清理自身 NPE) 三处补 null 防护:recorder 缺席即跳过 journal 记账(legacy 模式 本无 journal 可维护),与 releaseCallExecution 既有判空纪律一致。 legacy 路径的 turn 得以正常执行并写状态快照。 Fixes agentscope-ai#3771
juruoO-o
approved these changes
Nov 12, 2026
juruoO-o
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed null-recorder guards on the legacy-history reasoning, settlement and error-cleanup paths. A focused legacy regression test would be a useful follow-up.
No blocking findings in the reviewed diff. This was a static review of source and tests; local Java/Maven tests were not run.
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.
Fixes #3771
Root cause
Under
BUILDER_AGENT_API_LEGACY_HISTORY=true(AgentStateStore slots, no SessionLog), theRuntimeContextcan carry aSessionExecutionwithout aSessionRecorder. Three sites dereferenced the recorder unconditionally:SessionExecution.beforeStep(recorder, state)—recorder.acceptedMessageIds()→ the reported NPE. Note the stack attribution: the trace middleware'sdoOnErrorlogs it under its name ([opencode-coding-p]), but the throw site is in core.settleSession→execution.continueOrClose(SessionRecorder.from(rc)).closeFailedSessionExecution→recorder.close()— an NPE inside the error-cleanup path itself.Fix
Null-guards at all three sites: when the recorder is absent, the journal bookkeeping is skipped (legacy mode has no journal to maintain) — matching the existing discipline at
releaseCallExecution(if (recorder == null) return Mono.empty()). Legacy turns execute and write state snapshots normally.Verification
The exact repro (legacy mode, first and subsequent turns) requires the service dataplane + Redis compose stack; the guard shape mirrors already-proven null-checks in the same file's lifecycle methods. A unit-level repro of the beforeStep path with a null recorder is straightforward if maintainers want it — happy to add on request.