Context SpacesAttaching to agents

Attaching to agents

Attach Context Spaces to agents that should use source-backed context.

Registering a Context Space does not automatically give every agent access to it.

An agent opts in with UseContextSpace(...).

Travel guide sample

C#
using Runiq.Agents;
using Runiq.Agents.Tools;
using Runiq.ContextTravelGuide.Tools;

namespace Runiq.ContextTravelGuide.Agents;

public static class TravelGuideAgent
{
    public static Agent Create(string? apiKey)
    {
        return new Agent(
                id: "travel-agent",
                name: "Travel Agent",
                instructions: """
                You are a practical city trip planning assistant.

                Use context search to find destination-specific places,
                background, and travel notes.

                If the source context does not contain relevant destination
                information, say so transparently.
                """,
                model: "openai/gpt-5",
                apiKey: apiKey)
                .UseContextSpace("travel-planning")
                .AddTool<WeatherTool>()
                .AddTool<TravelBudgetEstimateTool>();
    }
}

The travel-agent can use:

CapabilityWhy
travel-planning Context SpaceSource-backed city guides and trip planning skill.
WeatherToolWeather-aware planning signal.
TravelBudgetEstimateToolApproximate budget estimate when requested.

Plain Agent comparison

The same sample registers Plain Agent without a Context Space:

C#
public static class PlainAgent
{
    public static Agent Create(string? apiKey)
    {
        return new Agent(
            id: "plain-agent",
            name: "Plain Agent",
            instructions: "You are a simple assistant. Answer clearly and briefly.",
            model: "openai/gpt-5",
            apiKey: apiKey);
    }
}

This is useful for testing. The Plain Agent can answer from its model and instructions, but it does not receive source excerpts or skills from travel-planning.

General pattern

For another domain:

Text
SupportAgent.Create(openAiApiKey)
    .UseContextSpace("product-support")
    .AddTool<CreateSupportTicketTool>();

Attach Context Spaces only to agents that should use that source boundary.

AgentContext Space
Travel Agenttravel-planning
Support Agentproduct-support
Expense Analystexpense-policy
Release Notes Agentrelease-notes

This keeps context access explicit and easier to debug.

On this page