Skip to content

Runnable With Message History

Runnable With Message History passes a message to a connected agent or chain and returns its answer as text, like Runnable Executor, but adding the conversation’s previous messages. That way the agent remembers what was said and can answer questions such as “and the other model?”.

By default, messages are kept in NappAI’s internal memory, separated by flow, session and conversation. If you prefer another memory, connect it to External Memory.

When to use it

  • A chat assistant that has to remember what the user said earlier.
  • Giving an agent or a chain, besides the message, other named input data.

Configuration

FieldWhat it does
InputThe message passed to the agent or chain.
Agent Executor (required)The agent or chain that runs.
External MemoryAn external memory where messages are read from and saved. Empty, NappAI’s internal memory is used.
StreamReturns the answer in parts, as it is generated. On by default.
Memory top messageHow many previous messages are retrieved from the internal memory. Default: 5.
Number of extra input parametersHow many extra input values are passed, from 1 to 15. For each one an input parameter N field appears, where you give a name and its value, which can come from another component.

Advanced options

FieldWhat it does
Output KeyThe name of the result taken from the answer. Default: output.
Input KeyThe name of the input the agent or chain expects. Default: input.
Executor NameThe name the run shows in the log. Default: executor_with_history.

Output

The Text output is the agent’s or chain’s answer.

Example

An online shop wants an assistant that keeps track of the conversation.

  1. Connect the customer’s message to Input and the shop’s agent to Agent Executor.
  2. Leave External Memory empty and set Memory top message to 10.
  3. Connect Text to the chat output.

Best practices

  • Retrieving more messages gives the agent more context, but makes each request longer.
  • Use an external memory when the conversation has to be shared with other systems.