AgentExecutionContextBuilder
NexusLabs.Needlr.AgentFramework.Testing¶
AgentExecutionContextBuilder Class¶
Mutable builder used by WithExecutionContext(Action<AgentExecutionContextBuilder>) to configure the NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext a tool sees during invocation.
Inheritance System.Object 🡒 AgentExecutionContextBuilder
Remarks¶
A fresh AgentExecutionContextBuilder instance is created per WithExecutionContext(Action<AgentExecutionContextBuilder>) call so that successive runner instances do not share mutable state.
The resulting context is established via
NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContextAccessor.BeginScope(NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext) for the
duration of a single InvokeAsync call, then disposed.
Methods¶
AgentExecutionContextBuilder.WithOrchestrationId(string) Method¶
Sets the NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext.OrchestrationId for the invocation context. Default is a fresh GUID-derived string per builder.
public NexusLabs.Needlr.AgentFramework.Testing.AgentExecutionContextBuilder WithOrchestrationId(string orchestrationId);
Parameters¶
orchestrationId System.String
Returns¶
AgentExecutionContextBuilder.WithProperty(string, object) Method¶
Adds a custom property to the execution context's NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext.Properties bag. Useful for tools that read tenant IDs, correlation tokens, or other ambient data via NexusLabs.Needlr.AgentFramework.Context.AgentExecutionContextExtensions.GetProperty<>.Needlr.AgentFramework.Context.IAgentExecutionContext,System.String).
public NexusLabs.Needlr.AgentFramework.Testing.AgentExecutionContextBuilder WithProperty(string key, object value);
Parameters¶
key System.String
value System.Object
Returns¶
AgentExecutionContextBuilder.WithUserId(string) Method¶
Sets the NexusLabs.Needlr.AgentFramework.Context.IAgentExecutionContext.UserId for the invocation context.
Default is "tool-invocation-runner".
public NexusLabs.Needlr.AgentFramework.Testing.AgentExecutionContextBuilder WithUserId(string userId);
Parameters¶
userId System.String
Returns¶
AgentExecutionContextBuilder.WithWorkspace(IWorkspace) Method¶
Attaches a caller-supplied NexusLabs.Needlr.AgentFramework.Workspace.IWorkspace to the execution context. Use this when the test needs a workspace implementation other than NexusLabs.Needlr.AgentFramework.Workspace.InMemoryWorkspace, or wants to share a workspace across invocations.
public NexusLabs.Needlr.AgentFramework.Testing.AgentExecutionContextBuilder WithWorkspace(NexusLabs.Needlr.AgentFramework.Workspace.IWorkspace workspace);
Parameters¶
workspace NexusLabs.Needlr.AgentFramework.Workspace.IWorkspace
Returns¶
AgentExecutionContextBuilder.WithWorkspace(Action<IWorkspace>) Method¶
Creates a fresh NexusLabs.Needlr.AgentFramework.Workspace.InMemoryWorkspace, runs seed against it, and attaches it to the execution context. This is the most common path: a per-invocation throw-away workspace pre-populated with fixture files.
public NexusLabs.Needlr.AgentFramework.Testing.AgentExecutionContextBuilder WithWorkspace(System.Action<NexusLabs.Needlr.AgentFramework.Workspace.IWorkspace> seed);
Parameters¶
seed System.Action<NexusLabs.Needlr.AgentFramework.Workspace.IWorkspace>
Callback that writes seed files to the workspace.
Returns¶
Remarks¶
Calling this multiple times replaces the previously-attached workspace; only the last call wins. If a workspace was already supplied via the WithWorkspace(IWorkspace) overload, it is replaced.