Nodes

Nodes contain your agent logic. They process events, maintain conversation context, and generate responses from LLMs.

What is a Node?

Nodes are where the “thinking” happens in your agent system. It contain the business logic and LLM interactions.

Basic Example

1from line.nodes import ReasoningNode
2from line.events import AgentResponse
3
4class ChatNode(ReasoningNode):
5 def __init__(self, system_prompt, llm_client):
6 super().__init__(system_prompt=system_prompt)
7 self.llm_client = llm_client
8
9 async def process_context(self, context):
10 # Get conversation history and system prompt
11 messages = self.format_for_llm(context.events)
12
13 # Generate response from LLM
14 response = await self.llm_client.generate(messages)
15
16 # Yield response to be spoken to user
17 yield AgentResponse(content=response)

Node Types

TypeDescription
NodeBase class for all nodes
ReasoningNodeTemplate for conversational agents with automatic context management

ReasoningNode is the base class for all nodes that use LLMs. Users should implement the process_context() method to process messages and yield events asynchronously.

Key Features

  • Event Processing: Receive and process events from bridges
  • State Management: Maintain conversation history and context
  • Response Generation: Yield events back through the system
  • Lifecycle Hooks: start() method for async initialization

Nodes can work together in multi-agent systems. See Agent Patterns for coordination examples.