Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:AIPentest CyberStrikeAI Soft Error Pattern

From Leeroopedia
Knowledge Sources
Domains LLMs, Debugging, Agent_Design
Last Updated 2026-10-19 00:00 GMT

Overview

Convert tool execution failures into soft errors (nil Go error + descriptive message returned to the LLM) so the agent can self-correct within the same turn instead of crashing the orchestration graph.

Description

In the Eino agent graph, a hard error from a tool propagates as a `NodeRunError` that either triggers an expensive full-replay retry or terminates the run entirely. CyberStrikeAI instead wraps every tool result that represents a recoverable failure (invalid JSON args, tool not found, command failure, timeout, permission denied, network unreachable) with a `ToolErrorPrefix` sentinel (`__CYBERSTRIKE_AI_TOOL_ERROR__\n`) and returns `nil` as the Go error. The run loop strips the prefix, surfaces a bilingual error message to the model, and lets the LLM adjust its next tool call. A companion middleware (`softRecoveryToolCallMiddleware`) catches errors that escape the bridge layer using a default-soft blacklist — only `context.Canceled` (user-initiated) is treated as truly fatal; everything else is converted to a soft tool-result message.

Usage

Apply this heuristic whenever an LLM agent calls external tools that may fail transiently or via malformed arguments. Use it to avoid full graph replays and run termination on recoverable errors, letting the model retry, pick an alternative tool, or explain the failure to the user. Do not apply it to user-cancellation or truly fatal conditions that must stop the orchestration.

The Insight (Rule of Thumb)

  • Action: Return `(ToolErrorPrefix + descriptiveMessage, nil)` from tool invocations instead of `("", err)` for recoverable failures; never let the error propagate as a Go error to the Eino `ToolsNode`.
  • Value: `ToolErrorPrefix = "__CYBERSTRIKE_AI_TOOL_ERROR__\n"`; soft-recovery blacklist contains only `context.Canceled`.
  • Trade-off: The model may loop on a genuinely broken tool, but the run stays alive and the model can self-correct or switch tools. Cost is a potential extra iteration vs. the high cost of a full replay or a terminated engagement.
  • Default-soft, not default-hard: Prefer a blacklist (`isSoftRecoverableToolError` returns `true` for everything except `context.Canceled`) over a fragile whitelist that must enumerate every new error pattern.
  • Bilingual messages: Emit errors in both English and Chinese so the model and the human reviewer both see actionable detail.
  • Argument preview truncation: Cap the args preview at 300 chars in the error message to avoid flooding the context.

Reasoning

A hard error in Eino's `ToolsNode` propagates to `ev.Err` and triggers the full-replay retry loop or run termination — both catastrophic for a long-running pentest engagement. By converting recoverable failures to soft errors:

  1. The model sees the failure as a normal tool result and can reason about it (fix JSON, choose another tool, ask the user).
  2. The graph never breaks — no replay, no termination, no lost conversation state.
  3. The blacklist stays tiny — only `context.Canceled` is fatal, so new error types are automatically recoverable without code changes.
  4. The sentinel prefix lets downstream handlers (`eino_adk_run_loop.go`, `eino_run_result_builder.go`) detect error results and strip the prefix before presentation, keeping success/error handling uniform.

Observed in `internal/einomcp/mcp_tools.go:139-141` (soft error on JSON parse failure), `:184-187` (soft error on `res.IsError`), and `internal/multiagent/tool_error_middleware.go:91-105` (default-soft blacklist).

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment