From 0362e5386c756c856fd608ef7a90bfbd110b0329 Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Tue, 15 Sep 2026 17:02:48 +0200 Subject: [PATCH] fix(coderd/x/chatd/chatloop): tell the model to gather context before retrying an exclusive tool (#29281) When the model batches `advisor` (an exclusive tool) with other tool calls, every call in the batch is rejected and the `advisor` result only says to retry with `advisor` alone. That nudges the model toward re-calling `advisor` immediately, even when the sibling calls were there to gather context for it. Extend the message so the model is told to run the other tools first when it still needs their output, then retry with only the exclusive tool call. Generated by Coder Agents on behalf of @ibetitsmike. --- coderd/x/chatd/chatloop/chatloop.go | 2 +- coderd/x/chatd/chatloop/chatloop_run_internal_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coderd/x/chatd/chatloop/chatloop.go b/coderd/x/chatd/chatloop/chatloop.go index f019d752197..75de56b0bfc 100644 --- a/coderd/x/chatd/chatloop/chatloop.go +++ b/coderd/x/chatd/chatloop/chatloop.go @@ -1220,7 +1220,7 @@ func exclusiveToolPolicyResults( } func exclusiveToolMustRunAloneErrorMessage(toolName string) string { - return toolName + " must be called alone, without other tools in the same batch. Retry with only the " + toolName + " call." + return toolName + " must be called alone, without other tools in the same batch. If you need more information to feed into the " + toolName + " call, execute the other tools first, then retry with only the " + toolName + " call." } func exclusiveToolSkippedErrorMessage(toolName string) string { diff --git a/coderd/x/chatd/chatloop/chatloop_run_internal_test.go b/coderd/x/chatd/chatloop/chatloop_run_internal_test.go index 393d7acbaeb..7b910efc081 100644 --- a/coderd/x/chatd/chatloop/chatloop_run_internal_test.go +++ b/coderd/x/chatd/chatloop/chatloop_run_internal_test.go @@ -505,7 +505,7 @@ func TestExclusiveToolPolicy_MixedBatchErrors(t *testing.T) { requireToolResultErrorMessage( t, results[0], - "advisor must be called alone, without other tools in the same batch. Retry with only the advisor call.", + "advisor must be called alone, without other tools in the same batch. If you need more information to feed into the advisor call, execute the other tools first, then retry with only the advisor call.", ) requireToolResultErrorMessage( t, @@ -559,12 +559,12 @@ func TestExclusiveToolPolicy_MultipleExclusive(t *testing.T) { requireToolResultErrorMessage( t, results[0], - "advisor must be called alone, without other tools in the same batch. Retry with only the advisor call.", + "advisor must be called alone, without other tools in the same batch. If you need more information to feed into the advisor call, execute the other tools first, then retry with only the advisor call.", ) requireToolResultErrorMessage( t, results[1], - "advisor must be called alone, without other tools in the same batch. Retry with only the advisor call.", + "advisor must be called alone, without other tools in the same batch. If you need more information to feed into the advisor call, execute the other tools first, then retry with only the advisor call.", ) }