Skip to main content

Module agents

Module agents 

Source
Expand description

The agents__* family - one address space for every forge session.

A target is a slot: (org, project, label), with lead reserved for a project’s own agent. Three verbs reach any slot from any session; the rest act on the caller’s own project and are lead-only.

Re-exportsΒ§

use std::sync::Arc; πŸ”’
use forge_sdk::mcp::tool::Tool; πŸ”’
use forge_sdk::mcp::tool::ToolInput; πŸ”’
use forge_sdk::mcp::tool::ToolOutput; πŸ”’
use crate::SessionSlot; πŸ”’
use crate::mcp::agents::facade::AgentDispatcher; πŸ”’
use crate::mcp::agents::target::AgentTarget; πŸ”’
use crate::mcp::agents::target::TargetError; πŸ”’
use crate::mcp::peers::facade::WorkspaceFacade; πŸ”’
use crate::mcp::peers::types::MessageId; πŸ”’
use crate::mcp::peers::types::PeerStatus; πŸ”’
use crate::mcp::peers::types::WrappedKind; πŸ”’
use crate::mcp::peers::types::WrappedPrompt; πŸ”’
use crate::mcp::workers::facade::DespawnOutcome; πŸ”’
use crate::mcp::workers::facade::WorkerCapSource; πŸ”’
use crate::mcp::workers::facade::WorkerDespawnError; πŸ”’
use crate::mcp::workers::facade::WorkerFacade; πŸ”’
use crate::mcp::workers::facade::WorkerSpawnError; πŸ”’
use crate::mcp::workers::facade::WorkerUpdateError; πŸ”’
use crate::protocol::SessionChoice; πŸ”’

ModulesΒ§

facade
The seam between the merged agents__* family and the two engines it drives. Every verb that takes a target resolves it here, so the routing rule lives in one place rather than at each call site.
target
The address an agents__* call names.

StructsΒ§

Capacity πŸ”’
agents__capacity - lead-only aggregate read of the caller’s project worker capacity. One JSON object rather than the per-worker snapshots agents__list returns.
Despawn πŸ”’
agents__despawn - lead-only. Closes a worker by label and cleans up its git worktree. A clean worktree is removed; a dirty one (uncommitted/untracked or unpushed commits) blocks the despawn unless force.
DespawnArgs πŸ”’
Handoff πŸ”’
agents__handoff - hand this seat over to a fresh session, from the session itself.
HandoffArgs πŸ”’
List πŸ”’
agents__list - every seat you can address, optionally narrowed to one project. No target args.
ListArgs πŸ”’
SendMessage πŸ”’
agents__send_message - one verb for every send, to any seat.
SendMessageArgs πŸ”’
Spawn πŸ”’
agents__spawn - lead-only. Allocates a new session in the caller’s project, threading charter through the new session’s system-prompt addendum, then returns the assigned session_id and tag (forge:worker:<label>).
SpawnArgs πŸ”’
TargetArgs πŸ”’
Update πŸ”’
agents__update - lead-only. Revises the stored charter, kick and resume_kick of an EXISTING worker, keyed by (project_key, label) exactly as agents__spawn persisted it.
UpdateArgs πŸ”’
Whoami πŸ”’
agents__whoami - the caller’s own slot and identity. No args.

FunctionsΒ§

add_lead_tools πŸ”’
Attach the four lead-only verbs to an existing McpServerBuilder. Each acts on the caller’s own project, so a worker has no project to act on and is not offered the surface.
add_shared_tools πŸ”’
Attach the three any-caller verbs to an existing McpServerBuilder.
build_server
Build a standalone forge MCP server carrying the whole agents__* family as a lead sees it. The wire-conformance harness drives the surface through this against mock facades.
canonical_spawn_families πŸ”’
Validate and canonicalise a spawn or update mcp_families argument: names in wire order, de-duplicated; an empty list resolves to None (every family) for a spawn.
format_despawn_error πŸ”’
format_spawn_error πŸ”’
format_update_error πŸ”’
json_output πŸ”’
row πŸ”’
A snapshot row: the address to pass back to agents__send_message, then whatever the engine that produced the snapshot knows about the seat.
sender_identity πŸ”’
The name and org an envelope carries for the session that sent it, derived from that session’s own slot: the project for a project’s own agent, project/label for a worker, with the org beside it.
slot_json πŸ”’
The slot an agent is addressed by, which is the shape every row and every response carries.
target_error_message πŸ”’
LLM-facing explanation of a target that did not resolve. Names the reachable set, because a target that refuses is usually a typo.
tool_error πŸ”’