AgentExecutionContextExtensions
NexusLabs.Needlr.AgentFramework¶
NexusLabs.Needlr.AgentFramework.Context¶
AgentExecutionContextExtensions Class¶
Extension methods for IAgentExecutionContextAccessor and IAgentExecutionContext.
Inheritance System.Object 🡒 AgentExecutionContextExtensions
Methods¶
AgentExecutionContextExtensions.GetProperty<T>(this IAgentExecutionContext) Method¶
Gets a typed property from the context's property bag, keyed by the type's full name. Returns null if not found or if the stored value is not assignable to T.
public static T? GetProperty<T>(this NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext context)
where T : class;
Type parameters¶
T
Parameters¶
context IAgentExecutionContext
Returns¶
Remarks¶
The default key (typeof(T).FullName) works well when each property type
is unique within a context — the common case for domain records like
ArticleAssignment, SeoReport, etc.
Properties is read-only by design. Consumers that need to store typed state should populate the property bag at context construction time via their own IAgentExecutionContext implementation.
AgentExecutionContextExtensions.GetProperty<T>(this IAgentExecutionContext, string) Method¶
Gets a typed property from the context's property bag with an explicit key. Returns null if not found or if the stored value is not assignable to T.
public static T? GetProperty<T>(this NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext context, string key)
where T : class;
Type parameters¶
T
Parameters¶
context IAgentExecutionContext
key System.String
Returns¶
AgentExecutionContextExtensions.GetRequired(this IAgentExecutionContextAccessor) Method¶
Returns the current IAgentExecutionContext or throws if none is established. Tools should call this rather than checking Current directly — there is no valid "anonymous" execution.
public static NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext GetRequired(this NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContextAccessor accessor);
Parameters¶
accessor IAgentExecutionContextAccessor
Returns¶
Exceptions¶
System.InvalidOperationException
Thrown when no execution context scope is active. This indicates a programming error:
the orchestration layer must call BeginScope(IAgentExecutionContext)
before invoking tools.