PlatformContext Class

Definition

Carries the platform-injected identity context for a single request. The Foundry platform sets x-agent-user-id and (on container protocol version 2.0.0) x-agent-foundry-call-id headers on every protocol request (e.g., /responses, /invocations). These opaque values let handlers partition per-user state and let the SDK forward the per-request caller context to Foundry platform services.

public class PlatformContext
type PlatformContext = class
Public Class PlatformContext
Inheritance
PlatformContext

Remarks

User ID key β€” the global, cross-agent partition key for per-user data (e.g., user profile, preferences, OAuth tokens, memory). The same user yields the same value regardless of which agent they interact with. Used container-side for per-user state partitioning; it is not forwarded on outbound 1P calls (not accepted/trusted by 1P services).

Call ID β€” the opaque per-request call identifier (present only on container protocol version 2.0.0). The container must forward it on outbound calls to Foundry platform services so that 1P services resolve the server-side-stored caller context. Never parsed.

Both values are opaque and platform-generated. Neither is guaranteed to be present when running locally (outside the platform); containers should handle null values gracefully (e.g., fall back to a default partition).

Constructors

Name Description
PlatformContext()

Initializes a new instance of PlatformContext for mocking.

PlatformContext(String, String)

Initializes a new instance of PlatformContext.

Properties

Name Description
CallId

Gets the opaque per-request call identifier from x-agent-foundry-call-id (container protocol version 2.0.0).

Empty

An empty PlatformContext with both values null. Used when the platform headers are absent (e.g., local development).

UserIdKey

Gets the user ID key β€” the global, cross-agent partition under which per-user state should be stored.

Methods

Name Description
FromRequest(HttpRequest)

Reads the x-agent-user-id and x-agent-foundry-call-id headers from the HTTP request. Returns Empty when neither header is present.

Applies to