Skip to content

fix(harness): propagate replay log write failures - #4139

Merged
juruoO-o merged 4 commits into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/workspace-log-append-failure
Nov 25, 2026
Merged

juruoO-o merged 4 commits into
agentscope-ai:mainfrom
pengmoubuaixuexi:fix/workspace-log-append-failure

Conversation

@pengmoubuaixuexi

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT; validated against main c8875287f808deb3cd0b3c2d85d671f1860fbbec.

Description

Fixes #4138.

When a filesystem backend returns a failed WriteResult, WorkspaceMessageBus.logAppend currently discards it and emits a successful entry-id cursor. sessionPublishEvent can then fan out a live event with that cursor although no replay entry exists.

Check WriteResult.isSuccess() and signal IllegalStateException with the backend diagnostic before capping or returning the cursor. The existing append-then-publish composition consequently does not publish on this failure. There is no interface, cursor, or successful-write format change.

An acknowledgement failure can follow an already-persisted write. Do not automatically retry or delete that uncertain entry. Document this boundary in the implementation Javadoc and EN/ZH distributed-store pages.

Regression evidence

WorkspaceMessageBusLogAppendFailureTest uses a temporary local filesystem and a deterministic write-result override; no model, service, or credentials.

  • Four cases cover ordinary failures/create-if-absent conflicts, with/without capping.
  • A failed append preserves old entries and subsequent successful appends recover.
  • A successful append returns its persisted entry's cursor.
  • A failed session-event append does not fan out a live event.
  • A write that persists bytes and then reports failure preserves both the old and uncertain entry, without capping/cleanup/retry.

The final eight cases on unmodified production code: 7 assertion failures / 0 errors, successful-write control passes. After the fix: 8/8 pass. The existing plus new bus classes: 40/40 pass.

Validation

Windows 11 / Temurin 17.0.15 / Maven 3.9.12, JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8:

mvn -B -T1C -pl :agentscope-harness -am -Dtest=WorkspaceMessageBusLogAppendFailureTest,WorkspaceMessageBusTest -Dsurefire.failIfNoSpecifiedTests=false test
mvn -B -T1C -pl :agentscope-harness -am -DskipTests clean install
mvn -B -T1C -pl :agentscope-harness clean verify

The dependency-install step compiles/packages dependencies with their tests skipped; it is not a full-repository test result. The subsequent full Harness clean verify succeeds: 1762 tests / 1715 passed / 47 skipped / 0 failures or errors, including all eight new cases; Spotless, Javadoc and packaging pass. Skips include existing Windows-disabled filesystem/shell/session cases, opt-in Docker tests, and existing conditional permission/GC cases. No assertions or skip conditions were changed. Full-repository verification was not run.

Docs: npm ci --ignore-scripts, npm test (13/13 pass), and npm run validate pass. npm run broken-links exits 1 on both the changed tree and the same unmodified main: 2230 links / 328 files; all 2558 ordered file/target entries match exactly. These are existing site links, not introduced by this PR. git diff --check passes.

AI assistance: investigated and implemented with Codex, with agent review of the complete diff and executed red/green tests. This is not a claim of independent human review or a production incident.

Checklist

  • Code has been formatted with mvn spotless:apply
  • Tests pass in the affected module, subject to the explicit existing skips above
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (EN/ZH)
  • Code is ready for review

Copilot AI balanced review requested due to automatic review settings November 12, 2026 00:19
@mintlify

mintlify Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit a8ab1a9.

Approve preview

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@jujn jujn added the P0 重要紧急 label Nov 16, 2026
@juruoO-o

Copy link
Copy Markdown
Collaborator

检查 WriteResult 并在写入失败时停止返回游标和实时广播,这个修复方向是对的。请在合入前补一下 HarnessGateway.publishEventToSession 的错误处理。它目前用 sessionPublishEvent(sessionId, payload).subscribe(),外层 try/catch 捕获不到 Reactor 的 onError。本 PR 让文件系统报告的写入失败进入这条路径,因此建议为订阅加一个显式错误回调,记录 session ID、事件标识(可用时)和失败结果,避免记录事件载荷。保持现有异步发布方式即可。

本地消息总线专项测试 40 项通过。

@pengmoubuaixuexi

Copy link
Copy Markdown
Contributor Author

已在 6d45941 补上显式错误回调,保留异步发布。写入失败时,HarnessGateway 会记录一条 WARN,包含会话 ID、事件 ID 和异常类型。序列化器或后端抛出的异常消息可能包含事件正文,因此日志只记录异常类型。

新增的测试从 runWakeup 入口让业务回复先完成,再让消息总线写入失败。旧代码会产生 Reactor 的 ErrorCallbackNotImplemented,修复后该错误由网关接收。定向测试 51 项全部通过,也核对了 WARN 中没有测试事件的正文。本地完整 Harness 验证通过,1716 项通过,47 项跳过。

@juruoO-o juruoO-o left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

异步发布失败已有显式错误回调,写入失败不会返回成功游标或触发实时广播。中英文说明已移到开发版文档。同步 main 后本地 61 项消息总线和网关测试通过,文档检查通过。

@juruoO-o
juruoO-o merged commit 19d4659 into agentscope-ai:main Nov 25, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 重要紧急

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WorkspaceMessageBus acknowledges failed replay-log writes

4 participants