mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(coderd/x/chatd): show correct provider and clean detail for Bedrock errors (#26338)
## Problem
Bedrock errors (routed through aibridge) showed the wrong provider
("Anthropic ...")
and a doubly-wrapped detail string instead of the clean message.
## Fix (chatd only)
- **Provider label:** thread the configured provider to error
classification via
`GenerateAssistantOptions.ErrorProvider`. Transport provider still
drives prompt
prep, sanitization, and metric labels (unchanged).
- **Detail:** unwrap the SDK transport wrapper (`METHOD "URL": NNN
{body}`) to surface
the inner message; handles top-level `{"message":...}` and nested
`{"error":{"message":...}}`.
## Notes
- Surfacing a top-level `message` now applies to all providers
(intentional; nested wins when both present).
- The advisor path keeps the transport label; accepted as-is (it returns
`err.Error()`, not the classification).
- Fixes display in chatd only; the wrapper originates in aibridge (out
of scope here).
🤖 Generated by Coder Agents.
This commit is contained in:
@@ -48,6 +48,10 @@ type generationPrepared struct {
|
||||
ModelRoute resolvedModelRoute
|
||||
ModelBuildOptions modelBuildOptions
|
||||
|
||||
// ResolvedProvider is the configured provider identity used to label
|
||||
// user-facing errors. See chatloop.GenerateAssistantOptions.ErrorProvider.
|
||||
ResolvedProvider string
|
||||
|
||||
ModelConfigID uuid.UUID
|
||||
ModelConfig codersdk.ChatModelCallConfig
|
||||
ProviderOptions fantasy.ProviderOptions
|
||||
@@ -626,6 +630,7 @@ func (s *taskStarter) generateAssistant(
|
||||
runCtx := input.DebugTurn.Ensure(ctx, prepared.Chat, prepared.Debug)
|
||||
outcome, err := chatloop.GenerateAssistant(runCtx, chatloop.GenerateAssistantOptions{
|
||||
Model: prepared.Model,
|
||||
ErrorProvider: prepared.ResolvedProvider,
|
||||
Messages: prepared.Prompt,
|
||||
Tools: prepared.Tools,
|
||||
ActiveTools: prepared.ActiveTools,
|
||||
|
||||
Reference in New Issue
Block a user