Multi-Agent Solution State Design for Long-Running Workflows and Audit Compliance

AI-500 By islever Editorial Last updated

Design and implement agent memory, context management, and knowledge integration Design logical architecture for multi-agent solutions

Short answer

Yes, the proposed design satisfies the constraints. The five-day recovery is handled by querying the Cosmos DB SessionMetadata container using userId and workflowType to retrieve the threadId, and the seven-year audit is met by storing serialized messages in the Cosmos DB Messages container with TTL disabled.

Question

HOTSPOT
You have a Microsoft Foundry multi-agent solution that runs as three stateless worker instances behind a load balancer. Each workflow can span five days and is identified by using two application-defined values named userId and workflowType.
During execution, each workflow has a Foundry Agent Service thread. Regulatory policy requires a seven-year queryable audit record of all agent messages.
You are evaluating the following state design for the solution:
For the active session container, use a Foundry Agent Service thread. The threadId value will be kept in worker memory during execution.
For the shared team state, use Azure Managed Red is keyed by workflowId with a two-hour sliding expiration. Missing Redis entries will be rebuilt from Azure Cosmos DB.
For the durable store, use Azure Cosmos DB for NoSQL A container named SessionMetadata will be partitioned by userId and will store workflowType, status, threadId, and expiresAt. A container named Messages will be partitioned by threadId, will store serialized messages, and will have TTL disabled.
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
NOTE: Each correct selection is worth one point.
Exhibit: Multi-Agent Solution State Design for Long-Running Workflows and

Key Takeaways

The key trap is assuming that keeping threadId in stateless worker memory breaks recovery, ignoring that SessionMetadata in Cosmos DB allows retrieving threadId via userId and workflowType.

This guide explains why a multi-agent state design using Cosmos DB for durable storage and Redis for caching satisfies five-day recovery and seven-year audit constraints.

Common mistake: Marking the design as flawed because stateless workers keep threadId in memory, failing to realize the Cosmos DB SessionMetadata container provides a durable recovery path.

Expert Analysis

The in-memory threadId trap

A superficial reading of the design might lead to rejecting it because the active session's threadId is kept in worker memory while the solution runs on stateless workers behind a load balancer. This sounds like a fatal flaw: if a worker restarts or the load balancer routes a subsequent request to a different worker, the in-memory threadId is lost, breaking the five-day workflow. However, this conclusion stops being correct when you examine the durable store. The SessionMetadata container in Azure Cosmos DB is partitioned by userId and stores both workflowType and threadId. Because the workflow is explicitly identified by these two application-defined values, any worker can query Cosmos DB using userId as the partition key and workflowType as a filter to retrieve the correct threadId and resume the Foundry Agent Service thread. Thus, the in-memory value is merely a performance cache, not a single point of failure.

Satisfying the seven-year audit

As noted in learner discussions, the Messages container in Cosmos DB for NoSQL stores serialized messages with TTL disabled, so nothing expires. This directly satisfies the regulatory requirement for a seven-year queryable audit record. By partitioning the container by threadId and disabling Time-to-Live, the design ensures that agent messages persist indefinitely. Azure Cosmos DB provides robust querying capabilities, meeting the "queryable" aspect of the mandate.

Caching strategy

The use of Azure Managed Redis with a two-hour sliding expiration for shared team state is appropriate for a five-day workflow. Missing entries can be transparently rebuilt from Cosmos DB, preventing data loss while optimizing read performance.

Exam Strategy

When evaluating state designs for stateless workers, always trace the recovery path for in-memory variables. If a variable like threadId is lost, check if it can be reconstructed or queried from a durable store like Cosmos DB using available application-defined keys. Do not assume in-memory caches in stateless environments are fatal flaws if a durable fallback exists.

Discussion 1 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 1

  1. ExamProAzure 👍 1
    Statement 1: The proposed design satisfies the five-day recovery and seven-year audit constraints. → Yes Seven-year audit: The Messages container in Cosmos DB for NoSQL stores serialized messages with TTL disabled, so nothing expires. Cosmos DB is queryable, which meets the “queryable audit record” requirement. Five-day recovery: SessionMetadata durably stores workflowType, status, threadId, and expiresAt, and the Messages container holds the messages. A workflow spanning five days can therefore be recovered from Cosmos DB even if workers or Redis lose their state. Statement 2: The proposed design supports resuming a workflow by userId and workflowType after a worker restart. → Yes The threadId is kept only in worker memory, which is lost on restart. But SessionMetadata is partitioned by userId and stores workflowType and threadId. A restarted worker (or any of the three stateless workers) can query by userId, filter on workflowType, read the stored threadId, and resume the workflow. Statement 3: The proposed design can hold the active shared team state without serving as the audit record store. → Yes Redis holds the shared team state keyed by workflowId with a two-hour sliding expiration, so it is a cache for active state and is not the audit store. Evicted entries are rebuilt from Cosmos DB, and the audit record lives in the Messages container.

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

← Back to AI-500 Study Guide