Skip to content
These docs cover Strata 0.9.0-preview.3.It is a preview, and the API can still change before 1.0.

Build a support ticket agent

In this tutorial you build a support ticket agent, one piece at a time. It classifies a ticket with a tool, drafts a reply that streams out token by token, records the conversation, and then waits for a person to approve the reply before it sends it. The wait survives a restart: you approve the ticket from a second run of the program.

You don’t need an API key. A small function stands in for the model, so every run gives the same output. The program follows the example agent in the framework repository (examples/dotnet-agent and examples/rust-agent), adapted to the published packages and to a SQLite file.

The agent is a graph of three nodes, with a pause between the second and the third:

  1. Classify calls the classify_ticket tool and stores the category.
  2. DraftReply streams a reply, stores it, and writes the customer’s message and the reply to a history store.
  3. The run pauses for a person to approve the reply. The program exits.
  4. SendReply runs when someone approves, in a new run of the program.

The first run (dotnet run or cargo run) prints the nodes as they start and the reply as it streams, then stops at the pause:

-> Classify
-> DraftReply
Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.
Paused after DraftReply, before SendReply.

The second run (dotnet run -- approve or cargo run -- approve) shows the reviewer the draft, approves it, and reads the conversation back:

Review T-1001 (billing): Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.
Completed: category billing, status sent (approved by dana@example.com)
[User] My invoice total looks wrong this month
[Assistant] Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.

Both languages print exactly this.

  • Do the Quickstart first. This tutorial assumes you know what a node, an edge and a run are.
  • Have the .NET 10 SDK or a Rust toolchain, as listed in Requirements.
  • You need no database server. The SQLite stores are built into the packages.
Terminal window
dotnet new console -n TicketAgent
cd TicketAgent
dotnet add package Datalium.Strata.Hosting --version 0.9.0-preview.2

Datalium.Strata.Hosting brings the engine, the [StrataTool] source generator and the SQLite stores. Replace Program.cs with these lines. Each step adds code to this file.

using System.Text.Json;
using Datalium.Strata.Graph;
using Datalium.Strata.Interruption;
using Datalium.Strata.Memory;
using Datalium.Strata.Storage.Memory;
using Datalium.Strata.Streaming;
using Datalium.Strata.Tools;
using Microsoft.EntityFrameworkCore;
const string TicketId = "T-1001";
const string DbPath = "tickets.db";

The state is the data that moves through the graph. Every node gets the current ticket and returns a new one. It holds what the next nodes need: the ticket’s subject, its category, the draft reply and a status. State explains the rules.

Add the record at the end of Program.cs. Types go after the top-level code, so keep it last as the file grows.

public sealed record Ticket(
string TicketId,
string Subject,
string? Category = null,
string? Draft = null,
string Status = "open");

A tool is a function that your code, or a model, calls by name with JSON arguments. Strata generates its schema and its dispatch code when you compile. This one sorts a subject line into a category by keywords. In a real agent it might call your ticketing system.

Create TicketTools.cs. The class must be partial: the source generator adds the part that dispatches calls to your method.

using Datalium.Strata.Tools;
public partial class TicketTools
{
[StrataTool(Name = "classify_ticket", Description = "Classifies a support ticket subject line into a category.")]
public static string ClassifyTicket(string subject)
{
var lowered = subject.ToLowerInvariant();
return lowered.Contains("invoice") || lowered.Contains("bill") ? "billing"
: lowered.Contains("crash") || lowered.Contains("error") ? "technical"
: "general";
}
}

Define tools covers the argument types, the schema a model sees, and tool errors.

Put the tool in a ToolRegistry, and build a graph whose first node calls it. Each call through a registry is traced and reported as run events.

Add this after the constants:

var tools = new ToolRegistry().Register(new TicketTools());
var graph = new StateGraph<Ticket>()
.AddNode("Classify", async (state, ctx, ct) =>
{
var arguments = JsonSerializer.Serialize(new { subject = state.Subject });
var json = await tools.DispatchToolAsync("classify_ticket", arguments, ToolCallContext.From(ctx), ct);
var category = JsonDocument.Parse(json).RootElement.GetProperty("result").GetString();
return state with { Category = category };
})
.Compile();

The tool’s result comes back as JSON, {"result": "billing"}, so the node reads the result property.

Classify is an async node. Besides the state, it gets a NodeContext: the thread ID, the run’s stream and history store, and more. ToolCallContext.From(ctx) / ToolCallContext::from(&ctx) passes that context on to the tool call, so the call is linked to this run and node.

