channel_agent
diapason.agents.channel_agent
¶
ChannelAgent — bridge between messaging channels and AI agents.
Routes incoming :class:~diapason.channels._stubs.ChannelMessage objects
to an agent, classifies queries as "quick" or "deep", and delivers responses
either inline or as a preview with an escalation link to a full report.
ChannelAgent
¶
Bridge between a :class:BaseChannel and an agent.
On each incoming message the agent is invoked in a background thread so
that :meth:_handle_message never blocks the channel's event loop.
Quick queries with short responses are delivered inline; deep queries or
long responses trigger a preview + escalation link.
Parameters¶
channel:
A connected :class:BaseChannel instance.
agent:
Any object that exposes a run(input: str) -> AgentResult-compatible
method (typically a :class:~diapason.agents._stubs.BaseAgent
subclass).
max_workers:
Size of the background :class:~concurrent.futures.ThreadPoolExecutor.
shutdown()
¶
Shut down the background thread pool.
classify_query(text)
¶
Return 'quick' or 'deep' based on heuristics.
Deep signals take priority over quick signals. A query is classified as deep if it contains deep keywords, a time-range phrase, or is longer than 20 words. Otherwise it is quick.