Expand description
AgentBlockInProcessSpawnerFactory — in-process headless LLM
agent execution over the agent-block-core SDK.
§Design responsibility — a state-less factory
The factory is a kind-level general-purpose builder — the
process-wide infrastructure layer. It does not carry per-agent
specialisation (script / system_prompt / tools); all agent
specialisation belongs to AgentDef.spec + AgentDef.profile. The
old default_script_path / default_project_root fields were
removed — they were the collision source when a single process
hosts multiple agent.md files.
§Two modes (via ScriptSource, v0.27.0)
| Mode | Trigger | Path |
|---|---|---|
| PromptBasedAgent (default) | spec.script_path absent | ScriptSource::DefaultAgent — the SDK’s embedded invoker (the agent StdPkg module invoked with _PROMPT / _CONTEXT); event kind = agent_result. |
| ScriptBasedAgent | spec.script_path = "<path>" | ScriptSource::Path(...) — a caller-provided Lua script; event kind = worker_result. |
profile.system_prompt (the agent.md body) is injected into the
_CONTEXT Lua global through BlockConfig.context, and applies to
both modes.
§Spec shape (AgentDef.spec)
{
"project_root": "<path>", // optional, default = std::env::current_dir()
"script_path": "<path>", // optional; absent => ScriptSource::DefaultAgent (PromptBased)
"mcp_rpc_timeout_ms": 30000 // optional, default = 30s
}§SDK paths introduced from v0.22.0 through v0.27.0
| Version | Feature | Use case |
|---|---|---|
| v0.22.0 | bus.emit(kind, payload, id?) Lua bridge | script → host event push |
| v0.23.0 | BlockConfig.host_handlers | Pre-install a Rust handler on the EventBus |
| v0.24.0 | BlockConfig.auto_serve_bus | SDK embed drives the dispatcher in the background |
| v0.25.0 | BlockConfig.shutdown_token + BlockError::Cancelled + Send on run() | tokio::spawn and external cancel |
| v0.26.0 | ScriptSource / PromptSource / SecretKeySource enums plus the embedded DefaultAgent invoker (breaking) | Script becomes optional at the SDK level |
| v0.27.0 | Embed the compile_loop StdPkg into core | require("compile_loop") hits directly |
Structs§
- Agent
Block InProcess Spawner Factory - The
SpawnerFactoryfor AgentBlock.KIND = AgentKind::AgentBlock. - Agent
Block Worker - Concrete Worker type for the AgentBlock kind — the handle for an
LLM call routed through the
agent-block-coreSDK. Embeds aWorkerJoinHandlerto carry the async signal. The intent is to eventually keep the SDK-specific quirks — theagent_resultevent name, payload shape, shutdown-token bridging, agent_result.content normalisation — contained inside this struct. Today it lands as a thin shape holding only the async signal; Phase B adds the normalisation layer here and structurally eliminates the token-boilerplate waste observed in observation #2.
Functions§
- build_
inline_ agent_ invoker - Build the inline Lua script used on the PromptBasedAgent path (when
spec.script_pathis absent). Instead of the SDK’s embeddedDEFAULT_AGENT_INVOKER(which passes no tools), this embedsmcp_serversas a Lua literal table and hands it toagent.run. - resolve_
needed_ mcp_ servers - Cross-reference
profile.tools(the CSV on thetools:line of an agent.md frontmatter) withspec.mcp_servers(the"server name" → command + argsmapping provided by theAgentDefliteral cascade) and resolve themcp_serversconfig actually exposed to the LLM for this invocation.