MCP sampling is answered on the chat path but refused on the task path #1410

Closed
opened 2026-10-27 13:40:17 +00:00 by sam · 0 comments
Owner

The daemon's chat path wires an MCP sampling handler into its MCP tool providers (WithSamplingHandler from the chat model manager's active model), so a server-initiated sampling/createMessage is answered. The agent worker's MCP provider builder constructs providers without any sampling handler, so a task-scoped MCP server that asks for a completion gets a JSON-RPC method-not-found and the same configured server behaves differently depending on which path hosts it. The worker has its own model runtime available (the task's provider set and its builder model role), so it can answer. Fix: thread a sampling handler built from the worker's model runtime into the worker's MCP provider builder. Acceptance: a task-scoped MCP server's sampling request is answered by the worker's model, and the provider built by the worker's builder carries a non-nil handler.

Close reason

Fixed in 6fa1836e: the agent worker's MCP provider builder now receives a sampling handler built from the task's builder model and shared with the stage runners (internal/app/agentworker/mcp_sampling.go, mcp_providers.go, task_execution.go). A task-scoped server's sampling/createMessage is answered instead of refused; the message mapping and max-token bound moved to internal/agentexec/sampling.go so both host paths bound a sample identically, and config.ModelLimits carries the catalog's reasoning flag so a reasoning builder model omits the bound its provider rejects. Red test failed on the nil-handler assertion before the wiring (TestBuildMCPProviderWiresTaskSamplingHandler); scoped go test, vet and golangci-lint clean.


Imported from beads archie-core-k48d · GitHub #1457 · type bug · priority P2 · created 2026-10-02 · closed 2026-10-02

The daemon's chat path wires an MCP sampling handler into its MCP tool providers (WithSamplingHandler from the chat model manager's active model), so a server-initiated sampling/createMessage is answered. The agent worker's MCP provider builder constructs providers without any sampling handler, so a task-scoped MCP server that asks for a completion gets a JSON-RPC method-not-found and the same configured server behaves differently depending on which path hosts it. The worker has its own model runtime available (the task's provider set and its builder model role), so it can answer. Fix: thread a sampling handler built from the worker's model runtime into the worker's MCP provider builder. Acceptance: a task-scoped MCP server's sampling request is answered by the worker's model, and the provider built by the worker's builder carries a non-nil handler. ### Close reason Fixed in 6fa1836e: the agent worker's MCP provider builder now receives a sampling handler built from the task's builder model and shared with the stage runners (internal/app/agentworker/mcp_sampling.go, mcp_providers.go, task_execution.go). A task-scoped server's sampling/createMessage is answered instead of refused; the message mapping and max-token bound moved to internal/agentexec/sampling.go so both host paths bound a sample identically, and config.ModelLimits carries the catalog's reasoning flag so a reasoning builder model omits the bound its provider rejects. Red test failed on the nil-handler assertion before the wiring (TestBuildMCPProviderWiresTaskSamplingHandler); scoped go test, vet and golangci-lint clean. --- _Imported from beads `archie-core-k48d` · GitHub #1457 · type bug · priority P2 · created 2026-10-02 · closed 2026-10-02_
sam added the mediumbug labels 2026-10-27 13:40:17 +00:00
sam self-assigned this 2026-10-27 13:40:17 +00:00
sam closed this issue 2026-10-27 13:40:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1410