Patterns
Organize Runiq agents cleanly in a .NET application.
Keep agents close to the behavior they define.
For a real application, create an Agents folder and put each agent definition in its own file. Program.cs should register agents; it should not become the place where long instructions, tool wiring, and behavior rules accumulate.
An agent is application code. Treat it like a registered runtime component with identity, model settings, instructions, tools, optional Context Spaces, and dashboard metadata.
Recommended project layout
For the travel workflow sample:
Travel is only the sample domain. The pattern is the important part: agents live in Agents/, tools live in Tools/, workflows live in Workflows/, and startup code only wires them together.
Keep Program.cs small
The startup file now answers one question: which Runiq runtime components are registered?
It does not hide long prompts or tool rules inline. To understand Weather Agent, open Agents/WeatherAgent.cs. To understand Planner Agent, open Agents/PlannerAgent.cs.
Put each agent in its own file
Use a small agent class or static factory per agent.
The private constructor makes callers use Create(...), so the tool attachment is not accidentally skipped. The factory returns a complete agent definition: identity, instructions, model, provider key, and allowed tools.
Group by responsibility
Prefer focused agents over one large general agent.
In the travel workflow sample, Weather Agent handles weather and comfort, Places Agent handles place suggestions and route considerations, and Planner Agent creates the final itinerary. This keeps each instruction set small and each dashboard run easier to inspect.
The same pattern works outside travel:
Each agent should have a clear job, a stable id, and only the tools or Context Spaces it needs.
Use registration helpers for larger apps
As the app grows, you can move grouped registration into an application-owned extension method.
Then Program.cs becomes:
This is not required by Runiq. It is a useful project organization pattern when the number of agents grows.
Keep tools and context outside agent files
Agent files should describe behavior and allowed capabilities. Tool files should implement deterministic .NET operations. Context Space files should define source-backed knowledge boundaries.
Do not put database queries, HTTP calls, policy calculations, or document content directly into agent instructions. Put application behavior in tools and domain knowledge in Context Spaces, then attach only what the agent should use.
Common mistakes
Putting every agent inline in Program.cs is fine for a quick spike, but it becomes hard to review quickly. Move real agents to Agents/*.cs.
Giving one agent every responsibility makes debugging harder. Split agents when the responsibilities are naturally different.
Attaching every tool to every agent weakens the capability boundary. Attach only the tools that agent is allowed to use.
Treating the tool result as the final answer is also a common mistake. Tool results go back to the model so the agent can continue and produce the final response.