A run needs a checkpoint store, where Strata saves a thread when it stops before the end. This agent also needs a history store for the conversation. Both SQLite stores can share one file, tickets.db.

Add this after the graph. Describe goes just before the Ticket record.

if (args is not ["approve"])
{
File.Delete(DbPath); // a new ticket starts from an empty file
}
using var checkpoints = new EfCoreCheckpointStore(new CheckpointDbContext(
new DbContextOptionsBuilder<CheckpointDbContext>().UseSqlite($"Data Source={DbPath}").Options));
using var history = new EfCoreHistoryStore(new HistoryDbContext(
new DbContextOptionsBuilder<HistoryDbContext>().UseSqlite($"Data Source={DbPath}").Options));
var options = new RunOptions { History = history };
var ticket = new Ticket(TicketId, "My invoice total looks wrong this month");
var (reader, completion) = graph.RunStreaming(TicketId, ticket, checkpoints, options);
await foreach (var chunk in reader.ReadAllAsync())
{
if (chunk.Type == StreamChunkType.NodeStart)
{
Console.WriteLine($"-> {chunk.NodeName}");
}
else if (chunk.Type == StreamChunkType.Token)
{
Console.Write(chunk.Payload);
}
}
Console.WriteLine();
Console.WriteLine(Describe(await completion));
static string Describe(GraphExecutionResult<Ticket> result) => result switch
{
GraphExecutionResult<Ticket>.Completed done => $"Completed: category {done.State.Category}, status {done.State.Status}",
GraphExecutionResult<Ticket>.Interrupted paused => $"Paused after {paused.SuspendedNode}, before {paused.NextNode}.",
GraphExecutionResult<Ticket>.Failed failed => $"Failed: {failed.Message}",
_ => result.ToString(),
};

RunOptions.History gives the history store to every async node’s context.

RunStreaming / run_streaming_with starts the run in the background and hands you a reader of stream chunks and the run’s result. The engine sends a NodeStart chunk before each node. The thread ID, T-1001, names this ticket’s thread. Step 8 uses it to find the ticket again.

The file is deleted when the program runs without arguments, so every run starts a fresh ticket. Step 8 adds an approve argument that keeps the file.

Run it now with dotnet run or cargo run:

-> Classify
Completed: category billing, status open

The tool classified the ticket as billing.

The next node writes the reply. A real agent would ask a model, and send each token to the reader as it arrives. Here, DraftTokens / draft_tokens splits a fixed reply into words, and a short sleep stands in for the model’s latency.

Add the node after Classify, and an edge to it, before .Compile():

.AddNode("DraftReply", async (state, ctx, ct) =>
{
var draft = "";
foreach (var token in DraftTokens(state.Category!))
{
await Task.Delay(50, ct); // stands in for a model's latency
if (ctx.Stream is { } stream)
{
await stream.EmitTokenAsync(token, ct);
}
draft += token;
}
var now = DateTimeOffset.UtcNow;
await ctx.History!.AppendAsync(ctx.ThreadId, new ChatMessage(MessageRole.User, state.Subject.AsMemory(), now), ct);
await ctx.History!.AppendAsync(ctx.ThreadId, new ChatMessage(MessageRole.Assistant, draft.AsMemory(), now), ct);
return state with { Draft = draft };
})
.AddEdge("Classify", "DraftReply")

Add the token generator before Describe:

static IEnumerable<string> DraftTokens(string category)
{
var reply = $"Thanks for writing in. Your ticket is with our {category} team, and they will reply within one business day.";
var words = reply.Split(' ');
for (var i = 0; i < words.Length; i++)
{
yield return i == 0 ? words[i] : " " + words[i];
}
}

The node does three things:

  • It streams. Under a streaming run, the node’s context carries the run’s stream, and EmitTokenAsync / emit_token sends a Token chunk to your reader. Under a plain RunAsync / run there is no stream, so the node checks for one first.
  • It records the conversation. It appends the customer’s message and the draft to the history store, keyed by the thread ID. The conversation lives there, not in the state, so checkpoints stay small. See State, history and long-term memory.
  • It stores the draft in the state, where the reviewer reads it in step 8.

Run it now. The reply appears a word at a time:

-> Classify
-> DraftReply
Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.
Completed: category billing, status open

Nothing should reach the customer before a person reads the draft. An interrupt boundary on DraftReply stops the run after that node: Strata saves the thread, with its state and the node to run next, to the checkpoint store, and the run returns Interrupted.

Add these after the Classify to DraftReply edge, before .Compile():

