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

Method AddRefusal

pkg/runtime/streaming_test.go:43–52  ·  view source on GitHub ↗

AddRefusal appends a terminal chunk carrying finish_reason "refusal", the way the Anthropic adapter surfaces a safety-classifier refusal (HTTP 200, no content).

()

Source from the content-addressed store, hash-verified

41// way the Anthropic adapter surfaces a safety-classifier refusal (HTTP 200,
42// no content).
43func (b *streamBuilder) AddRefusal() *streamBuilder {
44 b.responses = append(b.responses, chat.MessageStreamResponse{
45 Choices: []chat.MessageStreamChoice{{
46 Index: 0,
47 FinishReason: chat.FinishReasonRefusal,
48 }},
49 Usage: &chat.Usage{InputTokens: 1},
50 })
51 return b
52}
53
54// TestHandleStream_Refusal verifies that a refusal terminates the stream with
55// the refusal finish reason and stops the loop instead of being mistaken for a

Calls

no outgoing calls

Tested by

no test coverage detected