Files
cleveragents-core/docs/reference/actor_compiler.md
T
HAL9000 18d00c04c4
CI / lint (pull_request) Failing after 1m15s
CI / quality (pull_request) Successful in 1m21s
CI / typecheck (pull_request) Successful in 1m34s
CI / security (pull_request) Successful in 1m37s
CI / coverage (pull_request) Has been skipped
CI / unit_tests (pull_request) Failing after 1m37s
CI / docker (pull_request) Has been skipped
CI / build (pull_request) Successful in 33s
CI / helm (pull_request) Successful in 26s
CI / push-validation (pull_request) Successful in 19s
CI / e2e_tests (pull_request) Successful in 3m20s
CI / integration_tests (pull_request) Successful in 4m32s
CI / status-check (pull_request) Failing after 3s
fix(skills): implement multi-scope agent skill discovery for global, project, and local tiers
Implements AgentSkillDiscovery class to support discovering Agent Skills from
multiple configured directories across three scopes (global, project, local).
Handles name collisions with precedence: local > project > global.

Adds comprehensive BDD test coverage for multi-scope discovery scenarios including:
- Global-only, project-only, and local-only discovery
- Combined discovery from all scopes
- Name collision resolution with proper precedence
- Non-existent and empty scope directory handling
- Multiple skills in same scope discovery

ISSUES CLOSED: #9369
2026-05-06 19:55:22 +00:00

3.7 KiB

Actor Compiler

The actor compiler translates hierarchical YAML-defined GRAPH actors into LangGraph StateGraph node/edge structures that can be executed by the CleverAgents runtime.

Compilation Pipeline

  1. Input validation — The compiler accepts an ActorConfigSchema with type=GRAPH and a populated route field. Non-GRAPH types are rejected with ActorCompilationError.

  2. Reference validation — All node IDs referenced in edges, entry, and exit points are checked against the declared node set.

  3. Intra-graph cycle detection — The route's detect_cycles() method verifies the node graph is acyclic.

  4. Cross-actor subgraph cycle detection — When an optional actor_resolver is provided, the compiler follows SUBGRAPH node references recursively and detects cycles across actor boundaries (e.g. actor A → actor B → actor A).

  5. Node mapping — Each NodeDefinition is mapped to a LangGraph NodeConfig with the appropriate NodeType (AGENT, TOOL, CONDITIONAL, SUBGRAPH).

  6. Edge mapping — Each EdgeDefinition is mapped to a LangGraph Edge. Conditional expressions are preserved in edge.condition.

  7. LSP binding extraction — Per-node lsp_bindings config entries are extracted into LspBinding objects and stored in compilation metadata.

  8. Metadata assembly — The compiler returns a CompiledActor containing the node map, edge list, entry point, and a CompilationMetadata object for diagnostics and CLI inspection.

Node Binding

Actor Node Type LangGraph NodeType Notes
agent AGENT LLM invocation node
tool TOOL Tool execution node
conditional CONDITIONAL Routing node
subgraph SUBGRAPH Nested actor reference

LSP bindings are declared per-node in the config.lsp_bindings list:

nodes:
  - id: coder
    type: agent
    name: Code Writer
    description: Writes Python code
    config:
      agent: coder_agent
      lsp_bindings:
        - lsp_server_name: local/pyright
          languages: [python]
          auto_detect: true

Error Modes

Error Class When
Non-GRAPH type ActorCompilationError config.type != GRAPH
Missing route ActorCompilationError config.route is None
Missing node MissingNodeError Edge references unknown node
Invalid entry/exit InvalidEntryExitError Entry/exit node not in graph
Intra-graph cycle SubgraphCycleError Nodes form a cycle
Cross-actor cycle SubgraphCycleError Subgraph refs form a cycle

API Reference

compile_actor(config, *, actor_resolver=None) -> CompiledActor

Compile an ActorConfigSchema into a LangGraph-ready bundle.

Parameters:

  • config — The actor configuration (must be ActorType.GRAPH).
  • actor_resolver — Optional callable (name: str) -> ActorConfigSchema | None for resolving subgraph references.

Returns: CompiledActor with nodes, edges, and metadata.

CompiledActor

Field Type Description
name str Actor name
nodes dict[str, NodeConfig] LangGraph node configs
edges list[Edge] LangGraph edges
entry_point str Entry node ID
metadata CompilationMetadata Diagnostic metadata

CompilationMetadata

Field Type Description
node_ids list[str] All node IDs (sorted)
tool_nodes list[str] Tool-type node IDs
lsp_bindings list[LspBinding] Per-node LSP bindings
subgraph_refs dict[str, str] Subgraph node → actor name
entry_node str Entry point node ID
exit_nodes list[str] Exit point node IDs