Signpost AI Logo
WorkersTools

Chathistory

📸 Screenshots

Here are visual examples of this section:

Chathistory - Worker Configuration Interface Chathistory - Worker Configuration Interface

1. Overview and Purpose

The Chathistory worker manages conversation history by storing and retrieving chat messages from a database. It supports different history modes including full history retention and automatic summarization when conversations become too long. The worker can maintain conversation context while optimizing storage and token usage through intelligent summarization.

2. Configuration Parameters

  • history: Sets the history mode - can be "full" for complete history or "sumarized" for automatic summarization
  • keepLatest: Number of recent messages to keep unsummarized (default: 100)
  • sumarizeWhen: Threshold number of messages that triggers summarization (default: 200)
  • sumarizePrompt: Custom prompt used for summarizing chat history (default: system prompt)
  • sumarizationModel: AI model used for summarization (default: "openai/gpt-4-turbo")

3. Input/Output Handles

  • output: Output handle - returns array of chat history items including messages, roles, and content

4. Usage Examples with Code

// The worker automatically retrieves history based on user ID and agent ID
// History items are returned with the following structure:
{
  role: "user" | "assistant" | "system",
  type: "message",
  content: [{ text: "message content", type: "text" }],
  __FROM_DB__: true // indicates item was loaded from database
}

5. Integration Examples

This worker integrates at the beginning of chat workflows to provide conversation context to other workers. It works seamlessly with chat completion workers and can be combined with search and retrieval workers for enhanced context management.

6. Best Practices

  • Set appropriate keepLatest values based on your token limits and context requirements
  • Use summarization mode for long-running conversations to manage costs
  • Customize the summarization prompt to preserve domain-specific information
  • Monitor token usage when using full history mode with lengthy conversations

7. Troubleshooting Tips

  • Ensure user ID is provided in agent parameters to avoid "No uuid provided" errors
  • Check database connectivity if history retrieval fails
  • Verify API keys are configured properly when using summarization features
  • Review summarization model availability if summarization fails