fix(selfHosted): align worker lifecycle behavior - #11
Merged
Conversation
## 简述 对齐 Java self-hosted worker 的 SSE 生命周期和工具执行超时语义。 ## 修改前 - self-hosted SSE 复用普通 OkHttp client,整次 call timeout 可能终止长时间 session。 - EnvironmentWorker.Options 无法直接配置单次工具执行超时。 - timeout 只进入 ToolContext,非协作 custom tool 如果不主动检查 isCancelled,仍会阻塞 SessionToolRunner。 - 初版 SSE 修复同时关闭 readTimeout,会让静默网络断流永久挂起。 ## 修改后 - 为 self-hosted SSE 创建独立 OkHttp 和 Retrofit client,保留认证、代理、拦截器及调用方 read timeout,仅将整次 callTimeout 设为 0。 - EnvironmentWorker.Options 增加 toolTimeoutMillis;正值覆盖 ToolContext,非正值保留原 120s 默认值或用户配置。 - SessionToolRunner 使用 daemon executor 执行工具,并在外层强制 deadline;以 50ms 间隔观察 worker 和父 context 取消,超时后立即返回 error result,不等待忽略中断的工具。 - timeout 和取消会同步到执行用 ToolContext;配合型工具可及时释放进程和资源。 - WorkPoller 文档明确 AutoStop 是串行 iterator 语义;并发 dispatch 必须关闭并自行维护 heartbeat 和 stop。 ## 边界 - 非协作工具线程可能继续运行到自身返回,但结果会被丢弃;该行为语义对齐 Anthropic Go/Python 的 abandon-on-cancel 实现,工具仍应响应 isCancelled 或线程中断。 - 本 MR 不修改 SIGTERM 时 force-stop 行为,不实现 work 迁移、release 或 requeue。 ## 验证 - Java 全量单测:47 passed - Checkstyle 通过 - Maven package 通过 - test/run.sh --sdk:Go、Python、Java 真实 STG worker 3/3 通过 - test/run.sh --all:真实 STG 全量默认套件通过,Docker 和直接 work-contract 用例按独立模式开关跳过 See merge request: !88 Sync-Source-Commit: f328f80ce14608dfc1e0b62436ccbbfd0727e3bf Hand-Written-Reason: Hand-written self-hosted worker lifecycle alignment; not produced by ark-apis generation. Release-Version: 0.4.0
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.
Hand-written change from the internal SDK repository — not produced by
make vendor.fix(selfHosted): align worker lifecycle behaviorSync-Source-Commit: f328f80ce14608dfc1e0b62436ccbbfd0727e3bf
Hand-Written-Reason: Hand-written self-hosted worker lifecycle alignment; not produced by ark-apis generation.
Release-Version: 0.4.0
Created by ark-hand.