Skip to content

Routing & Sessions

When a user sends a message, the orchestrator needs to decide which agent handles it. Routing rules in agent.yaml control this behaviour. Sessions track the ongoing conversation state between a user and an agent.

Selu supports two routing modes:

In inline mode, the orchestrator evaluates every incoming message against all installed agents and picks the best match. This is the default when a user has multiple agents installed.

routing:
mode: inline
triggers:
- intent: weather_query
- mention: "@weather"
priority: 10

The orchestrator scores each agent based on trigger matches and priority. The highest-scoring agent handles the message.

In dedicated mode, the agent owns an entire channel or conversation thread. All messages in that context go directly to it — no routing evaluation is needed.

routing:
mode: dedicated

This is useful for single-purpose bots or when the user explicitly starts a session with a specific agent.

Triggers help the orchestrator match messages to agents in inline mode.

TriggerDescriptionExample
mentionMatches when the message contains a specific @-mention.@weather
intentMatches when the orchestrator’s lightweight classifier detects a semantic intent.weather_query
keywordMatches when specific keywords appear in the message.forecast, temperature
regexMatches a regular expression against the message text.\bweather\b

Triggers are evaluated in order. The first match wins for that agent, and its priority score is used in ranking.

When multiple agents match, priority breaks the tie. Higher values win. The default is 0.

routing:
priority: 10 # higher = more likely to be selected

A session is a stateful conversation between a user and an agent. Sessions track:

  • Message history — The rolling window of messages sent to the LLM.
  • Memory context — Long-term facts stored across sessions (when enabled).
  • Active capability state — If a capability uses multi-step flows, the session holds intermediate state.
memory:
session_ttl: 3600 # seconds before an idle session expires
max_history: 50 # max messages retained in the context window
long_term: true # persist facts to vector-backed long-term memory

For stateless utility agents (e.g. unit converter), use a low session_ttl and disable long_term:

memory:
session_ttl: 300
max_history: 10
long_term: false

When an agent delegates to another agent using delegate_to_agent, the orchestrator can either create a new session for the target agent or continue the existing one. This is controlled by the delegate_to_agent tool’s new_session parameter.

Now that you understand routing, head to Build Your First Agent to put it all together.