Universal.Operative.Sdk.Discrete
3.1.0
dotnet add package Universal.Operative.Sdk.Discrete --version 3.1.0
NuGet\Install-Package Universal.Operative.Sdk.Discrete -Version 3.1.0
<PackageReference Include="Universal.Operative.Sdk.Discrete" Version="3.1.0" />
<PackageVersion Include="Universal.Operative.Sdk.Discrete" Version="3.1.0" />
<PackageReference Include="Universal.Operative.Sdk.Discrete" />
paket add Universal.Operative.Sdk.Discrete --version 3.1.0
#r "nuget: Universal.Operative.Sdk.Discrete, 3.1.0"
#:package Universal.Operative.Sdk.Discrete@3.1.0
#addin nuget:?package=Universal.Operative.Sdk.Discrete&version=3.1.0
#tool nuget:?package=Universal.Operative.Sdk.Discrete&version=3.1.0
Universal.Operative.Sdk.Discrete
Provider-neutral conversations, model streams, tools, transforms, turn coordination, and durable conversation chronologies.
Install
dotnet add package Universal.Operative.Sdk.Discrete
Use a provider package such as Universal.Operative.Sdk.Discrete.OpenAI or Universal.Operative.Sdk.Discrete.Anthropic to supply an IModel.
Run a turn
using Universal.Operative.Sdk;
using Universal.Operative.Sdk.Discrete;
IEngine engine = EngineBuilder.FromDefaults(model)
.AddBaselineToolSet()
.Build();
var conversation = new Conversation
{
Messages =
{
new Message
{
Role = MessageRoles.User,
Content = { new TextBlock("Inspect this repository.") },
},
},
};
ConversationManager manager = await ConversationManager.CreateAsync(conversation);
await foreach (EngineEvent engineEvent in engine.ExecuteAsync(
new ExecutionContext(new TurnContext()), manager))
{
if (engineEvent is AssistantMessageEvent response)
Console.WriteLine(response.Message);
}
Engine streams model output, dispatches tools, applies transforms, and records turn and model-call audit facts through the conversation manager.
Persist and resume
The host owns the repository and its lifetime. ConversationManager owns one mutable materialization and moves one named head.
var repositoryOptions = new FileSystemConversationRepositoryOptions
{
Directory = conversationDirectory,
ChronologyId = conversationId,
};
await using FileSystemConversationRepository repository =
await FileSystemConversationRepository.OpenOrCreateAsync(repositoryOptions);
ConversationManager manager = await ConversationManager.OpenOrCreateAsync(
repository,
() => new Conversation { Id = conversationId });
IOperative operative = OperativeBuilder.Create(engine, manager)
.WithChronologyCompactor(new SizeLimitedChronologyCompactor(new()
{
MaximumBytes = 256L * 1024 * 1024,
}))
.Build();
Use FileSystemConversationRepository.CreateAsync when the chronology must be new, OpenAsync when it must exist, and OpenOrCreateAsync for either state. A filesystem repository permits one open writer.
chronology.jsonl contains ordered audit facts. Immutable content-addressed objects store conversation snapshots and messages. Unchanged messages are shared across revisions.
Branch and restore
Every revision records its ordered parents and exact conversation snapshot. A named head may be reset or forked without changing earlier revisions.
ConversationManager alternative = await manager.ForkAsync(
earlierRevisionId,
headName: "alternative");
await alternative.ResetAsync(otherRevisionId);
Conversation restored = alternative.Current;
Use ReadChronologyAsync to inspect revisions, named heads, turn outcomes, model invocations, and host-defined CustomChronologyEvent values.
Host multiple sessions
Session is the durable host-level unit around one discrete Conversation. It is
independent of authentication, tenancy, UI selection, and transport. ISessionStore
is the persistence boundary: implement it over a database or remote service, or start
with the included InMemorySessionStore and FileSystemSessionStore.
ISessionStore store = new FileSystemSessionStore(new()
{
Directory = sessionDirectory,
});
var sessions = new SessionManager(store, () => new Conversation
{
System = [new TextBlock("You are a helpful operative.")],
});
Session session = await sessions.CreateAsync();
IOperative operative = operativeFactory.Create(session.Conversation);
// Run turns, then persist the mutated conversation with optimistic concurrency.
session = await sessions.SaveAsync(session with { Conversation = operative.Conversation });
Store-issued Session.Version values are opaque optimistic-concurrency tokens. Reads
are detached, creates reject duplicate identifiers, stale saves fail with
SessionConflictException, and deletes may be conditional. A store instance defines
its own isolation boundary; the host decides whether that means one user, tenant,
application, connection, or a deliberately shared consciousness.
SessionManager supplies storage-neutral create, rename, fork, truncate, and title
inference operations. It intentionally does not track an active session or perform
authorization. Those are adapter responsibilities.
Bound storage
IChronologyCompactor defines lossy chronology compaction for repositories that implement ICompactableConversationRepository.
SizeLimitedChronologyCompactorretains the largest recent reachable revision window within a byte limit.RevisionWindowChronologyCompactorretains a configured number of recent reachable revisions.CheckpointChronologyCompactorretains only revisions referenced by named heads.FileSystemConversationRepository.ApplyRetentionAsyncdeletes old payloads while retaining the audit graph.
Compactors preserve every named head. A result reports when the requested byte target cannot be met by the required heads alone.
Main abstractions
Conversationis mutable state supplied to a model.ConversationManagermaterializes revisions and moves one named head.SessionandSessionManagermodel host-level conversation lifecycle.ISessionStorepersists sessions independently of transport and identity.IConversationRepositorystores immutable revisions and chronology events.Chronologyis the audit read model.IModelmaps a provider to provider-neutral stream events.Engineruns one turn.Operativecoordinates concurrent submissions.ITransformerderives replacement conversation or turn-context state.
License
Free for noncommercial use under the Universal.Operative Noncommercial License. Commercial use requires a separate license from Andrew Ong.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Universal.Operative.Sdk (>= 6.1.2)
- Universal.VersionControl (>= 1.0.0)
-
net8.0
- Universal.Operative.Sdk (>= 6.1.2)
- Universal.VersionControl (>= 1.0.0)
NuGet packages (16)
Showing the top 5 NuGet packages that depend on Universal.Operative.Sdk.Discrete:
| Package | Downloads |
|---|---|
|
Universal.Operative.Sdk.Scheduling
Durably schedule a prompt to fire into a Universal.Operative.Sdk IOperative at a future time, either once or on a recurring cron schedule — it fires even if this process wasn't running when the schedule came due. ScheduleCreate/List/Cancel tools (backed by a shared ScheduleService, reusable from an HTTP-facing admin surface too) durably register atomically on creation, roll back on failure. IDurableScheduleBackend implementations: WindowsTaskSchedulerBackend/SystemdTimerBackend/CrontabBackend register with the OS's own scheduler; HttpDurableScheduleBackend registers against a remote HTTP dispatcher instead, for hosts (e.g. a sandboxed PaaS container) with no local OS scheduler reachable at all. Every backend is fully configured at construction — RegisterAsync just needs the schedule. |
|
|
Universal.Operative.Sdk.Discrete.Anthropic.ClaudeAgentSdk
Claude Agent SDK model adapter for Universal.Operative.Sdk.Discrete. |
|
|
Universal.Operative.Sdk.Discrete.Anthropic
Anthropic Messages API adapter for Universal.Operative.Sdk.Discrete. |
|
|
Universal.Operative.Sdk.Discrete.OpenAI
OpenAI Chat Completions and Responses API adapters for Universal.Operative.Sdk.Discrete. |
|
|
Universal.Operative.Sdk.Discrete.DeepSeek
DeepSeek extensions for the Universal.Operative.Sdk. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Adds transport-neutral Session lifecycle and persistence contracts, optimistic concurrency, and in-memory and filesystem stores while retaining durable conversation chronologies.