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

Method RunStream

pkg/runtime/loop.go:225–231  ·  view source on GitHub ↗

RunStream starts the agent's interaction loop and returns a channel of events. The returned channel is closed when the loop terminates (success, error, or context cancellation). Each iteration: sends messages to the model, streams the response, executes any tool calls, and loops until the model sign

(ctx context.Context, sess *session.Session)

Source from the content-addressed store, hash-verified

223// the response, executes any tool calls, and loops until the model signals stop
224// or the iteration limit is reached.
225func (r *LocalRuntime) RunStream(ctx context.Context, sess *session.Session) <-chan Event {
226 slog.DebugContext(ctx, "Starting runtime stream", "agent", r.currentAgentName(), "session_id", sess.ID)
227 events := make(chan Event, defaultEventChannelCapacity)
228
229 go r.runStreamLoop(ctx, sess, events)
230 return r.observe(ctx, sess, events)
231}
232
233// runStreamLoop is the body of RunStream. Pulled out of the anonymous
234// goroutine so it has a real name in stack traces and is easier to navigate

Calls 3

currentAgentNameMethod · 0.95
runStreamLoopMethod · 0.95
observeMethod · 0.95