.AddInterruptBoundary("DraftReply")
.AddNode("SendReply", (state, ctx, _) =>
ValueTask.FromResult(state with { Status = $"sent (approved by {ctx.Decision!.Reviewer})" }))
.AddEdge("DraftReply", "SendReply")

SendReply would send the reply. Here it only sets the status. It reads who approved from the recorded decision, ctx.Decision / ctx.decision(), which a resume sets for every node after the boundary.

Run it now:

-> Classify
-> DraftReply
Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.
Paused after DraftReply, before SendReply.

The program exits, and nothing of the ticket stays in memory. It is in tickets.db. If you installed the strata CLI, you can see it waiting:

Terminal window
strata thread list --storage tickets.db --status interrupted
+-----------+--------------+-------------+-------------+-------------+----------------------+
| Thread ID | Current Node | Sequence ID | State | Waiting For | Updated At |
+-----------+--------------+-------------+-------------+-------------+----------------------+
| T-1001 | DraftReply | 0 | interrupted | - | 2026-10-30T15:29:53Z |
+-----------+--------------+-------------+-------------+-------------+----------------------+

The reviewer’s answer comes in a new process. It builds the same graph from your code, opens the same file, shows the reviewer the draft, and resumes the thread with a HumanSignal.

Add this right after the options line:

if (args is ["approve"])
{
var checkpoint = await checkpoints.LoadAsync(TicketId);
var pending = checkpoint!.FrozenState.Deserialize<Ticket>()!;
Console.WriteLine($"Review {pending.TicketId} ({pending.Category}): {pending.Draft}");
var resumed = await graph.ResumeAsync(TicketId, HumanSignal.Approve("dana@example.com"), checkpoints, options);
Console.WriteLine(Describe(resumed));
return;
}

The checkpoint’s frozen state is the ticket as DraftReply left it, saved as JSON. The resume loads the thread, records the decision, and continues at SendReply. It gets the same run options, so nodes after the boundary have the history store too. The reviewer is an identity, such as an email address. Strata saves it in later checkpoints, so never put a credential there.

Run it now. Start a ticket with dotnet run or cargo run, then approve it in a second run with dotnet run -- approve or cargo run -- approve:

Review T-1001 (billing): Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.
Completed: category billing, status sent (approved by dana@example.com)

A waiting thread can be answered once. Approve it again and the resume is refused, with nothing run:

Failed: checkpoint for thread 'T-1001' was already resumed

Last, show the conversation that DraftReply recorded. It is in the same file, so the new process reads it too.

Add this in the approve block, before return;:

await foreach (var message in history.GetHistoryAsync(TicketId))
{
Console.WriteLine($"[{message.Role}] {message.Content}");
}

GetHistoryAsync streams the most recent messages, 50 by default, oldest first.

Run it now, both commands again. The second one prints the output shown at the top of this page:

Review T-1001 (billing): Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.
Completed: category billing, status sent (approved by dana@example.com)
[User] My invoice total looks wrong this month
[Assistant] Thanks for writing in. Your ticket is with our billing team, and they will reply within one business day.

Program.cs:

