mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 18:30:09 +00:00
Tool handlers previously reached back into the runtime through two context keys (ToolOutputEmitter, ToolRecallEmitter), each with its own With*/FromContext/Emit* boilerplate, invisible in the handler signature and requiring ad-hoc lifetime tricks (context.WithoutCancel + closure capture) for background work. Replace both with a single tools.Runtime capability handle passed explicitly to every handler: - ToolHandler is now func(ctx, ToolCall, rt Runtime); runtime-managed handlers (toolexec.ToolHandler) grow the same parameter, unifying the two tool APIs on one capability surface - Runtime methods (EmitOutput, Recall, Supports) take ctx per call and remain valid after the handler returns, so background jobs hold the handle instead of a captured closure - NopRuntime serves hosts without an agent loop (slash commands, prompt expansion, tests); Supports() lets tools fail fast before starting background work - NewHandler keeps its signature; NewRuntimeHandler is the variant for tools that talk back (shell streaming/recall, codemode forwarding) - codemode forwards the handle into script-invoked tools, preserving the nested-capability inheritance the ctx transport gave implicitly