pub fn spawn_agent(
world: &mut World,
agent_id: String,
blueprint: Blueprint,
task: &str,
stages: Vec<ResolvedStage>,
global_hints: PromptHints,
) -> 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_hints is the caller’s global config toggle for each system-prompt
hint; each is resolved per stage against the blueprint’s agent-level and
per-stage override of the same name.