Skip to content

latent.agents.canned_response

Trivial-input canned-response short-circuit.

A CannedResponder is a deterministic, LLM-free reply rule. Its single reply field is a callable that inspects the conversation and returns the reply text, or None to decline (the agent tries the next responder, then the LLM). patterns() builds such a callable for the common regex case.

The event contract is owned by latent.agents.events.emit_text_turn.

Classes

CannedResponder

CannedResponder(name: str, reply: Reply)

Deterministic, LLM-free reply rule. reply(messages) returns the reply text, or None to decline. First-match-wins, in declaration order.

Functions

lifecycle_hooks

lifecycle_hooks(responders: Sequence[CannedResponder]) -> list[object]

Adapt configured canned responders into lifecycle-compatible hooks.

patterns

patterns(regexes: str = (), reply: str, max_len: int = 40) -> Reply

Build a Reply that fullmatches the normalized last user message.

Case-insensitive, surrounding whitespace stripped, inputs longer than max_len rejected (backstop against an over-broad pattern). Validates reply is non-empty at build time.

Attributes

Reply