aiagent

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

AI Agent node

Type: ai-agent
Category: AI

Runs the model ↔ tool-call loop: output 1 = final answer, output 2 = tool-call trace.

Behavior

This node is registered as ai-agent and runs as part of a workflow. Its exact runtime behavior is implemented in node.go; this document summarizes the editor-facing purpose and configuration contract.

Configuration

Field Type Default Description
concurrency integer Concurrency — Maximum in-flight agent runs; additional messages wait. Empty/0 means unlimited
maxIterations integer 8 Max Iterations — Mandatory cap on model ↔ tool rounds; exceeding it routes an error to the catch path
memory string AI Memory — Optional ID of an ai-memory config node supplying conversation history
prompt string User Prompt — Mustache template rendered against the message ({{payload.x}}, {{env.X}}, {{flow.X}}, {{global.X}})
provider string AI Provider — ID of the ai-provider config node to call through
systemPrompt string System Prompt — Optional system prompt sent verbatim
target string payload Target — Message property the final answer is written to
timeoutSeconds number Model Timeout (s) — Per-call timeout for each model round; overrides the provider default when set
toolTimeoutSeconds number 60 Tool Timeout (s) — How long each tool call may run before its result is reported back as an error
tools string Tools — Comma-separated ai-tool references: "nodeID" (same workflow) or "workflowID/nodeID"

Implementation

  • node.go contains the executor, validation, schema, and registration.
  • editor.html contains the editor integration.
  • node_test.go, when present, contains behavioral tests.

Documentation

Overview

Package aiagent contains the ai-agent node implementation: runs the model ↔ tool-call loop through github.com/dracory/llm's ToolsInterface.GenerateWithTools — the caller (this node) executes each requested tool by injecting a call message into an ai-tool node's flow and awaiting its ai-tool-return. Output 1 carries the final answer, output 2 the tool-call trace. Iterations are capped and every model/tool call runs under a timeout; conversation history optionally round-trips through an ai-memory config node.

Index

Constants

View Source
const Type = "ai-agent"

Type is the registered node type id.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentNode

type AgentNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

AgentNode is the ai-agent executor.

func NewAgentNode

func NewAgentNode(node nodestore.NodeInterface, config *Config, host nodebase.NodeHost) *AgentNode

NewAgentNode creates a new ai-agent node. host may be nil — provider/tool resolution then fails with explicit errors.

func (*AgentNode) Execute

Execute runs the agent loop and returns the message carrying the final answer (routed to output 1 by SelectPorts); the tool-call trace is emitted on output 2.

func (*AgentNode) SelectPorts

func (n *AgentNode) SelectPorts(input, output nodestore.MessageInterface) []string

SelectPorts routes the returned message to output 1 only — the trace left through an explicit output-2 emit inside Execute.

func (*AgentNode) Validate

func (n *AgentNode) Validate() error

Validate checks the structural config: a provider reference is required and max-iterations, when set, must be positive.

type Config

type Config struct {
	// Provider is the ID of the ai-provider config node to call through.
	Provider string `json:"provider"`
	// Memory is the optional ID of an ai-memory config node.
	Memory string `json:"memory"`
	// SystemPrompt is sent verbatim as the system message.
	SystemPrompt string `json:"systemPrompt"`
	// Prompt is the mustache template rendered against the message.
	Prompt string `json:"prompt"`
	// Tools is a comma-separated list of ai-tool references:
	// "nodeID" within the same workflow or "workflowID/nodeID" for a
	// tool flow living in another running workflow.
	Tools string `json:"tools"`
	// MaxIterations caps model ↔ tool rounds (default 8).
	MaxIterations int `json:"maxIterations"`
	// TimeoutSeconds is the per-model-call timeout; overrides the
	// provider default when > 0.
	TimeoutSeconds float64 `json:"timeoutSeconds"`
	// ToolTimeoutSeconds bounds each tool invocation (default 60).
	ToolTimeoutSeconds float64 `json:"toolTimeoutSeconds"`
	// Target is the message property the final answer is written to.
	Target string `json:"target"`
	// Concurrency caps in-flight agent runs; <= 0 means unlimited.
	Concurrency int `json:"concurrency"`
}

Config holds the ai-agent configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL