Template Patterns
Long-Running Agent with Compaction
Describes a persistent conversational-agent pattern that compacts chat history to manage long-term context usage.
This simple pattern involves a conversational agent in a single state that has many actions that it can use to fulfill the users request.
This pattern is typically initiated once (sometimes a setup state is used) and then handles tasks for a user over a long period of time.
This means the conversational chat needs to implement chat squashing to compact the context window for long term usage.
Examples
- A home shopping list manager
- A task and time logging agent for employees of a consultancy firm
- An agent that takes instructions to add and check off tasks in a project management system
Detailed Structure
- An agent is initiated on the
_createaction - There is an optional 'setup-in-progress' state which sets up the basic details of the agent with input from the user
- An
activestate has a collection of actions that the agent can use. - Replies from the AI agent are routed to a notification platform e.g. Whatsapp
- The stubsession is set to timeout in a year ~9000 hours
- This allows the user to keep the chat open to the stub and access the agent at any time
- On each update from the AI Agent check to see if we need to squash the chat, i.e. Compact the context window
- The gpt_chat_task safeguards need to be disabled