Context Spaces Defining Context Spaces Defining Context Spaces Register source-backed context spaces in an ASP.NET Core application.
Define Context Spaces in code and register them with AddRuniqServer.
The Runiq.ContextTravelGuide sample keeps the Context Space definition in a Context folder:
Runiq.ContextTravelGuide/
Program.cs
Agents/
TravelGuideAgent.cs
PlainAgent.cs
Context/
TravelGuideContext.cs
istanbul-guide.md
bursa-guide.md
ankara-guide.md
london_city_guide.pdf
Skills/
trip-planning/
SKILL.md
Tools/
WeatherTool.cs
TravelBudgetEstimateTool.cs
This organization keeps Program.cs clean and makes the context boundary reviewable.
using Runiq . ContextSpaces . Models . Sources ;
namespace Runiq . ContextTravelGuide . Context ;
internal static class TravelPlanningContext
{
public static ContextSpace Create ()
{
return new ContextSpace (
id : "travel-planning" ,
name : "Travel Planning Context" ,
description : "Shared read-only context for city trip planning agents." )
. AddSources ( sources => sources. FromFileSystem (
id : "travel-docs" ,
name : "Travel Documents" ,
path : "./Context" ,
description : "Sample travel planning documents and city guide notes." ))
. AddSkills ( skills => skills. FromFileSystem (
id : "travel-skills" ,
name : "Travel Skills" ,
path : "./Skills" ));
}
}
The travel sample is only one example. A support application might use:
internal static class ProductSupportContext
{
public static ContextSpace Create ()
{
return new ContextSpace (
id : "product-support" ,
name : "Product Support Context" ,
description : "Support policies, troubleshooting docs, and escalation guidance." )
. AddSources ( sources => sources. FromFileSystem (
id : "support-docs" ,
name : "Support Documents" ,
path : "./SupportDocs" ,
description : "Product help articles and support policies." ))
. AddSkills ( skills => skills. FromFileSystem (
id : "support-skills" ,
name : "Support Skills" ,
path : "./SupportSkills" ));
}
}
using Runiq . ContextTravelGuide . Context ;
using Runiq . Core ;
builder.Services. AddRuniqServer ( options =>
{
options. AddContextSpace (TravelPlanningContext. Create ());
options. AddAgent (TravelGuideAgent. Create (openAiApiKey));
options. AddAgent (PlainAgent. Create (openAiApiKey));
});
Registering the Context Space makes it visible to runtime metadata and the dashboard. An agent still needs to attach it with UseContextSpace(...) before it participates in that agent's run.
The current builder API supports:
Builder Use sources.FromFileSystem(...)Read documents from a local folder. sources.FromS3(...)Register an S3-compatible object storage source. skills.FromFileSystem(...)Discover SKILL.md files from a local folder. skills.FromS3(...)Register an S3-compatible skill source.
The current file-system source reader supports .md, .txt, .json, and .pdf files.