BUILD WITH AGENTS

Agents

Define focused AI behavior in C# and run it inside your application.

An agent brings together instructions, one executor, and the capabilities it may use. Choose model-provider execution, local Codex CLI execution, or local Claude Code CLI execution. Your application registers the definition; the Runiq runtime handles execution.

Use an agent when a request needs interpretation, tool selection, or a generated response. Attach only the tools and knowledge that its responsibility requires.

What makes an agent

Building blockResponsibility
IdentityA stable id for runtime lookup and a readable name for Studio.
InstructionsThe agent's role, boundaries, and expected response style.
ExecutorA model provider selected by the constructor or UseModel(...), or a local CLI selected by UseCodex(...) or UseClaude(...).
ToolsTyped C# operations attached with AddTool<TTool>().
RAG, when neededRetrieval configured with UseRag(...) against a named index; supported by model execution.

Tools and RAG are optional. Start with a small definition and add capabilities as your feature needs them.

Choose an executor

Execution pathConfiguration
Model and providerSelect a provider/model reference and configure the provider connection.
Codex CLISet an explicit CLI model with UseCodex(...); use local CLI authentication.
Claude CLISet an explicit CLI model with UseClaude(...); use local CLI authentication. See the guide for callback API availability.

All three paths support typed Runiq tools and the same runtime result/event API. Active Runiq RAG bindings are supported only by model execution. Select exactly one executor before registration; a successful selection cannot be replaced.

A definition in C#

C#
using Runiq.AI.Agents;

var agent = new Agent(
    id: "support-agent",
    name: "Support Agent",
    instructions: """
        Help users understand the application.
        Ask for missing details before giving specific guidance.
        Keep answers concise and state uncertainty clearly.
        """,
    model: "openai/gpt-5",
    apiKey: builder.Configuration["OpenAI:ApiKey"]);

This snippet belongs in your host setup after creating builder. It creates a definition; register it before running it by id. Choose a model available through your provider account.

How a request runs

  1. Your application passes a message and agent id to the runtime.
  2. The runtime resolves the definition and invokes its executor. Model execution can retrieve configured RAG passages before its initial model call; CLI execution starts the selected local process.
  3. The executor produces an answer or requests an attached tool. Runiq executes the tool and returns its output for continuation. CLI executors expose attached tools through an automatic per-run MCP bridge.
  4. Your application receives a completed result or streaming events. Studio helps inspect the run.

A tool result is intermediate data; the model can use it to compose the final response.

Build your first agent

Define and register an agent →

Create a small definition and make it available to your application.

Run an agent →

Call the runtime from C# and handle results or streaming events.

Inspect a run in Studio →

Check the selected model, tool calls, and retrieved sources.

On this page