set_history

View as MarkdownOpen in Claude

Control what the model still sees when this step is entered. The mode applies at the moment of entry and governs everything that came before, including the turn that triggered the transition. It doesn’t affect this step’s own turns, which accumulate fresh. Nothing is deleted: the call log keeps every message.

Overrides the context-level default set with Context.set_history().

Parameters

history
strRequired

One of three modes.

  • "keep" — clear nothing. Every prior step’s instructions and dialogue stay visible to the model.
  • "default" — hide the prior step instructions, keep the user and assistant dialogue. This is the behavior when unset.
  • "hide" — hide the prior instructions and pull the prior dialogue out of the model’s context. Pair it with a ${step_history.*} reference in this step’s text to choose exactly what comes back.

Returns

Step — Self for method chaining.

Raises

ValueError if history is not one of the three modes.

Example

from signalwire import AgentBase
agent = AgentBase(name="my-agent", route="/agent")
contexts = agent.define_contexts()
ctx = contexts.add_context("default")
ctx.add_step("collect_trip").set_text("Ask where the caller is going and when.")
ctx.add_step("confirm_trip").set_history("hide").set_text(
"Previously: ${step_history.prev.summary}\n\nConfirm the booking details."
)
agent.serve()