Skip to main content
The say function adds a user message to a thread and gets an agent’s response. It transforms str → str, making it easy to:
  • Store messages in a thread (“My name is Alice” → thread.messages += [user_msg, agent_msg])
  • Get contextual responses (“What’s my name?” → “Your name is Alice”)
  • Guide agent behavior (“You are a chef…” → “Let me suggest a recipe…”)
For complex conversations, consider creating a custom task. The say function is a convenient wrapper around Marvin’s task system - see Tasks for more details.

Usage

Add a message and get a response:

Parameters

  • message: The message to add to the thread
  • instructions: Optional guidance for the agent’s responses
  • agent: Optional custom agent to use
  • thread: Optional thread to store conversation history
  • context: Optional additional context

Async Support

The function is also available in an async version:

Examples

With Instructions

Guide the agent’s responses:

With Custom Agent

Use a specialized agent:

With Memory

Remember previous interactions: