Skip to content

AgentPrismRunContext

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Carries the identity, tree position, and budget of the running run to the helper components inside the run path.

public static class AgentPrismRunContext

objectAgentPrismRunContext

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

It has two consumers. Skill script execution is triggered from inside MAF, below the recording wrapper; sub-agent invocation is triggered from MAF’s background task tool. Neither has a way to pass the run identity as a parameter: the call chain belongs to MAF.

The value is held in an Threading.AsyncLocal. This means the assignment does not flow back to the caller: the Set call must happen in the own body of the method that starts the run. The same trap happened with Activity.Current.

The value flows downward: because Microsoft Agent Framework’s background agent task captures ExecutionContext, a sub-agent running on a different thread also sees the same scope.

Gets the scope of the running run. null outside a run.

public static AgentRunScope? Current { get; }

AgentRunScope?

Gets the identity of the running run. null outside a run.

public static Guid? CurrentRunId { get; }

Guid?

Sets the scope of the running run.

public static void SetCurrent(AgentRunScope? scope)

scope AgentRunScope?

The scope. If null, the scope is cleared.