Skip to content

πŸ› fix(scheduler): kicks point at hive-task only for agents that have the MCP server - #16910

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/task-mcp-pointer-only-when-connected
Nov 6, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/task-mcp-pointer-only-when-connected

Conversation

@Danathar

@Danathar Danathar commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Every scheduler kick told its agent that the hive-task MCP server is connected and to call context_bundle first. 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. With task_mcp.drop_stuffed_context: true their 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:

## Task context MCP

The `hive-task` MCP server is connected for this launch. Call `context_bundle` first for the assigned task, related work, and CI summary instead of re-reading the issue/PR and CI from scratch.

It has no such server. With drop_stuffed_context: true its lists were also cut down to bare repo#N refs, and the kick named context_bundle as the source of truth for everything else. That left the agent with neither the titles nor a way to fetch them.

What changes

  • The pointer is sent only to an agent that launches as Claude Code. Agents on an inference backend or a configured model gateway count, because they run the claude CLI.
  • The scheduler asks the agent runtime which backend an agent launches on. An agent that provider rotation moved from claude to copilot stops getting the pointer, even though its config still says claude.
  • drop_stuffed_context is 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.
  • A hive without a dashboard token cannot mint the launch token the endpoint requires. The scheduler is no longer told about the endpoint there, so no agent on that hive is pointed at it.
  • A replica of a Claude Code agent keeps the pointer. A review head is judged by its own backend, not its base agent's.

Nothing changes for a Claude Code agent on a hive with a dashboard token.

Not covered

  • A sandboxed agent (sandbox.enabled) runs its kicks through a headless CLI that gets no MCP configuration. A sandboxed Claude agent is still pointed at the server.
  • A remote contributor who takes on an agent role is shown that agent's kick. It now follows the hub agent's backend, which says nothing about the contributor's own setup.

Files

  • src/pkg/scheduler/kickmessage.go: new taskMCPConnected and launchBackend; dropStuffedContext and addTaskMCPPointer use them.
  • src/pkg/scheduler/scheduler.go: new AgentBackendLookup and SetAgentBackendLookup; a contract comment on SetTaskMCPURL.
  • src/pkg/scheduler/kick_layout.go: assembleKick passes the agent name to addTaskMCPPointer.
  • src/cmd/hive/main.go: bootGovernor calls wireSchedulerTaskMCP (one line replaced).
  • src/cmd/hive/task_mcp_kick_wire.go: new wireSchedulerTaskMCP, taskMCPURLForKicks and agentLaunchBackend.
  • 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 when drop_stuffed_context applies.
  • src/docs/agent-configuration.md: the drop_stuffed_context comment.
  • src/hive.yaml.example: the drop_stuffed_context comment.
  • 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.
  • TestTaskMCPPointerFollowsRuntimeBackend and TestTaskMCPPointerDoesNotAskRuntimeWithoutEndpoint: 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

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 6, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16915 πŸ› fix(task-mcp): a remote task's MCP token works for as long as its lease is renewed same files src/docs/design/task-mcp.md
#16919 πŸ› fix(taskmcp): knowledge answers multi-word queries and serves full bodies same files src/docs/design/task-mcp.md

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive

hivecommons-hive Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from adjudicator-3 (folded here because this head already carries its hive review):

Style review (head f0cf11f) β€” non-blocking; one maintainability note.

taskMCPConnected adds a fourth hand-rolled copy of "this backend launches the claude CLI" β€” src/pkg/scheduler/kickmessage.go:713:

return backend == "claude" || config.IsInferenceBackend(backend) || s.cfg.Governor.ResolveGateway(backend) != nil

The same rule already lives in the launcher (src/crux/agent/manager_routing.go:52-60 routableBackend, :147-156 backendBinaryName β†’ "claude"), in src/pkg/config/backends.go:93 (IsInferenceBackend(backend) || g.isGatewayName(backend)) and in the manager's gateway checker at src/cmd/hive/main.go:2057-2060. The kick pointer's correctness depends on this predicate staying byte-for-byte equal to what connectionMCPFlags (manager_launch.go:1056) ends up seeing, so a backend added to one list and not the other silently re-opens the bug this PR fixes. The backend == "" early return at kickmessage.go:709-711 is also load-bearing β€” ResolveGateway("") returns the default gateway (src/crux/config/gateways.go:53-56), so dropping or reordering it would point every default-backend agent at the server β€” but the comment above it does not say so.

Suggested: give pkg/config one exported predicate next to the existing isGatewayName, and call it from the scheduler (and later from main.go:2057):

--- 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 launchBackend replica fallback mirrors dropStuffedContext, SetAgentBackendLookup follows the existing Set* setter + RLock pattern in scheduler.go, and the host-side wiring in task_mcp_kick_wire.go keeps boot nil-safe like its neighbours.

Evidence bundle `#16910f0cf11f` sha256:8bc764a037807323496e14e52909d8ef397e6c9b8c979e833ed038692dc2cd5c β€” download from the dashboard or `hivectl review evidence #16910`.

@hivecommons-hive
hivecommons-hive Bot merged commit fe043a2 into hivecommons:v6 Nov 6, 2026
71 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant