Skip to main content

build_inline_agent_invoker

Function build_inline_agent_invoker 

Source
pub fn build_inline_agent_invoker(mcp_servers: &[Value]) -> ScriptSource
Expand description

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.

This is the core of the observation #3 fix. The old DefaultAgent path had no way to deliver a frontmatter tools: line to the SDK. This inline path bakes the profile.toolsmcp_servers config into the Lua source, so the LLM can actually make tool calls.

The JSON-stringify + std.json.decode route was ruled out because the SDK environment cannot require the std module (no package.preload['std'] field), so we take the JSON → Lua-literal conversion on the Rust side and embed the result directly. The event name is agent_result — the same convention the SDK’s internal DEFAULT_AGENT_INVOKER uses.