fix(selfHosted): align worker lifecycle behavior - #18
Merged
Conversation
## 简述 对齐 Go self-hosted worker 的 work ownership、SSE 生命周期和工具超时配置,同时收紧配置透传边界。 ## 修改前 - WorkPoller 会在 Next 和 Close 时自动 stop 上一条 work,EnvironmentWorker 自己也会在 HandleItem 结束时 force-stop,存在重复 stop。 - session SSE 复用普通 HTTP client,受 client 整次请求 timeout 限制。 - EnvironmentWorkerOptions 无法设置 SessionToolRunner 的单次工具超时。 - 仅把 ToolTimeout 传给 SessionToolRunner 时,默认 Bash 工具仍使用 ToolContext 中的旧值。 ## 修改后 - WorkPoller 增加 AutoStop,默认保持 true;EnvironmentWorker 显式设置 false,由 worker 唯一负责 heartbeat 和 stop。 - session 与 thread SSE 使用复制出的独立 HTTP client,保留 Transport、代理、认证和 redirect 行为,仅移除整次请求总时长 timeout。 - EnvironmentWorkerOptions.ToolTimeout 同时进入 SessionToolRunner 和默认工具 ToolContext;优先级为 Worker option、ToolContext、120s 默认值。 - SessionToolRunner 使用 context deadline 和独立 goroutine 强制限制工具执行等待时间;超时立即返回 error result,工具通过 context 接收取消信号。 - 增加 ownership、SSE timeout、自定义工具 timeout 和默认 Bash timeout 回归测试。 ## 边界 - WorkPoller 的 AutoStop 默认语义只适用于串行 iterator;并发 dispatch 必须关闭 AutoStop 并由调用方维护 heartbeat 和 stop。 - 非协作工具 goroutine 可能继续到自身返回,runner 只在有限 drain 时间内等待;该行为对齐 Anthropic Go。 - 本 MR 不修改 SIGTERM 时 force-stop 行为,不实现 work 迁移、release 或 requeue。 ## 验证 - go test -count=1 ./... 通过 - go vet ./... 通过 - race:environments、selfhosted、toolset 通过 - test/run.sh --sdk:Go、Python、Java 真实 STG worker 3/3 通过 - test/run.sh --all:真实 STG 全量默认套件通过,Docker 和直接 work-contract 用例按独立模式开关跳过 See merge request: !86 Sync-Source-Commit: 5ad76a67a79d225c46b41a822165d6b2f1b6f32e 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: 5ad76a67a79d225c46b41a822165d6b2f1b6f32e
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.