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 block | Responsibility |
|---|---|
| Identity | A stable id for runtime lookup and a readable name for Studio. |
| Instructions | The agent's role, boundaries, and expected response style. |
| Executor | A model provider selected by the constructor or UseModel(...), or a local CLI selected by UseCodex(...) or UseClaude(...). |
| Tools | Typed C# operations attached with AddTool<TTool>(). |
| RAG, when needed | Retrieval 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 path | Configuration |
|---|---|
| Model and provider | Select a provider/model reference and configure the provider connection. |
| Codex CLI | Set an explicit CLI model with UseCodex(...); use local CLI authentication. |
| Claude CLI | Set 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#
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
- Your application passes a message and agent id to the runtime.
- 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.
- 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.
- 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.
Call the runtime from C# and handle results or streaming events.
Check the selected model, tool calls, and retrieved sources.