[Code Quality] Think tool races under parallel tool execution
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #4570 @dlanov による — マージ済み
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
調査の方向性
pkg/tools/builtin/think/think.go:25–27 と pkg/runtime/toolexec/dispatcher.go:251–273 の並列ディスパッチ経路から始めてください。提供された Go プログラムで race を再現し、その後 think ツールの状態とハンドラーを調べてください。並行呼び出しで race が発生せず、すべての思考が保持される状態を完了条件とします。並行実行の回帰テストを追加し、go test -race で実行してください。
索引モデルが issue の本文から書いたものです。
説明
Severity: medium · Type: code-quality
Location
Reviewed commit: cd65d7c776dda80d554735ee20572d09cfe2d791.
pkg/tools/builtin/think/think.go:25–27: appends tot.thoughtsand joins the shared slice without synchronization.pkg/runtime/toolexec/dispatcher.go:251–273: dispatches calls from the same model batch concurrently.
Issue details
Two think calls on the same toolset can execute concurrently. The handler writes the slice header/backing array and reads it through strings.Join without a mutex. The same toolset instance can also be reused by concurrent runs of the same agent.
This is reproducible without credentials or a model request. Save the following as /tmp/think-race.go, then run go run -race /tmp/think-race.go from the repository root:
package main
import (
"context"
"sync"
"github.com/docker/docker-agent/pkg/tools"
"github.com/docker/docker-agent/pkg/tools/builtin/think"
)
func main() {
ctx := context.Background()
set := think.New()
available, _ := set.Tools(ctx)
tool := available[0]
start := make(chan struct{})
var wg sync.WaitGroup
for range 2 {
wg.Go(func() {
<-start
for range 100 {
_, _ = tool.Handler(ctx, tools.ToolCall{Function: tools.FunctionCall{Name: "think", Arguments: `{"thought":"parallel thought"}`}}, tools.NopRuntime{})
}
})
}
close(start)
wg.Wait()
}
On darwin/arm64 with the repository's Go 1.27.2 toolchain, this reports WARNING: DATA RACE at think.go:26 and think.go:27, ending with Found 5 data race(s) and exit status 66.
Impact
Concurrent scratchpad calls may lose appended thoughts or return inconsistent output. The race violates the dispatcher's parallel-execution contract; a read-only annotation does not make the tool's internal state immutable.
Recommended fix
Protect the append and output snapshot with a mutex (or serialize execution explicitly). If joining outside the lock, copy the slice while holding the lock first. Add a regression test that invokes the same tool concurrently and verifies all thoughts are retained, and run it under go test -race.
Separately decide whether the scratchpad should be scoped to a conversation rather than a long-lived toolset; locking alone does not establish conversation isolation.
- 主要言語
- Go
- スター
- 4.4k
- フォーク
- 508
- 平均マージ
- 8時間 10分
- マージ済み PR(30日)
- 231
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
docker/docker-agent のほかの issue
-
pkg/hooks tests fail with a misleading assertion when jq is not installed対応中かも @dwin-gharibi が 54 日前に担当しました。 オープンarea/testing
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
docker/docker-agent#4052 ·
メンテナーはふだん 1 日以内に返信
-
`remove_directory` and `create_directory` hide work they already did when a later path fails対応中かも @dwin-gharibi が 72 日前に担当しました。 オープンarea/tools
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
docker/docker-agent#3933 ·
メンテナーはふだん 1 日以内に返信
-
`edit_file` silently edits the first match when `oldText` occurs more than once対応中かも @dwin-gharibi が 72 日前に担当しました。 オープンarea/tools
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
docker/docker-agent#3929 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Native API: distinguish provider finish_reason from inferred EOF completion (follow-up to #3669)オープンarea/api area/providers/openai area/runtime
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
docker/docker-agent#4624 ·
メンテナーはふだん 1 日以内に返信
-
[Flaky test] TestHandleStream_ContextCancellation対応中かも @aheritier が 1 日前に担当しました。 オープンarea/testing automated flaky-test status/needs-triage
docker/docker-agent#4617 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
docker/docker-agent の issue をすべて見る
似ている issue
-
documentation priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
yeixio/toskar-core#697 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
keyxmakerx/Chronicle#1532 ·
メンテナーはふだん 1 日以内に返信
-
The acquisition fixture's search path skips the argument table production enforces (regression from #285)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Judgment-Pack/judgment-pack-gateway#293 ·
メンテナーはふだん 1 日以内に返信
-
bug desktop v3 windows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
esengine/DeepSeek-Reasonix#13697 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
eugenioenko/ttt#959 ·
メンテナーはふだん 1 日以内に返信