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

Principle:42 evey Hermes plugins LLM Delegation

From Leeroopedia
Knowledge Sources
Domains LLM_Delegation, Agent_Architecture, Autonomous_Agents
Last Updated 2026-10-29 00:00 GMT

Overview

A pattern for making out-of-band LLM calls from any execution context (not just an active agent conversation), enabling plugins, cron jobs, and background tasks to leverage LLM capabilities.

Description

LLM Delegation is the mechanism by which an autonomous agent invokes an LLM to perform a subtask without being in a direct conversation with the user. The key challenge is that the LLM gateway credentials and context are stored in context variables tied to the active session — but delegation may originate from a cron job, a Telegram handler, or another plugin with no active conversation.

The pattern solves this by:

  1. Storing the LLM gateway in a module-level context (ctx) set at plugin registration time, accessible from any code path.
  2. Using ctx.llm.complete() as the uniform API for all LLM calls, with parameters for messages, max_tokens, temperature, timeout, and purpose.
  3. Handling model override trust: Model overrides require explicit operator permission (allow_model_override in config). Without it, the call silently falls back to the active model with a note.

Usage

Use this principle when any part of an agent system needs to make LLM calls outside of a direct user conversation. Appropriate for background processing, cron-triggered tasks, plugin-to-plugin delegation, and parallel multi-model execution.

Theoretical Basis

The delegation pattern separates the call context from the conversation context:

# Abstract pattern (NOT real implementation)
_CTX = None  # set at registration, holds the LLM gateway

def delegate(goal, model=None, context=""):
    prompt = build_prompt(goal, context)
    result = _CTX.llm.complete(
        messages=[{"role": "user", "content": prompt}],
        max_tokens=2000,
        temperature=0.7,
        purpose="delegation",
        model=model,  # only honored if operator grants allow_model_override
    )
    return result.text

The purpose parameter tags each call for observability, enabling per-plugin cost tracking and trace attribution.

For parallel delegation, contextvars.copy_context() preserves the gateway's credential contextvars across thread pool boundaries, ensuring each parallel call has valid credentials.

Related Pages

Implemented By

Page Connections

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