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

Implementation:AIPentest CyberStrikeAI runEinoADKAgentLoop

From Leeroopedia
Knowledge Sources
Domains Multi_Agent, Orchestration
Last Updated 2026-10-19 04:10 GMT

Overview

Concrete tool for driving the Eino ADK multi-agent event loop provided by the internal/multiagent package.

Description

runEinoADKAgentLoop is the shared control loop for Deep, Plan-Execute, and Supervisor orchestration modes. It takes an einoADKRunLoopArgs (orchestrator agent, conversation ID, progress callback, middleware config, token budgets) and base messages, then runs the Eino ADK event iterator with context hookup. For each event it dispatches to stream/materialize handlers, normalizes streaming deltas, reconciles tool pairs, prunes orphan tool results, and classifies errors (stream cancel, turn-loop preempt, iteration limit, panic) into restart-or-return decisions. It supports retry with exponential backoff on 429/5xx and context-overflow compression.

Usage

  • First engagement (step 5): the single-agent and multi-agent runners both call this loop.
  • Multi-agent sub-agent execution: each sub-agent turn runs through this loop with its own agent instance.
  • HITL continuation: after an approved/rejected tool call, the loop resumes from the tool result.

Code Reference

Source Location

  • Repository: CyberStrikeAI
  • File: internal/multiagent/eino_adk_run_loop.go
  • Lines: einoADKRunLoopArgs L109-155, runEinoADKAgentLoop L157-333

Signature

type einoADKRunLoopArgs struct {
    OrchMode, OrchestratorName, ConversationID string
    Progress   func(eventType, message string, data interface{})
    Logger     *zap.Logger
    DA         adk.Agent
    MaxTotalTokens, ToolMaxBytes int
    ModelName  string
    MiddlewareConfig *config.MultiAgentEinoMiddlewareConfig
    MCPExecutionBinder      *MCPExecutionBinder
    FilesystemMonitorRecord einomcp.ExecutionRecorder
    ToolInvokeNotify        *einomcp.ToolInvokeNotifyHolder
    EmptyResponseMessage string
    // ... retry, callbacks, trace holders ...
}

func runEinoADKAgentLoop(ctx context.Context, args *einoADKRunLoopArgs,
    baseMsgs []adk.Message) (*RunResult, error)

type RunResult struct {
    Response, LastAgentTraceInput, LastAgentTraceOutput string
    MCPExecutionIDs []string
    Finalized bool
    Status, CompletionReason string
}

Import

// internal package — invoked by RunDeepAgent / RunEinoSingleChatModelAgent

I/O Contract

Inputs

Name Type Required Description
ctx context.Context Yes Cancellable context for interrupt/shutdown
args *einoADKRunLoopArgs Yes Agent, conversation, progress, budgets, middleware
baseMsgs []adk.Message Yes Initial message history

Outputs

Name Type Description
returns *RunResult, error Final response + traces + MCP execution IDs

Usage Examples

Run a Deep Orchestrator

result, err := runEinoADKAgentLoop(ctx, &einoADKRunLoopArgs{
    OrchMode:         "deep",
    OrchestratorName: "orchestrator",
    ConversationID:   convID,
    DA:               deepAgent,
    Progress:         progressCallback,
    Logger:           zapLogger,
    MaxTotalTokens:   100000,
    ToolMaxBytes:     12000,
    ModelName:        "gpt-4o",
}, baseMsgs)

Related Pages

Implements Principle

Uses Heuristic

Requires Environment

Page Connections

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