Menu

Post image 1
Post image 2
1 / 2
0

State Management and Chat History

DEV Community·Lukas Walter·about 1 month ago
#2yGeUH8l
#dotnet#csharp#ai#session#context#agent
Reading 0:00
15s threshold

This is Part 4 of my series on the Microsoft Agent Framework. You can read the original post over on lukaswalter.dev . Introduction: Why AIs are stateless Large Language Models (LLMs) are stateless. Ask, “How many levels are in Super Mario 64?” and you’ll get an answer. Ask, “How many stars are there?” right after, and the AI often won’t recognize you mean the game. It may return an unrelated number. Each LLM request is isolated. For AI to understand context, you must send the entire conversation history each time. With every additional chat question, the number of input tokens rises. You pay for the entire historical text sent back and forth. The Basic Approach: Agent Sessions In-Memory Storage: To solve this, the Agent Framework provides the concept of Agent Sessions. Instead of just calling agent.runAsync("Question") , you create a session and include it with each call. The framework then automatically appends the new messages to a list in the background and sends them with the next call.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More