Поделиться через


Managing Turns

The Microsoft 365 Agents SDK is based on turns. A turn is the roundtrip starting with the incoming activity and then sending any outgoing activity that you choose to send back.

A turn can contain many Activities where multiple messages are sent back to a person or other agent. A turn doesn't mean the conversation or interaction is done, only that specific turn. Typically within a conversation multiple 'turns' take place. A turn therefore represents the workflow from the incoming to an outgoing action of the agent.

Multiple internal actions can take place within a turn, such as using internal services, AI services, APIs and more to generate plans, responses and get information to use & format.

Within the Agents SDK, developers can access information available for the agent to use, per turn based on the turn context:

    await turnContext.SendActivityAsync(MessageFactory.Text({response}"), cancellationToken);

The turn context object is how activities are sent back to the channel using the SendActivityAync method

State & Memory

Agents created with the Agents SDK are stateless by default and can be added.

State is supported as an optional parameter when the agent is built, and includes Private State, User State, and Conversation State. State requires storage to store state (and other information you require). The SDK supports Memory storage, Blob, Cosmos, or custom storage.

Because by default, agents are stateless, any information is lost on the next turn, unless you save state. Developers must specifically configure state (or memory) and choose where to store or persist that state, and retrive it on the next turn. A sample will be linked soon on how to do this.

A note on using state across multiple agents

When you work with multiple agents, you might want to manage multiple states of agents. How you manage the state and memory of those agents depends on a few factors, including:

  • The types of state and storage supported by the agents
  • What information needs to be stored persistently
  • What data you want or need to store across turns
  • What data needs to be accessed across agents to perform the required actions