diff --git a/coderd/x/chatd/subagent_context_internal_test.go b/coderd/x/chatd/subagent_context_internal_test.go index 5acdc1efaf..6d5a6e4513 100644 --- a/coderd/x/chatd/subagent_context_internal_test.go +++ b/coderd/x/chatd/subagent_context_internal_test.go @@ -477,6 +477,12 @@ func TestSpawnComputerUseAgentInheritsContext(t *testing.T) { ctx := chatdTestContext(t) parentChat := createParentChatWithInheritedContext(ctx, t, db, server) insertEnabledAnthropicProvider(ctx, t, db, parentChat.OwnerID) + // The direct DB insert above bypasses the pubsub event that + // production uses to invalidate the provider cache. Explicitly + // invalidate here so the background processing goroutine does + // not serve a stale provider list (OpenAI only) that was cached + // before the Anthropic provider was inserted. + server.configCache.InvalidateProviders() tools := server.subagentTools(ctx, func() database.Chat { return parentChat }, parentChat.LastModelConfigID) tool := findToolByName(tools, spawnAgentToolName)