#user history support

1 messages · Page 1 of 1 (latest)

safe tulip
#

based on the conversation between @wind siren and @carmine badge would love to hear how you've built stateful agents (e.g: agents that remember previous conversations with a user).

one of the things i'm thinking about is allowing you to pass a user id to the agent's conversation, and maintain a history string (idk like 500chars?) for each user id you pass to an agent. you could also specify a summarise prompt. after each call we would take in the current_history_string + your_summarise_prompt + latest_call_transcript -> new_history_string.

before each call for a user id we would append their history string to the system prompts before a call to imrpove their experience.

#

would love to hear your thoughts about how we can make this easy for you!

wind siren
#

Thanks @safe tulip !

Here's a visualization I made of the WebSocket agent connection flow. The diagram shows two main scenarios:

  • Starting a new conversation (generating a new conversation_id)
  • Continuing an existing conversation (using an existing conversation_id)

Regarding the user_id topic - I think it's actually better to handle this at the backend level where we can associate one user_id with multiple conversation_ids. This keeps our WebSocket layer clean and focused on conversation management.

Some thoughts on why this approach is beneficial:

  • We can map user_id → multiple conversation_ids in the database
  • Easier to implement different storage strategies per conversation
  • Better user session management options
  • Can implement proper user context and history tracking
#

I've also been thinking about an interesting approach for agent initialization - instead of relying on traditional system prompts to define behavior, what if we fed the agent a synthetic conversation history? The idea is to create a pre-made JSON transcript that demonstrates exactly how we want the agent to behave, including tool usage patterns, response styles, and interaction flows.

For example, rather than telling the agent "use tool X when you see Y," we could include a conversation snippet where it successfully used that tool in the exact scenario we want. The history would use the same format as real conversations (roles, timestamps, tool results, etc.), making it feel more natural for the agent. Similar to the Few Shot prompting

This approach would also solve the previous discussion about conversation continuity - instead of reusing an existing conversation_id (which can be tricky to manage), we could simply initialize a new conversation with the real history from another conversation as input. We'd get a fresh conversation_id while maintaining all the context and interaction patterns we want to preserve. This gives us the best of both worlds: clean conversation management with the richness of previous interactions.

What makes this particularly interesting is that it shifts from prescriptive instructions ("do this") to demonstrated behavior ("this is how it's done"). It could potentially lead to more consistent tool usage since the agent sees concrete examples rather than abstract rules. Got this problem on my project

I've made a comparison diagram of both approaches, and while the prompt method gives us direct control over instructions, the synthetic history might offer better "muscle memory" for the agent. Still needs testing to validate the benefits, but I'm curious

#

(sorry for the spam 🙂 )