Skip to main content

Module runtime

Module runtime 

Source
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)

ModeTriggerPath
PromptBasedAgent (default)spec.script_path absentScriptSource::DefaultAgent — the SDK’s embedded invoker (the agent StdPkg module invoked with _PROMPT / _CONTEXT); event kind = agent_result.
ScriptBasedAgentspec.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

VersionFeatureUse case
v0.22.0bus.emit(kind, payload, id?) Lua bridgescript → host event push
v0.23.0BlockConfig.host_handlersPre-install a Rust handler on the EventBus
v0.24.0BlockConfig.auto_serve_busSDK embed drives the dispatcher in the background
v0.25.0BlockConfig.shutdown_token + BlockError::Cancelled + Send on run()tokio::spawn and external cancel
v0.26.0ScriptSource / PromptSource / SecretKeySource enums plus the embedded DefaultAgent invoker (breaking)Script becomes optional at the SDK level
v0.27.0Embed the compile_loop StdPkg into corerequire("compile_loop") hits directly

Structs§

AgentBlockInProcessSpawnerFactory
The SpawnerFactory for AgentBlock. KIND = AgentKind::AgentBlock.
AgentBlockWorker
Concrete Worker type for the AgentBlock kind — the handle for an LLM call routed through the agent-block-core SDK. Embeds a WorkerJoinHandler to carry the async signal. The intent is to eventually keep the SDK-specific quirks — the agent_result event 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_path is absent). Instead of the SDK’s embedded DEFAULT_AGENT_INVOKER (which passes no tools), this embeds mcp_servers as a Lua literal table and hands it to agent.run.
resolve_needed_mcp_servers
Cross-reference profile.tools (the CSV on the tools: line of an agent.md frontmatter) with spec.mcp_servers (the "server name" → command + args mapping provided by the AgentDef literal cascade) and resolve the mcp_servers config actually exposed to the LLM for this invocation.