Skip to main content

try_daemon_tool_call_blocking

Function try_daemon_tool_call_blocking 

Source
pub fn try_daemon_tool_call_blocking(
    name: &str,
    arguments: Option<Value>,
) -> Option<String>
Expand description

Blocking helper for CLI commands: routes a tool call through the daemon.

Returns None if no daemon can serve the call (caller then renders the tool locally / standalone). Behaviour splits on caller identity:

  • Normal CLI invocation: connects to a running daemon, and auto-starts one if none is listening (so the long-lived LeanCtxServer state — caches, indexes, detectors — is reused across commands).
  • Shadow-mode hook child (LEAN_CTX_HOOK_CHILD set): connect-only. It reuses an already-running daemon for full parity (the ready fast-path below routes straight through /v1/tools/callcall_tool_guarded, so the in-memory LoopDetector, correction-loop auto-degrade, bounce tracker and adaptive thresholds all fire on the daemon’s long-lived state — #566), but it MUST NEVER auto-start a daemon. A hook fires once per intercepted read/grep as a fresh process; auto-starting from there would spawn daemons uncontrollably. With no live daemon it returns None and the caller falls back to the enriched standalone path (disk-backed learning sinks + Context IR from #550/#569).