FoundryAgentRequestContext Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Request-scoped platform identity context, backed by an
AsyncLocal<T> so it flows across
await points and child tasks within a single request without being
threaded through every call site. This is the .NET analogue of the Python
SDK's get_request_context() / FoundryAgentRequestContext.
public sealed class FoundryAgentRequestContext
type FoundryAgentRequestContext = class
Public NotInheritable Class FoundryAgentRequestContext
- Inheritance
-
FoundryAgentRequestContext
Remarks
On container protocol version 2.0.0 the platform stamps x-agent-foundry-call-id and x-agent-user-id on the inbound request. The SDK's request-context middleware captures them here before the handler runs; outbound Foundry-bound clients read Current and echo only the call id (e.g. via FoundryCallIdHandler).
x-agent-user-id is exposed purely as a convenience for the container's own per-user state isolation — it is never echoed on outbound calls (the receiver resolves user identity from the call id).
Current never returns null; outside a request (e.g. local development) it yields an empty context with all-null fields.
Constructors
| Name | Description |
|---|---|
| FoundryAgentRequestContext() | |
Properties
| Name | Description |
|---|---|
| CallId |
The opaque per-request call identifier from |
| Current |
Gets the platform identity context for the current request. Never returns
|
| Empty |
An empty context with all fields |
| SessionId |
The session ID sourced from the |
| UserId |
The global, cross-agent per-user identity from |
Methods
| Name | Description |
|---|---|
| PlatformHeaders() |
Builds the platform identity headers to echo on outbound Foundry-bound
calls. Only |