Connections define how messages are automatically forwarded from agents to other destinations. They enable agent pipelines, parallel processing, and message routing patterns.
Overview¶
Connections allow you to:
- Forward messages between agents for sequential processing
- Save messages to files with custom formatting
- Process messages through custom Python functions
- Create agent pipelines and workflows
- Implement complex message routing patterns
LLMling-Agent supports three connection types:
- Node Connection: Forward to another agent, team, or node
- File Connection: Save messages to files with templating
- Callable Connection: Process through Python functions
Configuration Reference¶
Node Connection Configuration¶
Forward messages to another node.
This configuration defines how messages should flow from one node to another, including: - Basic routing (which node, what type of connection) - Message queueing and processing strategies - Timing controls (priority, delay) - Execution behavior (wait for completion)
File Connection Configuration¶
Write messages to a file using a template.
The template receives the full message object for formatting. Available fields include: - timestamp: When the message was created - name: Name of the sender - content: Message content - role: Message role (user/assistant/system) - model: Model used (if any) - cost_info: Token usage and cost info - forwarded_from: Chain of message forwarding
Callable Connection Configuration¶
Forward messages to a callable.
The callable can be either sync or async and should have the signature: def process_message(message: ChatMessage[Any], **kwargs) -> Any
Any additional kwargs specified in the config will be passed to the callable.
Connection Types¶
Node Connection¶
Forward messages to other agents or teams:
agents:
analyzer:
connections:
- type: node
name: "summarizer"
connection_type: "run"
wait_for_completion: true
Connection types:
run: Execute target agent with the messagequeue: Add message to target's queueforward: Simple message forwarding
File Connection¶
Save messages to files with Jinja2 templating:
agents:
logger:
connections:
- type: file
path: "logs/{date}/{agent}.txt"
template: "[{timestamp}] {name}: {content}"
encoding: "utf-8"
Callable Connection¶
Process messages through Python functions:
agents:
processor:
connections:
- type: callable
callable: "myapp.handlers:process_message"
kw_args:
format: "json"
Message Flow Control¶
Wait for Completion¶
Control whether to wait for the connection to complete:
Priority¶
Control processing order when multiple messages are queued:
Delay¶
Add delays before processing:
Conditions¶
Apply conditions to control when messages are forwarded:
connections:
- type: node
name: "expensive_agent"
filter_condition:
type: word_match
words: ["urgent", "important"]
stop_condition:
type: cost_limit
max_cost: 1.0
See Conditions Configuration for details on available condition types.
Queue Management¶
Control message queueing behavior:
connections:
- type: node
name: "worker"
connection_type: "queue"
queue_max_size: 100
queue_trigger_size: 10 # Process when queue reaches this size
Configuration Notes¶
- Connections are evaluated in the order they are defined
- Multiple connections can be active simultaneously
- File paths support variable substitution (date, agent name, etc.)
- Callable connections can be sync or async functions
- Queue connections allow batching messages for efficiency
- Conditions provide fine-grained control over message flow
- Priority affects order of processing when multiple messages are queued