pub(crate) async fn open_agent_impl(
state: &AppState,
cmd: CommandAgentOpenData,
) -> Result<AgentOpenResult, String>Expand description
The agent.open implementation — load the definition, resolve the
provider/CLI, create the block, enqueue the layout insert, and register
the controller. Extracted from the RPC closure so the HTTP surface
(POST /api/v1/agent/open, backing the OpenAgent MCP tool) shares this
exact code path instead of re-deriving it: the TOCTOU serialization via
AGENT_OPEN_LOCKS (reagent P1 on PR #2059), the ABF provider shadowing,
the resume-session seeding guard, and the CLI path resolution all live
here once. Same extraction shape as open_pane / handle_pane_open.
See docs/reports/REPORT_AGENT_OPEN_API_GAP_2026_09_06.md.