MCPcopy Create free account
hub / github.com/coder/aibridge / augmentRequestForBedrock

Method augmentRequestForBedrock

intercept/messages/base.go:317–352  ·  view source on GitHub ↗

augmentRequestForBedrock will change the model used for the request since AWS Bedrock doesn't support Anthropics' model names. It also converts adaptive thinking to enabled with a budget for models that don't support adaptive thinking natively.

()

Source from the content-addressed store, hash-verified

315// Anthropics' model names. It also converts adaptive thinking to enabled with a budget for models that
316// don't support adaptive thinking natively.
317func (i *interceptionBase) augmentRequestForBedrock() {
318 if i.bedrockCfg == nil {
319 return
320 }
321
322 model := i.Model()
323 updated, err := i.reqPayload.withModel(model)
324 if err != nil {
325 i.logger.Warn(context.Background(), "failed to set model in request payload for Bedrock", slog.Error(err))
326 return
327 }
328 i.reqPayload = updated
329
330 if !bedrockModelSupportsAdaptiveThinking(model) {
331 updated, err = i.reqPayload.convertAdaptiveThinkingForBedrock()
332 if err != nil {
333 i.logger.Warn(context.Background(), "failed to convert adaptive thinking for Bedrock", slog.Error(err))
334 return
335 }
336 i.reqPayload = updated
337 }
338
339 // Filter Anthropic-Beta header to only include Bedrock-supported flags
340 // that the current model supports.
341 if i.clientHeaders != nil {
342 filterBedrockBetaFlags(i.clientHeaders, model)
343 }
344
345 // Strip body fields that Bedrock does not accept.
346 updated, err = i.reqPayload.removeUnsupportedBedrockFields(i.clientHeaders)
347 if err != nil {
348 i.logger.Warn(context.Background(), "failed to remove unsupported fields for Bedrock", slog.Error(err))
349 return
350 }
351 i.reqPayload = updated
352}
353
354// bedrockModelSupportsAdaptiveThinking returns true if the given Bedrock model ID
355// supports the "adaptive" thinking type natively (i.e. Claude 4.6 models).

Calls 7

ModelMethod · 0.95
filterBedrockBetaFlagsFunction · 0.85
withModelMethod · 0.80
ErrorMethod · 0.45