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

Function TestWithReasoning

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

Source from the content-addressed store, hash-verified

394}
395
396func TestWithReasoning(t *testing.T) {
397 t.Parallel()
398
399 stream := newStreamBuilder().
400 AddReasoning("Let me think about this...").
401 AddReasoning(" I should respond politely.").
402 AddContent("Hello, how can I help you?").
403 AddStopWithUsage(10, 15).
404 Build()
405
406 sess := session.New(session.WithUserMessage("Hi"))
407
408 events := runSession(t, sess, stream)
409
410 // Extract the actual message from MessageAddedEvent to use in comparison
411 // (it contains dynamic fields like CreatedAt that we can't predict)
412 require.Len(t, events, 12)
413 msgAdded := events[9].(*MessageAddedEvent)
414 require.NotNil(t, msgAdded.Message)
415
416 expectedEvents := []Event{
417 TeamInfo([]AgentDetails{{Name: "root", Provider: "test", Model: "mock-model"}}, "root"),
418 ToolsetInfo(0, false, "root"),
419 UserMessage("Hi", sess.ID, nil, 0),
420 StreamStarted(sess.ID, "root"),
421 ToolsetInfo(0, false, "root"),
422 AgentInfo("root", "test/mock-model", "", ""),
423 AgentChoiceReasoning("root", sess.ID, "Let me think about this..."),
424 AgentChoiceReasoning("root", sess.ID, " I should respond politely."),
425 AgentChoice("root", sess.ID, "Hello, how can I help you?"),
426 MessageAdded(sess.ID, msgAdded.Message, "root"),
427 NewTokenUsageEvent(sess.ID, "root", &Usage{InputTokens: 10, OutputTokens: 15, ContextLength: 25, LastMessage: &MessageUsage{
428 Usage: chat.Usage{InputTokens: 10, OutputTokens: 15},
429 Model: "test/mock-model",
430 FinishReason: chat.FinishReasonStop,
431 }}),
432 StreamStopped(sess.ID, "root", "normal"),
433 }
434
435 assertEventsEqual(t, expectedEvents, events)
436}
437
438func TestMixedContentAndReasoning(t *testing.T) {
439 t.Parallel()

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
WithUserMessageFunction · 0.92
newStreamBuilderFunction · 0.85
runSessionFunction · 0.85
TeamInfoFunction · 0.85
ToolsetInfoFunction · 0.85
StreamStartedFunction · 0.85
AgentChoiceReasoningFunction · 0.85
AgentChoiceFunction · 0.85
MessageAddedFunction · 0.85
NewTokenUsageEventFunction · 0.85
StreamStoppedFunction · 0.85

Tested by

no test coverage detected