using System.Text.Json;
using Datalium.Strata.Graph;
using Datalium.Strata.Interruption;
using Datalium.Strata.Memory;
using Datalium.Strata.Storage.Memory;
using Datalium.Strata.Streaming;
using Datalium.Strata.Tools;
using Microsoft.EntityFrameworkCore;
const string TicketId = "T-1001";
const string DbPath = "tickets.db";
var tools = new ToolRegistry().Register(new TicketTools());
var graph = new StateGraph<Ticket>()
.AddNode("Classify", async (state, ctx, ct) =>
{
var arguments = JsonSerializer.Serialize(new { subject = state.Subject });
var json = await tools.DispatchToolAsync("classify_ticket", arguments, ToolCallContext.From(ctx), ct);
var category = JsonDocument.Parse(json).RootElement.GetProperty("result").GetString();
return state with { Category = category };
})
.AddNode("DraftReply", async (state, ctx, ct) =>
{
var draft = "";
foreach (var token in DraftTokens(state.Category!))
{
await Task.Delay(50, ct); // stands in for a model's latency
if (ctx.Stream is { } stream)
{
await stream.EmitTokenAsync(token, ct);
}
draft += token;
}
var now = DateTimeOffset.UtcNow;
await ctx.History!.AppendAsync(ctx.ThreadId, new ChatMessage(MessageRole.User, state.Subject.AsMemory(), now), ct);
await ctx.History!.AppendAsync(ctx.ThreadId, new ChatMessage(MessageRole.Assistant, draft.AsMemory(), now), ct);
return state with { Draft = draft };
})
.AddInterruptBoundary("DraftReply")
.AddNode("SendReply", (state, ctx, _) =>
ValueTask.FromResult(state with { Status = $"sent (approved by {ctx.Decision!.Reviewer})" }))
.AddEdge("Classify", "DraftReply")
.AddEdge("DraftReply", "SendReply")
.Compile();
if (args is not ["approve"])
{
File.Delete(DbPath); // a new ticket starts from an empty file
}
using var checkpoints = new EfCoreCheckpointStore(new CheckpointDbContext(
new DbContextOptionsBuilder<CheckpointDbContext>().UseSqlite($"Data Source={DbPath}").Options));
using var history = new EfCoreHistoryStore(new HistoryDbContext(
new DbContextOptionsBuilder<HistoryDbContext>().UseSqlite($"Data Source={DbPath}").Options));
var options = new RunOptions { History = history };
if (args is ["approve"])
{
var checkpoint = await checkpoints.LoadAsync(TicketId);
var pending = checkpoint!.FrozenState.Deserialize<Ticket>()!;
Console.WriteLine($"Review {pending.TicketId} ({pending.Category}): {pending.Draft}");
var resumed = await graph.ResumeAsync(TicketId, HumanSignal.Approve("dana@example.com"), checkpoints, options);
Console.WriteLine(Describe(resumed));
await foreach (var message in history.GetHistoryAsync(TicketId))
{
Console.WriteLine($"[{message.Role}] {message.Content}");
}
return;
}
var ticket = new Ticket(TicketId, "My invoice total looks wrong this month");
var (reader, completion) = graph.RunStreaming(TicketId, ticket, checkpoints, options);
await foreach (var chunk in reader.ReadAllAsync())
{
if (chunk.Type == StreamChunkType.NodeStart)
{
Console.WriteLine($"-> {chunk.NodeName}");
}
else if (chunk.Type == StreamChunkType.Token)
{
Console.Write(chunk.Payload);
}
}
Console.WriteLine();
Console.WriteLine(Describe(await completion));
static IEnumerable<string> DraftTokens(string category)
{
var reply = $"Thanks for writing in. Your ticket is with our {category} team, and they will reply within one business day.";
var words = reply.Split(' ');
for (var i = 0; i < words.Length; i++)
{
yield return i == 0 ? words[i] : " " + words[i];
}
}
static string Describe(GraphExecutionResult<Ticket> result) => result switch
{
GraphExecutionResult<Ticket>.Completed done => $"Completed: category {done.State.Category}, status {done.State.Status}",
GraphExecutionResult<Ticket>.Interrupted paused => $"Paused after {paused.SuspendedNode}, before {paused.NextNode}.",
GraphExecutionResult<Ticket>.Failed failed => $"Failed: {failed.Message}",
_ => result.ToString(),
};
public sealed record Ticket(
string TicketId,
string Subject,
string? Category = null,
string? Draft = null,
string Status = "open");

TicketTools.cs:

using Datalium.Strata.Tools;
public partial class TicketTools
{
[StrataTool(Name = "classify_ticket", Description = "Classifies a support ticket subject line into a category.")]
public static string ClassifyTicket(string subject)
{
var lowered = subject.ToLowerInvariant();
return lowered.Contains("invoice") || lowered.Contains("bill") ? "billing"
: lowered.Contains("crash") || lowered.Contains("error") ? "technical"
: "general";
}
}
You built What it is Go further
The Ticket state The typed data that moves through a graph and is saved in checkpoints. State
The classify_ticket tool A function with a generated schema, called by name through a ToolRegistry. Define tools, Tool middleware
Classify and DraftReply Async nodes, which get a NodeContext with the thread ID, the stream and the history store. Graphs, nodes and edges
The streamed draft Token chunks that a node sends to the reader of a streaming run. Observe runs
The conversation Messages in a history store, kept out of the state. State, history and long-term memory
The pause and the approval An interrupt boundary, a HumanSignal, and the decision the resume records. Human-in-the-loop, Pause for approval
The restart A thread saved in a SQLite file and resumed by another process. Threads and checkpoints, Choose a store, Use SQLite

From here, you can:

  • Handle a rejection. Give the boundary a reject route, let the reviewer correct the draft with an override, or set a time limit on the approval. Pause for approval shows all three.
  • Use a real model. Replace the token generator with a model call, and let the model choose the tools. Follow Build an LLM agent, or see Call a model and Build an agent.
  • Run it as a service. The framework’s example runs this agent in the .NET Generic Host. Hosting shows how to register the stores and the graph and configure them from settings.

Before you build something real, read the Known limitations.