---
name: agui-dotnet-sample-step
description: >-
  Add a GettingStarted sample Step (a Server/Client pair) to the AG-UI .NET SDK that demonstrates one protocol feature the way we want users to write it. USE FOR: adding a new samples/GettingStarted/StepNN_<Name> Server+Client pair, wiring it into AGUI.slnx and the integration-test project, giving it a deterministic FakeChatClient for replay, and registering it in the Step tables in AGENTS.md / docs/architecture.md. DO NOT USE FOR: the replay/Verify integration-test mechanics (use agui-dotnet-integration-tests), the dojo scenarios under samples/AGUIClientServer (use agui-dojo), or protocol/wire changes the sample exercises (use agui-dotnet-wire-types / agui-dotnet-transport).
title: agui-dotnet-sample-step
canonical_url: https://skilld.dev/gh/ag-ui-protocol/ag-ui/agui-dotnet-sample-step
last_updated: 2026-11-15T23:16:06.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install ag-ui-protocol/ag-ui/agui-dotnet-sample-step`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/agui-dotnet-sample-step`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/ag-ui-protocol/ag-ui/agui-dotnet-sample-step) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/agui-dotnet-sample-step`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/agui-dotnet-sample-step --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/agui-dotnet-sample-step --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# AG-UI .NET — Add a GettingStarted Sample Step

The `samples/GettingStarted/Step01..StepNN` pairs are the primary consumer-facing
deliverable: each Step is a self-contained Server + Client that demonstrates **one**
feature, written to look like the code we want users to write. Adding a Step is a
recurring, multi-artifact task. This skill covers the sample anatomy and wiring; it
**routes the integration-test mechanics to `agui-dotnet-integration-tests`** and the doc
sync to `agui-dotnet-agents-sync`.

Run all commands from `sdks/dotnet/`. Confirm the next free number and the current naming
by listing `samples/GettingStarted/Step*` first — never assume the range.

## Anatomy of a Step

A Step is a folder `samples/GettingStarted/StepNN_<Name>/` with two projects:

- **`StepNN_<Name>.Server`** — an ASP.NET host (`Microsoft.NET.Sdk.Web`, `net10.0`).
  `Program.cs` calls `builder.Services.AddAGUI()`, registers an `IChatClient`, and ends
  with `app.MapAGUI("/")`. The `IChatClient` is the whole point: the SDK turns any
  `IChatClient` into an AG-UI endpoint, so the sample logic is just MEAI.
  - References `src/AGUI.Abstractions` + `samples/AGUI.Samples.Shared` (the ASP.NET glue).
    It does **not** reference an `src/` server package directly.
  - `InternalsVisibleTo` the integration-test project so its replay test can reach the
    server's `Program` and any `FakeChatClient`.
  - Provide a **deterministic `FakeChatClient`** fallback (fixed clocks, canned tool
    results) used when no real LLM is configured. Replayable determinism is what lets the
    integration test record once and replay forever.
- **`StepNN_<Name>.Client`** — a console app (`Microsoft.NET.Sdk`, `OutputType Exe`,
  `net10.0`). `Program.cs` builds the client and hands it to a shared `SampleClient`:

  ```csharp
  using HttpClient httpClient = new() { BaseAddress = new Uri(baseUrl) };
  var aguiClient = new AGUIChatClient(new(httpClient, baseUrl));
  await SampleClient.RunAsync(aguiClient, Console.Out);
  ```

  - References only `src/AGUI.Client`. (`AGUIChatClient` is constructed from
    `AGUIChatClientOptions` — see `agui-dotnet-transport` for the protobuf opt-in via
    `AGUIEventStreamHandler`.)

Mirror the closest existing Step rather than inventing structure: the feature determines
which one (tools → Step02/03, interrupts → Step09/10, state → Step05, parallel calls →
Step12). Keep the file-name/type-name/namespace consistent (`StepNN_<Name>.Server` etc.).

## Wiring (the parts agents forget)

1. **Solution.** Add both `.csproj` paths to `AGUI.slnx` under the
   `/samples/GettingStarted/` folder, in Step order.
2. **Integration-test references.** Add a `ProjectReference` to both the Server and Client
   projects in `tests/AGUI.Hosting.AspNetCore.IntegrationTests/*.csproj` (it references
   every Step pair so its replay tests can host them).
3. **Replay test.** Add `Samples/GettingStarted/StepNN_<Name>Test.cs` deriving from
   `IntegrationTestBase<StepNN_<Name>.Server.Program>`, then record its baseline. The
   recording/Verify/8-capture-point mechanics belong to
   **`agui-dotnet-integration-tests`** — use that skill; don't reinvent them here. Fixtures
   land under `Samples/GettingStarted/fixtures/StepNN_<Name>/` and baselines under
   `baselines/StepNN_<Name>/`.
4. **Doc tables.** Add the Step to the Step tables in `sdks/dotnet/AGENTS.md` and
   `sdks/dotnet/docs/architecture.md` (and the PR review guide's Step table if present) via
   **`agui-dotnet-agents-sync`**.

GettingStarted Steps are standalone console samples, **not** dojo scenarios. The dojo is a
separate host (`samples/AGUIClientServer/AGUIDojoServer`) — only touch it via `agui-dojo`
if the feature also needs a dojo demo.

## Verify

```bash
dotnet build samples/GettingStarted/StepNN_<Name>/StepNN_<Name>.Server/StepNN_<Name>.Server.csproj
dotnet build samples/GettingStarted/StepNN_<Name>/StepNN_<Name>.Client/StepNN_<Name>.Client.csproj
dotnet test tests/AGUI.Hosting.AspNetCore.IntegrationTests/ --filter StepNN_<Name>
```

Run the pair end to end (server in one shell, client in another) to confirm it reads like
the code a user would write — the bar for a sample is exemplary, not merely passing.

## ❌ Anti-patterns

1. **Non-deterministic sample behavior.** A wall-clock, RNG, or live network call in the
   `FakeChatClient` path breaks record/replay. Use fixed values.
2. **Protocol or hosting code in the sample.** A Step composes existing SDK APIs; if it
   needs a new event/encoding, that lands in `src/` first (`agui-dotnet-wire-types` /
   `agui-dotnet-transport`), and the sample only consumes it.
3. **Half-wired Step.** Forgetting `AGUI.slnx`, the integration-test `ProjectReference`, or
   the doc Step tables leaves a sample that builds locally but isn't covered, shipped in the
   solution, or documented.
4. **Diverging from the sibling Steps.** Copy the closest Step's shape (naming, csproj refs,
   `Program.cs` skeleton, `InternalsVisibleTo`) instead of a new layout.

## References

- Replay/Verify test mechanics: **`agui-dotnet-integration-tests`**.
- Step tables / structure sync: **`agui-dotnet-agents-sync`**.
- Protobuf opt-in or a new encoding the Step demos: **`agui-dotnet-transport`**.
- End-to-end workflow context: **`agui-dotnet-feature-workflow`**.
