pub fn spawn_agent(
world: &mut World,
agent_id: String,
blueprint: Blueprint,
task: &str,
stages: Vec<ResolvedStage>,
global_batch_tool_hint: bool,
) -> Result<Entity, String>Expand description
Spawn a fully-formed agent into world from its blueprint, task, and
per-stage resolution, and return its entity. Builds every stage’s
StageInference/StageSetup up front (so transitions are pure component
swaps), seeds the context window, applies the first stage’s setup (its
layout and system prompt), pre-counts the first stage’s visit, and marks the
agent ReadyToInfer. Returns Err if the first stage’s system prompt doesn’t fit
its region (the same hard failure the imperative loop raises at stage 0).
stages must be aligned with blueprint.stages (one ResolvedStage each).
global_batch_tool_hint is the caller’s global config toggle for the
batch-tool-calls system-prompt hint; it is resolved per stage against the
blueprint’s agent-level and each stage’s batch_tool_hint.