# Short-Term Thread Memory

> Persist a typed state object per session thread — current screen, active plan, recent tool calls — with a TTL so it survives across turns but expires when the session is done.

- **Category**: Agentic AI
- **Subcategory**: Memory
- **Canonical URL**: https://designpattern.fyi/patterns/short_term_memory/

---

## Description
**Intent**: Carry the relevant slice of conversation context across turns within a session.
**Context**: A multi-turn agent needs continuity across recent turns — what screen the user is on, what the active plan looks like, what tools have been called and what they returned. But it doesn't need this information forever; the current session uses it, the next conversation almost certainly won't.
**Solution**: Define a typed state object per thread (messages, current screen, active plan, agent step). Persist with a TTL (commonly 24h). Reload on the next turn; expire and reset on TTL.



## Use Cases
- A multi-turn agent needs continuity across turns within a session.
- Replaying the full conversation history each turn is expensive or pollutes context.
- A typed state object with TTL can capture the relevant slice.






## Trade-offs


### Advantages

- Session continuity without the cost of full-history replay.

- Bounded memory footprint per active user — the TTL cleans up automatically.




### Considerations & Drawbacks

- TTL boundaries surprise users when state vanishes mid-task — communicate TTL behavior clearly.

- Schema migrations are painful for live state — in-flight sessions may hold old schema versions.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/short-term-thread-memory/)

