MCPcopy Create free account
hub / github.com/docker/docker-agent / Send

Method Send

pkg/embeddedchat/embeddedchat.go:224–249  ·  view source on GitHub ↗

Send appends prompt to the conversation and streams the assistant reply. The returned channel closes when the runtime stream stops. A clean stream emits a final Done event first; a stream that reports an ErrorEvent emits one Err event, suppresses later projected events, then keeps draining until the

(ctx context.Context, prompt string)

Source from the content-addressed store, hash-verified

222// If ctx is cancelled, Send drains the runtime stream until it stops, but no
223// further events are delivered to the caller.
224func (s *Session) Send(ctx context.Context, prompt string) (<-chan Event, error) {
225 s.mu.Lock()
226 if s.rt == nil || s.session == nil {
227 s.mu.Unlock()
228 return nil, ErrNotInitialized
229 }
230 if s.closed {
231 s.mu.Unlock()
232 return nil, ErrClosed
233 }
234 if s.activeCancel != nil {
235 s.mu.Unlock()
236 return nil, ErrRunActive
237 }
238 runCtx, cancel := context.WithCancel(ctx)
239 s.activeCancel = cancel
240 s.activeRun++
241 runID := s.activeRun
242 s.session.AddMessage(session.UserMessage(prompt))
243 events := s.rt.RunStream(runCtx, s.session)
244 s.mu.Unlock()
245
246 out := make(chan Event, eventBufferSize(s.cfg.EventBuffer))
247 go s.forwardEvents(runCtx, events, out, cancel, runID)
248 return out, nil
249}
250
251// Confirm answers the pending tool confirmation, if any.
252func (s *Session) Confirm(ctx context.Context, req dagentruntime.ResumeRequest) error {

Callers

nothing calls this directly

Implementers 7

fakeSessionpkg/tools/lifecycle/supervisor_test.go
sessionClientpkg/tools/mcp/session_client.go
mockMCPClientpkg/tools/mcp/mcp_test.go
reconnectableMockClientpkg/tools/mcp/mcp_test.go
failingInitClientpkg/tools/mcp/reconnect_test.go
clientSessionpkg/tools/mcp/mcp.go
lspSessionpkg/tools/builtin/lsp/lsp_lifecycle.go

Calls 7

forwardEventsMethod · 0.95
UserMessageFunction · 0.92
eventBufferSizeFunction · 0.85
AddMessageMethod · 0.65
RunStreamMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected