IndexThinking 0.24.2
See the version list below for details.
dotnet add package IndexThinking --version 0.24.2
NuGet\Install-Package IndexThinking -Version 0.24.2
<PackageReference Include="IndexThinking" Version="0.24.2" />
<PackageVersion Include="IndexThinking" Version="0.24.2" />
<PackageReference Include="IndexThinking" />
paket add IndexThinking --version 0.24.2
#r "nuget: IndexThinking, 0.24.2"
#:package IndexThinking@0.24.2
#addin nuget:?package=IndexThinking&version=0.24.2
#tool nuget:?package=IndexThinking&version=0.24.2
IndexThinking
Working Memory Manager for Reasoning-capable LLMs
What It Does
IndexThinking handles the repetitive-but-hard parts of LLM integration:
- Truncation Recovery - Auto-continue when responses hit token limits (
GetResponseAsync; a truncated stream is reported asWasTruncated) - Reasoning Extraction - Unified API for provider-specific thinking formats
- Context Tracking - Session-aware conversation with sliding window
- Token Management - Token usage tracking (
IBudgetTracker) and complexity estimation (IComplexityEstimator), reported in turn metrics — informational, not limits. To cap how much a model thinks, set it on the request:ChatOptions.Reasoning(effort) andChatOptions.MaxOutputTokens; IndexThinking extracts the reasoning, it does not throttle it - Content Recovery - Repair truncated JSON/code blocks
- Thinking State Stores -
IThinkingStateStorewith an in-memory default (AddIndexThinkingInMemoryStorage) and a distributed-cache store in the core package; a persistent SQLite store is opt-in (below)
Scope
IndexThinking manages a single LLM turn, not multi-step workflows.
| IndexThinking | Agent Orchestrators |
|---|---|
| Single turn optimization | Multi-step coordination |
| Building block | Workflow controller |
| Used BY orchestrators | Uses IndexThinking |
Token counting role boundary — IndexThinking owns token counting (ITokenCounter, framework-neutral; IChatMessageTokenCounter for M.E.AI ChatMessage counting). Model metadata (context window, pricing) belongs to TokenMeter; combining the two into budget enforcement belongs to the consuming pipeline.
Packages
| Package | Use |
|---|---|
IndexThinking |
Turn handling, reasoning extraction, token counting, in-memory and distributed-cache state stores |
IndexThinking.Sqlite |
Persistent SQLite IThinkingStateStore — services.AddIndexThinkingSqliteStorage("Data Source=thinking.db"). Carries Microsoft.Data.Sqlite and the native e_sqlite3; the core package does not |
Quick Start
dotnet add package IndexThinking
// Register services
services.AddIndexThinkingAgents();
services.AddIndexThinkingContext();
// Wrap any IChatClient
var client = new ChatClientBuilder(innerClient)
.UseIndexThinking()
.Build(serviceProvider);
// Use normally
var response = await client.GetResponseAsync(messages);
// Access metadata
var thinking = response.GetThinkingContent();
var metrics = response.GetTurnMetrics();
Session-Aware Chat
// Context is automatically tracked and injected
var response = await client.ChatAsync("session-123", "Do that again");
Streaming with Thinking Orchestration
Streaming uses a Collect-and-Yield pattern: chunks are yielded to the caller immediately while buffered internally. After the stream completes, the buffered response is processed through the full orchestration pipeline (reasoning parsing, budget tracking, context tracking). A stream cut off at the output limit is not continued — the caller already has every chunk — and is reported as TurnResult.WasTruncated. The output-token boost and the context-window cap of GetResponseAsync do not apply either: a streamed request is sent with the caller's own MaxOutputTokens.
await foreach (var update in client.GetStreamingResponseAsync(messages))
{
// Real-time chunks arrive here
Console.Write(update.Text);
// The final update contains orchestration metadata
if (update.AdditionalProperties?.ContainsKey(ThinkingChatClient.TurnResultKey) == true)
{
var result = update.AdditionalProperties[ThinkingChatClient.TurnResultKey] as TurnResult;
Console.WriteLine($"\nTokens: {result?.Metrics.TotalTokens}");
}
}
Live reasoning separation (opt-in)
Open-source / local providers (DeepSeek, Qwen3, vLLM-served) emit reasoning inline in the text delta as
<think>…</think> rather than as a separate channel. Enable SeparateReasoningInStream to have IndexThinking
split it live — answer text arrives as TextContent, reasoning as TextReasoningContent — even when a tag is
split across chunk boundaries. No bespoke tag parser needed. Default is off (raw pass-through). Native reasoning
providers (OpenAI o-series, Anthropic, Gemini) already emit a separate channel, so this is a no-op for them.
Migration note: with separation enabled, reasoning spans are no longer part of
ChatResponseUpdate.Text(which concatenatesTextContentonly). Consumers readingupdate.Textmust switch to iteratingupdate.Contents(as below) or reasoning deltas will be silently dropped.
var options = new ThinkingChatClientOptions
{
SeparateReasoningInStream = true, // default false
// StreamingReasoningStartTag = "<think>", // defaults shown
// StreamingReasoningEndTag = "</think>",
};
await foreach (var update in client.GetStreamingResponseAsync(messages))
{
foreach (var content in update.Contents)
{
if (content is TextReasoningContent reasoning)
RenderThinking(reasoning.Text); // live "💭 thinking…" UI
else if (content is TextContent answer)
RenderAnswer(answer.Text);
}
}
Supported Providers
| Provider | Reasoning Format | Truncation Handling | Requires Activation |
|---|---|---|---|
| OpenAI | reasoning field |
length, content_filter |
No (automatic) |
| Anthropic | thinking blocks |
max_tokens, refusal |
No (automatic) |
| Google Gemini | thoughtSignature |
MAX_TOKENS, SAFETY |
No (automatic) |
| DeepSeek/Qwen | <think> tags |
OpenAI-compatible | Yes (EnableReasoning) |
| vLLM/GPUStack | Configurable tags | length |
Yes (EnableReasoning) |
Enabling Reasoning for DeepSeek/vLLM/Qwen
Some providers require explicit reasoning activation:
var options = new ThinkingChatClientOptions
{
EnableReasoning = true // Adds include_reasoning: true to requests
};
var client = new ChatClientBuilder(innerClient)
.UseIndexThinking(options)
.Build(serviceProvider);
Inline Reasoning Stripping (Automatic)
When reasoning is disabled on continuation requests (to avoid double-billing thinking tokens), open-source models sometimes output inline reasoning text instead of properly tagged content. IndexThinking automatically strips these fragments:
StripLeadingUntaggedReasoning— removes reasoning paragraphs that appear at the start of a continuation fragment (≥2 consecutive reasoning paragraphs required before stripping)StripUntaggedReasoning— removes trailing reasoning that appears after the actual answer content (requires ≥200 chars of content before the marker and ≥200 chars of trailing reasoning)
Both methods are called automatically by the continuation pipeline. They are also available as static methods on OpenSourceReasoningParser for manual use.
Documentation
License
MIT License - See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Bcl.Memory (>= 10.0.12)
- Microsoft.Extensions.AI (>= 10.10.0)
- Microsoft.Extensions.AI.Abstractions (>= 10.10.1)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.12)
- Microsoft.ML.Tokenizers (>= 2.0.0)
- Microsoft.ML.Tokenizers.Data.Cl100kBase (>= 2.0.0)
- Microsoft.ML.Tokenizers.Data.O200kBase (>= 2.0.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on IndexThinking:
| Package | Downloads |
|---|---|
|
IronHive.Agent
IronHive Agent - Reusable agent layer for AI-powered CLI tools |
|
|
IndexThinking.SDK
Public SDK for IndexThinking - Working Memory manager for Reasoning-capable LLMs. |
|
|
IndexThinking.Sqlite
SQLite-backed thinking state store for IndexThinking (persistent IThinkingStateStore). |
|
|
PulsaLLM.SDK
Pulsa LLM SDK for language model inference |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.34.0 | 218 | 12/1/2026 |
| 0.33.0 | 2,533 | 10/19/2026 |
| 0.32.0 | 152 | 10/18/2026 |
| 0.31.0 | 252 | 10/18/2026 |
| 0.30.0 | 325 | 10/17/2026 |
| 0.29.0 | 174 | 10/16/2026 |
| 0.28.0 | 128 | 10/16/2026 |
| 0.27.0 | 181 | 10/16/2026 |
| 0.26.0 | 581 | 10/11/2026 |
| 0.25.1 | 127 | 10/11/2026 |
| 0.25.0 | 1,303 | 10/6/2026 |
| 0.24.2 | 611 | 10/4/2026 |
| 0.24.1 | 441 | 10/4/2026 |
| 0.24.0 | 733 | 10/2/2026 |
| 0.23.1 | 946 | 10/1/2026 |
| 0.23.0 | 1,803 | 9/26/2026 |
| 0.22.1 | 449 | 9/23/2026 |
| 0.22.0 | 524 | 9/19/2026 |
| 0.21.2 | 930 | 9/10/2026 |
| 0.21.1 | 1,079 | 7/19/2026 |