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

Function TestReasoningOnlyTurnEmitsWarning

pkg/runtime/runtime_test.go:4179–4206  ·  view source on GitHub ↗

TestReasoningOnlyTurnEmitsWarning is a regression test for https://github.com/docker/docker-agent/issues/3145. A thinking-mode model (e.g. Qwen3 via an openai_chatcompletions provider) can stream only reasoning tokens and then stop with no content and no tool calls. recordAssistantMessage skips that

(t *testing.T)

Source from the content-addressed store, hash-verified

4177// runtime must instead surface a Warning explaining that the model produced only
4178// reasoning, and must still not persist an assistant message.
4179func TestReasoningOnlyTurnEmitsWarning(t *testing.T) {
4180 stream := newStreamBuilder().
4181 AddReasoning("The user wants the file list. ").
4182 AddReasoning("I should call list_directory.").
4183 AddStopWithUsage(10, 25).
4184 Build()
4185
4186 sess := session.New(session.WithUserMessage("List the files"))
4187 events := runSession(t, sess, stream)
4188
4189 var warn *WarningEvent
4190 assistantPersisted := false
4191 for _, ev := range events {
4192 switch e := ev.(type) {
4193 case *WarningEvent:
4194 warn = e
4195 case *MessageAddedEvent:
4196 if e.Message != nil && e.Message.Message.Role == chat.MessageRoleAssistant {
4197 assistantPersisted = true
4198 }
4199 }
4200 }
4201
4202 require.NotNil(t, warn, "expected a Warning event for a reasoning-only turn")
4203 assert.Contains(t, warn.Message, "only reasoning")
4204 assert.False(t, assistantPersisted,
4205 "a reasoning-only turn must not persist an assistant message")
4206}
4207
4208// TestEmptyTurnEmitsWarning verifies that a wholly empty turn (no content, no
4209// reasoning, no tool calls) - e.g. a rate-limited or token-capped provider that

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
WithUserMessageFunction · 0.92
newStreamBuilderFunction · 0.85
runSessionFunction · 0.85
AddStopWithUsageMethod · 0.80
AddReasoningMethod · 0.80
BuildMethod · 0.45

Tested by

no test coverage detected