Defining agents
Register your first agent and give it a clear identity and responsibility.
This guide creates the model-based support-agent used throughout the Agents documentation. You need a .NET 10 ASP.NET Core application and a configured model provider for this example. For local CLI execution, see Codex CLI or Claude CLI.
Install the package
Run this in the project that defines and executes agents:
The Agents package references Core and includes the agent runtime. For a new solution, you can also follow Get Started.
Register the agent
Add the definition before building the host:
The runtime can now resolve support-agent. Registration alone does not send a request to the model. Configure your key using Model and provider, then follow Running agents to add an endpoint.
Select an executor
The constructor above selects model execution. Alternatively, use the three-argument constructor and select the executor explicitly:
Use UseCodex(options => options.Model = "gpt-6-astra") for Codex CLI, or UseClaude(options => options.Model = "sonnet") for Claude CLI. Both require an explicit model; see the Claude guide for API availability and migration from the old parameterless method. Start those definitions with the three-argument constructor as well. A definition can select exactly one executor; selecting again throws InvalidOperationException. Finish selection before the AddRuniqServer callback returns.
CLI executor registration is automatic when you add those agents through AddRuniqServer. CLI installation and authentication are required when executing a request, not when creating or registering the definition.
Choose identity and instructions
| Field | What to choose |
|---|---|
id | A unique, stable identifier such as support-agent. Calls and links may depend on it. |
name | A readable label such as Support Agent. |
instructions | The agent's responsibility, boundaries, and answer style. |
model | For model execution, a supported provider name followed by the model identifier. CLI settings are described in their respective guides. |
apiKey | For model execution, read from configuration when the provider requires a key. CLI agents use the host account's CLI authentication. |
Keep the id stable after callers depend on it. See Instructions for guidance you can test.
Add capabilities deliberately
Tools let the agent request application operations. Define a typed tool, then attach it with AddTool<TTool>(). All three executors support attached Runiq tools; the CLI executors expose them through an automatic MCP bridge. Tools execute with host permissions. Follow Defining tools for the contract and registration.
RAG supplies relevant document passages for model execution. Active Runiq RAG bindings are unsupported by the CLI executors. After configuring and ingesting a named index, connect it to an existing model-agent definition:
This does not create or ingest the index. The default policy allows normal answers when no context is accepted. Choose the grounding and no-context policy explicitly for source-dependent answers in Defining indexes.
Keep the first definition small
Start with one responsibility and verify a response before attaching more capabilities. Move definitions into separate files when they grow; Patterns shows how.