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

Function TestRequestPayloadInjectTools

intercept/messages/reqpayload_test.go:269–292  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

267}
268
269func TestRequestPayloadInjectTools(t *testing.T) {
270 t.Parallel()
271
272 payload := mustMessagesPayload(t, `{"model":"claude-opus-4-5","max_tokens":1024,"messages":[{"role":"user","content":"hello"}],"tools":[{"name":"existing_tool","type":"custom","input_schema":{"type":"object","properties":{}},"cache_control":{"type":"ephemeral"}}]}`)
273
274 updatedPayload, err := payload.injectTools([]anthropic.ToolUnionParam{
275 {
276 OfTool: &anthropic.ToolParam{
277 Name: "injected_tool",
278 Type: anthropic.ToolTypeCustom,
279 InputSchema: anthropic.ToolInputSchemaParam{
280 Properties: map[string]interface{}{},
281 },
282 },
283 },
284 })
285 require.NoError(t, err)
286
287 toolItems := gjson.GetBytes(updatedPayload, "tools").Array()
288 require.Len(t, toolItems, 2)
289 require.Equal(t, "injected_tool", toolItems[0].Get("name").String())
290 require.Equal(t, "existing_tool", toolItems[1].Get("name").String())
291 require.Equal(t, "ephemeral", toolItems[1].Get("cache_control.type").String())
292}
293
294func TestRequestPayloadConvertAdaptiveThinkingForBedrock(t *testing.T) {
295 t.Parallel()

Callers

nothing calls this directly

Calls 3

mustMessagesPayloadFunction · 0.85
GetMethod · 0.80
injectToolsMethod · 0.45

Tested by

no test coverage detected