From b66ddd17719614e0dd53d4c77703f4f87fab6672 Mon Sep 17 00:00:00 2001 From: Phantom-IN Date: Wed, 25 Nov 2026 19:21:20 +0530 Subject: [PATCH] fix(agent): send no tools with the LLM connection test TestConnection passes an empty Tools slice so the model gets a bare chat request, but agentcore still appends its background-task tools (TaskOutput, TaskStop, TaskList, Monitor) unless DisableBackgroundTasks is set. The request therefore carried four tool definitions, and models answered the "ping" with a TaskOutput call or tool-like text instead of OK (#526). Against a local gemma4:e4b the streaming test spent its whole 30 s budget reasoning about those tools and failed; with them gone it answers OK in under a second. Set DisableBackgroundTasks, as goal decomposition already does, and add a test that checks the request body has no tools. --- CHANGELOG.md | 1 + agent/conntest_tools_test.go | 38 ++++++++++++++++++++++++++++++++++++ agent/provider.go | 3 +++ 3 files changed, 42 insertions(+) create mode 100644 agent/conntest_tools_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f46c990e..7c295d904 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project are documented in this file. The format is b ### Fixed +- **The LLM connection test sends no tools**: the test passes an empty tool list, but the agent SDK still added its background-task tools (`TaskOutput`, `TaskStop`, `TaskList`, `Monitor`), so some models answered with a call to one of them or with tool-like text instead of `OK`, and a local reasoning model could spend the whole 30-second budget deciding whether to use them. The test now turns those tools off, the same way goal decomposition does (#526). - **Missing Docker buildx is reported before the build**: without the buildx plugin, Compose only warns and falls back to the legacy builder, which fails on the Dockerfile's first `FROM --platform=$BUILDPLATFORM` with `failed to parse platform`. `install.sh` (all-Docker) and `update.sh` (Docker update) now check `docker buildx version` first and stop with an install hint, and the automatic Docker install on apt-based distros not covered by get.docker.com installs the buildx package as well. The README Docker section names buildx as a requirement. - **A goal URL followed by punctuation is still seeded**: a goal such as `Assess http://juiceshop:3000.` no longer logs `could not parse a target host/IP` and skips the site. Trailing punctuation, including full-width `。` and a closing bracket that has no matching opener, is trimmed from the URL before it is parsed, so `http://[::1]` is left alone. The scheme the goal names is kept and a final period does not end up in the host. - **Task timeout triggers fire for every task**: `on_task_timeout` used the task id as a watermark, but tasks time out in deadline order. Once a newer task timed out first, an older task that timed out later was never fired for. Fired timeouts are now kept in a persisted set, like met goals; on first start the set is seeded with the tasks already timed out, so nothing replays. diff --git a/agent/conntest_tools_test.go b/agent/conntest_tools_test.go new file mode 100644 index 000000000..13e99af7c --- /dev/null +++ b/agent/conntest_tools_test.go @@ -0,0 +1,38 @@ +package agent + +import ( + "context" + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "testing" +) + +// The connection test must send a bare chat request. Models given the SDK's +// background-task tools answered the test by calling TaskOutput instead of OK (#526). +func TestConnectionSendsNoTools(t *testing.T) { + var body []byte + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + body, _ = io.ReadAll(r.Body) + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"id":"x","object":"chat.completion","model":"m","choices":[{"index":0,"message":{"role":"assistant","content":"OK"},"finish_reason":"stop"}],"usage":{"prompt_tokens":1,"completion_tokens":1,"total_tokens":2}}`)) + })) + defer server.Close() + + cfg := ConfigFrom("ollama", "m", server.URL+"/v1", "", "") + cfg.Stream = false + _, reply, err := TestConnection(context.Background(), cfg) + if err != nil || reply != "OK" { + t.Fatalf("TestConnection = %q, %v; want OK", reply, err) + } + var req struct { + Tools []json.RawMessage `json:"tools"` + } + if err := json.Unmarshal(body, &req); err != nil { + t.Fatalf("request body: %v\n%s", err, body) + } + if len(req.Tools) != 0 { + t.Fatalf("connection test sent %d tools, want none:\n%s", len(req.Tools), body) + } +} diff --git a/agent/provider.go b/agent/provider.go index cf8251775..7d8a4da20 100644 --- a/agent/provider.go +++ b/agent/provider.go @@ -696,6 +696,9 @@ func TestConnection(ctx context.Context, c Config) (time.Duration, string, error MaxTurns: 1, MaxTokens: 8192, NonStreaming: !c.Stream, // use this profile's real send/receive mode for the connection test + // Without this the SDK still adds TaskOutput/TaskStop/TaskList/Monitor, and + // some models answer the test with a call to one of them instead of OK. + DisableBackgroundTasks: true, }, "ping") lat := time.Since(start) if err != nil {