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

Function appendNewlineToQueuedMessage

pkg/runtime/loop.go:136–151  ·  view source on GitHub ↗

appendNewlineToQueuedMessage returns sm with "\n" appended to its text content; never mutates the caller's slice contents. For plain-text messages Content is extended. For multi-content messages only the last part is considered: if it is a text part, "\n" is appended to it in a shallow copy of the s

(sm QueuedMessage)

Source from the content-addressed store, hash-verified

134// (e.g. image), sm is returned unchanged — non-text parts carry their own
135// provider envelope that acts as a separator.
136func appendNewlineToQueuedMessage(sm QueuedMessage) QueuedMessage {
137 if len(sm.MultiContent) == 0 {
138 sm.Content += "\n"
139 return sm
140 }
141 // Only act if the last part is a text part.
142 last := len(sm.MultiContent) - 1
143 if sm.MultiContent[last].Type != chat.MessagePartTypeText {
144 return sm
145 }
146 // Shallow-copy the slice so we don't mutate the original.
147 parts := append([]chat.MessagePart(nil), sm.MultiContent...)
148 parts[last].Text += "\n"
149 sm.MultiContent = parts
150 return sm
151}
152
153// emitHookDrivenShutdown fans out the standard Error /
154// notification(level=error) / on_error stanzas when a hook

Callers 2

drainAndEmitSteeredMethod · 0.85

Calls

no outgoing calls

Tested by 1