Index of every page on this site: llms.txt
All skills
ag-ui-protocol avatar

/agui-dotnet-reasoning

@c31e1e8
by ag-ui-protocolag-ui-protocol/ag-ui21k stars
2,167
Run it yourself

Surface a reasoning/thinking model's intermediate thoughts separately from its final answer with the AG-UI .NET SDK — so a client can show the agent "thinking" before it responds, and handle that reasoning trace correctly across turns. USE FOR: distinguishing the model's reasoning trace from its answer on the client by matching TextReasoningContent vs TextContent in each ChatResponseUpdate's Contents; rendering thinking and answer in different ways as they stream; deciding whether to carry the reasoning text into later turns (whether to append/resend the model's reasoning back into conversation history). DO NOT USE FOR: plain text streaming with no reasoning display (use agui-dotnet-streaming-chat); tools, shared state, interrupts, multimodal, generative UI, or protobuf.

Use this Skill: https://skilld.dev/gh/ag-ui-protocol/ag-ui/agui-dotnet-reasoning

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈202 tokens for metadata: the name and description. ≈600 when used: this file.

Description uses 10.1% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈805 characters, or 10.1%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

AG-UI .NET — reasoning (thinking) events

Goal: show a reasoning model's intermediate thoughts as they stream, kept visually separate from the final answer.

A reasoning model emits two kinds of text in the stream: its thinking and its answer. In Microsoft.Extensions.AI these arrive as different content types on each ChatResponseUpdate — TextReasoningContent for the thoughts, TextContent for the answer. update.Text only concatenates the answer parts, so to display thinking you inspect update.Contents.

Separate thinking from the answer

Iterate update.Contents and branch on the content type instead of reading update.Text:

using Microsoft.Extensions.AI;

var messages = new List<ChatMessage>
{
    new(ChatRole.User, "20 heads, 56 legs — how many chickens and rabbits? Show your reasoning."),
};

await foreach (var update in client.GetStreamingResponseAsync(messages))
{
    foreach (var content in update.Contents)
    {
        switch (content)
        {
            case TextReasoningContent { Text: { Length: > 0 } thinking }:
                RenderThinking(thinking);   // e.g. a dimmed/collapsible panel
                break;
            case TextContent { Text: { Length: > 0 } answer }:
                RenderAnswer(answer);       // the user-facing reply
                break;
        }
    }
}

Both stream incrementally and can interleave: thinking deltas arrive, then answer deltas. Render each as it comes rather than buffering, so the "thinking…" state is visible before the answer lands.

Anti-patterns

  • Re-sending the reasoning text as conversation history. The thinking is scratch work for a single turn, not a message. Appending captured TextReasoningContent into the next request's messages bloats the prompt, and some providers reject prior reasoning as input. Carry forward only the assistant's answer.
  • Treating reasoning as part of the answer. The thinking is a separate channel; concatenating it into the reply shows the user the model's scratch work as if it were the response. Keep the two render paths distinct.

Verify

  1. For a prompt that asks the model to reason, the stream yields TextReasoningContent updates before the final TextContent answer.
  2. The rendered answer contains only the response, with the reasoning shown (or hidden) through its own path — not mixed into the answer text.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts4mo3 checks · Risk SAFE
  • Gen Agent Trust Hub4mo

    The skill provides safe documentation and code examples for handling reasoning and thinking traces in .NET AI applications using the Microsoft.Extensions.AI library. It focuses on UI rendering and best practices for conversation history management.

  • Socket4mo

    No alerts

  • Snyk4mo

    Risk: LOW · No issues

Signed by skilld at c31e1e8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 5 months ago

README badge

README badge for ag-ui-protocol/ag-ui/agui-dotnet-reasoning