mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(coderd/x/chatd): fix flaky TestSpawnComputerUseAgentInheritsContext (#24666)
Fixes flaky `TestSpawnComputerUseAgentInheritsContext`. - The test inserts an Anthropic provider directly into the DB after `CreateChat` has already been called - The server's background goroutine may have already cached the provider list (OpenAI only) via `configCache.EnabledProviders()` with a 10s TTL - The direct DB insert bypasses the pubsub event that production uses to invalidate the cache - `isAnthropicConfigured()` returns the stale cached result, making `computer_use` appear unavailable - Fix: call `server.configCache.InvalidateProviders()` after the insert, mirroring what production does via pubsub CI failure: https://github.com/coder/coder/actions/runs/24829197096/job/72673070101?pr=24648 > 🤖
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user