INNER CODE UNIT · TypeScript

recoveryCallable

JuliusBrussee/caveman · packages/pi-extension/src/index.ts:313

  const recoveryCallable = (): boolean => {
    try {
      return typeof pi.getActiveTools === "function" && pi.getActiveTools().includes(RECOVERY_TOOL);
    } catch {
      return false;
    }
  };

  pi.on("tool_result", GUARD_tool_result((event: Parameters<typeof shrinkToolResult>[2], ctx: ExtensionContext) =>
    event.toolName === RECOVERY_TOOL || !recoveryCallable() ? undefined : shrinkToolResult(bridge, sessionId, event, recovery, () => {
      // The runtime answered SessionStart and then stopped answering, so
      // shrinking has silently stopped for the rest of the session: the user
      // pays full token cost with nothing to show for it (#1287). Say so once.
      // A session that never reached a runtime already got the "native runtime
      // unreachable" notice above, so gate on reachable to avoid saying it twice.
      // One empty reply can also just be a hook that outran HOOK_TIMEOUT_MS, and
      // every later result is still attempted, so hedge rather than assert.
      if (!runtimeReachable || warnedNoReply) return;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…