Repository navigation
π fix(scheduler): kicks point at hive-task only for agents that have the MCP server - #16910
Conversation
β¦the MCP server Every kick told its agent "The hive-task MCP server is connected for this launch. Call context_bundle first". The pointer was gated only on the hive having a task MCP URL, which it always has, but only a Claude Code launch is given that server. Agents on every other backend were pointed at a tool they do not have, and task_mcp.drop_stuffed_context cut their work lists down to bare refs as well. The pointer and the elision now need the agent to launch as Claude Code (inference backends and gateway names included). The scheduler asks the agent runtime for the backend, so a provider-rotation override counts. A hive without a dashboard token mints no launch token and its endpoint refuses every call, so the scheduler is not given the endpoint there. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
docs-currency (read at head f0cf11f)
The docs track the code: connectionMCPFlags returns nothing unless backend == "claude" (src/crux/agent/manager_launch.go:1056-1057) and inference/gateway launches are rewritten to claude first (manager_launch.go:101,133), which is exactly what the new text in src/docs/design/task-mcp.md and the drop_stuffed_context comments say. The 215-byte figure added under "First live measurement" matches the pointer string in kickmessage.go.
One advisory gap, low severity: the PR body's "Not covered" admits a sandboxed Claude agent still gets the pointer, and startSandboxKickLocked (src/crux/agent/manager_sandbox.go:109-160) indeed builds a SandboxKickSpec with no connections/MCP config. The design doc (task-mcp.md, new bullets after "An agent gets the pointer only when both of these hold") omits this, so an operator reading it would conclude a sandboxed Claude agent has the server. Suggest noting it next to the second bullet:
- The hive can mint the launch token the endpoint requires, which needs a dashboard token (see "Hub-launched scoping"). Without one the endpoint refuses every agent call.
Known gap: a sandboxed agent (`sandbox.enabled`) runs each kick through a headless CLI that is given no MCP configuration, so a sandboxed Claude Code agent still receives the pointer but has no `hive-task` server to call.
β hive: agent=adjudicator-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Style review (head f0cf11f) β non-blocking; one maintainability note.
return backend == "claude" || config.IsInferenceBackend(backend) || s.cfg.Governor.ResolveGateway(backend) != nilThe same rule already lives in the launcher ( Suggested: give --- a/src/pkg/config/backends.go
+++ b/src/pkg/config/backends.go
@@ isGatewayName
+// LaunchesClaudeCLI reports whether backend is started as the claude CLI:
+// claude itself, an inference backend, or a configured gateway name. This is
+// the launcher's rule (crux/agent routableBackend / backendBinaryName) and the
+// only CLI connectionMCPFlags builds an MCP config for. An empty backend is
+// the hive default, never a named gateway (ResolveGateway("") would return
+// the default gateway), so it is excluded here on purpose.
+func (g GovernorConfig) LaunchesClaudeCLI(backend string) bool {
+ if backend == "" {
+ return false
+ }
+ return backend == "claude" || IsInferenceBackend(backend) || g.isGatewayName(backend)
+}
--- a/src/pkg/scheduler/kickmessage.go
+++ b/src/pkg/scheduler/kickmessage.go
@@ func (s *Scheduler) taskMCPConnected(agentName string) bool {
- backend := s.launchBackend(agentName)
- if backend == "" {
- return false
- }
- return backend == "claude" || config.IsInferenceBackend(backend) || s.cfg.Governor.ResolveGateway(backend) != nil
+ return s.cfg.Governor.LaunchesClaudeCLI(s.launchBackend(agentName))Everything else reads cleanly: the |
Summary
Every scheduler kick told its agent that the
hive-taskMCP server is connected and to callcontext_bundlefirst. Only an agent launched as Claude Code is given that server. Agents on copilot, codex, cline and every other backend were told on every kick to call a tool they do not have, and so was every agent on a hive without a dashboard token, where the endpoint refuses all calls. Withtask_mcp.drop_stuffed_context: truetheir issue and PR lists were also cut down to bare refs. The pointer and the list cut now apply only to agents that really have the server.What went wrong
The scheduler added the pointer whenever the hive had a task MCP URL, and the hive always has one. The launcher builds an MCP configuration for the claude CLI only.
So a copilot agent read this at the top of every kick:
It has no such server. With
drop_stuffed_context: trueits lists were also cut down to barerepo#Nrefs, and the kick namedcontext_bundleas the source of truth for everything else. That left the agent with neither the titles nor a way to fetch them.What changes
drop_stuffed_contextis ignored for an agent without the server. Its lists stay complete, and its kick is byte for byte what it was before the pointer existed.Nothing changes for a Claude Code agent on a hive with a dashboard token.
Not covered
sandbox.enabled) runs its kicks through a headless CLI that gets no MCP configuration. A sandboxed Claude agent is still pointed at the server.Files
src/pkg/scheduler/kickmessage.go: newtaskMCPConnectedandlaunchBackend;dropStuffedContextandaddTaskMCPPointeruse them.src/pkg/scheduler/scheduler.go: newAgentBackendLookupandSetAgentBackendLookup; a contract comment onSetTaskMCPURL.src/pkg/scheduler/kick_layout.go:assembleKickpasses the agent name toaddTaskMCPPointer.src/cmd/hive/main.go:bootGovernorcallswireSchedulerTaskMCP(one line replaced).src/cmd/hive/task_mcp_kick_wire.go: newwireSchedulerTaskMCP,taskMCPURLForKicksandagentLaunchBackend.src/pkg/scheduler/task_mcp_pointer_connected_test.go: new tests.src/pkg/scheduler/task_mcp_pointer_runtime_backend_test.go: new tests.src/cmd/hive/task_mcp_kick_wire_test.go: new tests.src/docs/design/task-mcp.md: who gets the pointer and whendrop_stuffed_contextapplies.src/docs/agent-configuration.md: thedrop_stuffed_contextcomment.src/hive.yaml.example: thedrop_stuffed_contextcomment.changelog.d/fixed-task-mcp-pointer-only-when-connected.md: changelog entry.Tests
New, all fail without the change:
TestTaskMCPPointerOnlyForBackendsThatLaunchClaude: every supported backend; only claude, the inference backends and a configured gateway get the pointer.TestTaskMCPDropStuffedContextNeedsTheConnection: copilot, codex and cline keep full lists with the flag on, and their kick equals the kick of a hive with no task MCP URL.TestTaskMCPPointerNotForUnconfiguredAgent: an agent the hive has no config for gets no pointer.TestTaskMCPPointerForReplicasAndReviewHeads: a replica follows its base; a review head follows its own backend.TestTaskMCPPointerFollowsRuntimeBackendandTestTaskMCPPointerDoesNotAskRuntimeWithoutEndpoint: the runtime's backend wins over the config. These use the new setter, so they do not compile against the old code.TestKickPointsAtTaskMCPOnlyWhenALaunchTokenCanBeMinted: a booted hive without a dashboard token sends no pointer; with one it does.TestKickTaskMCPPointerFollowsRuntimeBackendOverride: a booted hive drops the pointer when the agent manager moves the agent to copilot.Still green:
TestTaskMCPPromptPointerGatedByURL,TestTaskMCPDropStuffedContextGatesRefsOnlyAndIssueRefs,TestTaskMCPElidesTemplateMergeEligibleToRefsOnly, and the full./pkg/scheduler/and./cmd/hive/packages.π€ Generated with Claude Code