MCPcopy Index your code
hub / github.com/docker/docker-agent / TestToolCallVariations

Function TestToolCallVariations

pkg/runtime/runtime_test.go:641–696  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

639}
640
641func TestToolCallVariations(t *testing.T) {
642 t.Parallel()
643
644 tests := []struct {
645 name string
646 streamBuilder func() *streamBuilder
647 description string
648 }{
649 {
650 name: "tool_call_with_empty_args",
651 streamBuilder: func() *streamBuilder {
652 return newStreamBuilder().
653 AddToolCallName("call_1", "empty_tool").
654 AddToolCallArguments("call_1", "{}").
655 AddStopWithUsage(3, 5)
656 },
657 description: "Tool call with empty JSON arguments",
658 },
659 {
660 name: "multiple_tool_calls",
661 streamBuilder: func() *streamBuilder {
662 return newStreamBuilder().
663 AddToolCallName("call_1", "tool_one").
664 AddToolCallArguments("call_1", `{"param":"value1"}`).
665 AddToolCallName("call_2", "tool_two").
666 AddToolCallArguments("call_2", `{"param":"value2"}`).
667 AddStopWithUsage(8, 12)
668 },
669 description: "Multiple tool calls in sequence",
670 },
671 {
672 name: "tool_call_with_fragmented_args",
673 streamBuilder: func() *streamBuilder {
674 return newStreamBuilder().
675 AddToolCallName("call_1", "fragmented_tool").
676 AddToolCallArguments("call_1", `{"long`).
677 AddToolCallArguments("call_1", `_param": "`).
678 AddToolCallArguments("call_1", `some_value"}`).
679 AddStopWithUsage(5, 8)
680 },
681 description: "Tool call with arguments streamed in fragments",
682 },
683 }
684
685 for _, tt := range tests {
686 t.Run(tt.name, func(t *testing.T) {
687 stream := tt.streamBuilder().Build()
688 sess := session.New(session.WithUserMessage("Use tools"))
689 events := runSession(t, sess, stream)
690
691 require.True(t, hasEventType(t, events, &PartialToolCallEvent{}), "Expected PartialToolCallEvent for %s", tt.description)
692 require.True(t, hasEventType(t, events, &StreamStartedEvent{}), "Expected StreamStartedEvent")
693 require.True(t, hasEventType(t, events, &StreamStoppedEvent{}), "Expected StreamStoppedEvent")
694 })
695 }
696}
697
698// queueProvider returns a different stream on each CreateChatCompletionStream call.

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
WithUserMessageFunction · 0.92
newStreamBuilderFunction · 0.85
runSessionFunction · 0.85
hasEventTypeFunction · 0.85
AddStopWithUsageMethod · 0.80
AddToolCallArgumentsMethod · 0.80
AddToolCallNameMethod · 0.80
RunMethod · 0.65
BuildMethod · 0.45

Tested by

no test coverage detected