{"id":51244591,"url":"https://github.com/agentruntimecontrolprotocol/csharp-sdk","last_synced_at":"2026-06-29T03:03:02.389Z","repository":{"id":356975891,"uuid":"1234794428","full_name":"agentruntimecontrolprotocol/csharp-sdk","owner":"agentruntimecontrolprotocol","description":"C# / .NET reference SDK for ARCP (Agent Runtime Control Protocol).","archived":false,"fork":false,"pushed_at":"2026-06-22T01:27:09.000Z","size":878,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-22T03:14:54.939Z","etag":null,"topics":["agent-protocol","agent-runtime-control-protocol","agents","ai-agents","arcp","csharp","dotnet","durable-execution","llm","mcp","sdk","streaming"],"latest_commit_sha":null,"homepage":"https://github.com/agentruntimecontrolprotocol/spec","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agentruntimecontrolprotocol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-10T16:45:12.000Z","updated_at":"2026-06-16T21:28:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/agentruntimecontrolprotocol/csharp-sdk","commit_stats":null,"previous_names":["agentruntimecontrolprotocol/csharp-sdk"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/agentruntimecontrolprotocol/csharp-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentruntimecontrolprotocol%2Fcsharp-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentruntimecontrolprotocol%2Fcsharp-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentruntimecontrolprotocol%2Fcsharp-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentruntimecontrolprotocol%2Fcsharp-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agentruntimecontrolprotocol","download_url":"https://codeload.github.com/agentruntimecontrolprotocol/csharp-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agentruntimecontrolprotocol%2Fcsharp-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34911135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-protocol","agent-runtime-control-protocol","agents","ai-agents","arcp","csharp","dotnet","durable-execution","llm","mcp","sdk","streaming"],"created_at":"2026-06-29T03:03:01.237Z","updated_at":"2026-06-29T03:03:02.371Z","avatar_url":"https://github.com/agentruntimecontrolprotocol.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch3 align=\"center\"\u003eARCP C# SDK\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\u003cstrong\u003eC# SDK for the Agent Runtime Control Protocol (ARCP) — submit, observe, and control long-running agent jobs from C#.\u003c/strong\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.nuget.org/packages/Arcp\"\u003e\u003cimg alt=\"NuGet\" src=\"https://img.shields.io/nuget/v/Arcp.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/agentruntimecontrolprotocol/csharp-sdk/actions/workflows/test.yml\"\u003e\u003cimg alt=\"CI\" src=\"https://github.com/agentruntimecontrolprotocol/csharp-sdk/actions/workflows/test.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/agentruntimecontrolprotocol/csharp-sdk\"\u003e\u003cimg alt=\"codecov\" src=\"https://codecov.io/gh/agentruntimecontrolprotocol/csharp-sdk/graph/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md\"\u003e\u003cimg alt=\"ARCP\" src=\"https://img.shields.io/badge/ARCP-v1.1%20draft-blue\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-Apache--2.0-lightgrey\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md\"\u003eSpecification\u003c/a\u003e ·\n  \u003ca href=\"#concepts\"\u003eConcepts\u003c/a\u003e ·\n  \u003ca href=\"#installation\"\u003eInstall\u003c/a\u003e ·\n  \u003ca href=\"#quick-start\"\u003eQuick start\u003c/a\u003e ·\n  \u003ca href=\"docs/\"\u003eGuides\u003c/a\u003e ·\n  \u003ca href=\"docs/\"\u003eAPI reference\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n`Arcp` is the C# / .NET reference implementation of [ARCP](https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md), the Agent Runtime Control Protocol. It covers both sides of the wire — `Arcp.Client` for submitting and observing jobs, `Arcp.Runtime` for hosting agents, with `Arcp.AspNetCore`, `Arcp.Hosting`, `Arcp.Otel`, and `Arcp.Cli` rounding out the host integrations — so either side can talk to any conformant peer in any language without hand-rolling the envelope, sequencing, or lease enforcement.\n\nARCP itself is a transport-agnostic wire protocol for long-running AI agent jobs. It owns the parts of agent infrastructure that don't change between products — sessions, durable event streams, capability leases, budgets, resume — and stays out of the parts that do. ARCP wraps the agent function; it does not define how agents are built, how tools are exposed (that's MCP), or how telemetry is exported (that's OpenTelemetry).\n\n## Installation\n\nRequires .NET 10 or later. The SDK ships as a set of NuGet packages: install the meta-package `Arcp` for everything (client, runtime, and core types), or pick à la carte if you only need one side of the wire:\n\n```sh\ndotnet add package Arcp\n# or, à la carte:\ndotnet add package Arcp.Client    # client side\ndotnet add package Arcp.Runtime   # runtime side\ndotnet add package Arcp.Core      # wire types only\n```\n\nOptional host integrations live in separate packages: `Arcp.AspNetCore` (Kestrel WebSocket endpoint via `IEndpointRouteBuilder.MapArcp`), `Arcp.Hosting` (`IServiceCollection.AddArcpRuntime` for non-ASP.NET workers), `Arcp.Otel` (W3C trace propagation), and `Arcp.Cli` (the `arcp` executable).\n\n## Quick start\n\nConnect to a runtime, submit a job, stream its events to completion:\n\n```csharp\nusing Arcp.Client;\nusing Arcp.Core.Messages;\nusing Arcp.Core.Transport;\n\nvar ws = new System.Net.WebSockets.ClientWebSocket();\nawait ws.ConnectAsync(new Uri(\"wss://runtime.example.com/arcp\"), CancellationToken.None);\nvar transport = new WebSocketTransport(ws);\n\nawait using var client = await ArcpClient.ConnectAsync(transport, new ArcpClientOptions\n{\n    Client = new ClientInfo { Name = \"quickstart\", Version = \"1.0.0\" },\n    Token = Environment.GetEnvironmentVariable(\"ARCP_TOKEN\"),\n});\n\nvar handle = await client.SubmitAsync(\n    agent: \"data-analyzer\",\n    input: new { dataset = \"s3://example/sales.csv\" });\n\n_ = Task.Run(async () =\u003e\n{\n    await foreach (var ev in handle.Events())\n        Console.WriteLine($\"[{ev.EventSeq}] {ev.Kind}\");\n});\n\nvar result = await handle.Result;\nConsole.WriteLine($\"final: {result.FinalStatus}\");\n```\n\nThis is the whole shape of the SDK: open a session, submit work, consume an ordered event stream, get a terminal result or error. Everything below is detail on those four moves.\n\n## Concepts\n\nARCP organizes everything around four concerns — **identity**, **durability**, **authority**, and **observability** — expressed through five core objects:\n\n- **Session** — a connection between a client and a runtime. A session carries identity (a bearer token), negotiates a feature set in a `hello`/`welcome` handshake, and is *resumable*: if the transport drops, you reconnect with a resume token and the runtime replays buffered events. Jobs outlive the session that started them. See [§6](https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md).\n- **Job** — one unit of agent work submitted into a session. A job has an identity, an optional idempotency key, a resolved agent version, and a lifecycle that ends in exactly one terminal state: `success`, `error`, `cancelled`, or `timed_out`. See [§7](https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md).\n- **Event** — the ordered, session-scoped stream a job emits: logs, thoughts, tool calls and results, status, metrics, artifact references, progress, and streamed result chunks. Events carry strictly monotonic sequence numbers so the stream survives reconnects gap-free. See [§8](https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md).\n- **Lease** — the authority a job runs under, expressed as capability grants (`fs.read`, `fs.write`, `net.fetch`, `tool.call`, `agent.delegate`, `cost.budget`, `model.use`). The runtime enforces the lease at every operation boundary; a job can never act outside it. Leases may carry a budget and an expiry, and may be subset and handed to sub-agents via delegation. See [§9](https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md).\n- **Subscription** — read-only attachment to a job started elsewhere (e.g. a dashboard watching a job a CLI submitted). A subscriber observes the live event stream but cannot cancel or mutate the job. Distinct from *resume*, which continues the original session and carries cancel authority. See [§7.6](https://github.com/agentruntimecontrolprotocol/spec/blob/main/docs/draft-arcp-1.1.md).\n\nThe SDK models each of these as first-class objects; the rest of this README shows how.\n\n## Guides\n\n### Sessions and resume\n\nOpen a session, negotiate features, and reconnect transparently after a transport drop using the resume token — jobs keep running server-side while you're gone.\n\n```csharp\nusing Arcp.Client;\nusing Arcp.Core.Messages;\nusing Arcp.Core.Transport;\n\nawait using var client = await ArcpClient.ConnectAsync(transport, new ArcpClientOptions\n{\n    Client = new ClientInfo { Name = \"resumable\", Version = \"1.0.0\" },\n    Token = Environment.GetEnvironmentVariable(\"ARCP_TOKEN\"),\n});\n\nvar sessionId = client.SessionId;\nvar resumeToken = client.ResumeToken;\nvar effective = client.EffectiveFeatures; // intersection of hello.features and welcome.features\n\n// ... transport drops; track the last seq your reader observed ...\nvar lastSeq = client.LastReceivedSeq;\n\n// Capture `sessionId`, `resumeToken`, and `lastSeq` to hand to a fresh connection\n// when reconnect logic re-establishes the transport (spec §6.3).\n```\n\n### Submitting jobs\n\nSubmit a job with an agent (optionally version-pinned as `name@version`), an input, and an optional lease request, idempotency key, and runtime limit.\n\n```csharp\nusing Arcp.Core.Leases;\n\nvar lease = new Lease(new Dictionary\u003cstring, IReadOnlyList\u003cstring\u003e\u003e\n{\n    [LeaseNamespaces.NetFetch] = new[] { \"https://reports.example.com/**\" },\n});\n\nvar handle = await client.SubmitAsync(\n    agent: \"weekly-report@2.1.0\",\n    input: new { week = \"2026-W19\" },\n    leaseRequest: lease,\n    leaseConstraints: new LeaseConstraints { ExpiresAt = DateTimeOffset.UtcNow.AddMinutes(1) },\n    idempotencyKey: \"weekly-report-2026-W19\",\n    maxRuntimeSec: 300);\n\nConsole.WriteLine($\"job_id = {handle.JobId}\");\nConsole.WriteLine($\"effective lease = {handle.Lease}\");\nConsole.WriteLine($\"resolved agent = {handle.Agent}\");\n```\n\n### Consuming events\n\nIterate the ordered event stream — `log`, `thought`, `tool_call`, `tool_result`, `status`, `metric`, `artifact_ref`, `progress`, `result_chunk` — and optionally acknowledge progress so the runtime can release buffered events early.\n\n```csharp\nusing Arcp.Core.Messages;\n\nawait foreach (var ev in handle.Events())\n{\n    switch (ev.Kind)\n    {\n        case EventKinds.Log:\n            Console.WriteLine($\"log: {ev.Body}\");\n            break;\n        case EventKinds.ToolCall:\n            Console.WriteLine($\"→ tool: {ev.Body}\");\n            break;\n        case EventKinds.Metric:\n            Console.WriteLine($\"metric: {ev.Body}\");\n            break;\n        case EventKinds.Progress:\n            Console.WriteLine($\"progress: {ev.Body}\");\n            break;\n    }\n\n    // Coalesce acks so the runtime can release buffered events (spec §6.5).\n    if (ev.EventSeq % 32 == 0)\n        await client.AckAsync(ev.EventSeq);\n}\n```\n\n### Leases and budgets\n\nRequest capabilities, a budget, and an expiry; read budget-remaining metrics as they arrive; handle the runtime's enforcement decisions.\n\n```csharp\nusing Arcp.Core.Errors;\nusing Arcp.Core.Leases;\nusing Arcp.Core.Messages;\n\nvar lease = new Lease(new Dictionary\u003cstring, IReadOnlyList\u003cstring\u003e\u003e\n{\n    [LeaseNamespaces.ToolCall]   = new[] { \"search.*\", \"fetch.*\" },\n    [LeaseNamespaces.CostBudget] = new[] { \"USD:1.00\" },\n});\n\nvar handle = await client.SubmitAsync(\n    agent: \"web-research\",\n    input: new { iterations = 8, perCallUSD = 0.3 },\n    leaseRequest: lease,\n    leaseConstraints: new LeaseConstraints { ExpiresAt = DateTimeOffset.UtcNow.AddMinutes(10) });\n\nConsole.WriteLine($\"initial budget: {string.Join(\",\", handle.Budget!)}\");\n\n_ = Task.Run(async () =\u003e\n{\n    await foreach (var ev in handle.Events())\n    {\n        if (ev.Kind != EventKinds.Metric) continue;\n        var metric = ev.BodyAs\u003cMetricBody\u003e();\n        if (metric?.Name == \"cost.budget.remaining\")\n            Console.WriteLine($\"budget remaining: {metric.Value} {metric.Unit}\");\n    }\n});\n\nvar outcome = await handle.Result;\nif (!outcome.Success)\n{\n    // BUDGET_EXHAUSTED and LEASE_EXPIRED are never retryable.\n    outcome.EnsureSuccess();\n}\n```\n\n### Subscribing to jobs\n\nAttach read-only to a job submitted elsewhere and observe its live stream (with optional history replay) without cancel authority.\n\n```csharp\nusing Arcp.Core.Ids;\nusing Arcp.Core.Messages;\n\nvar listing = await client.ListJobsAsync(\n    filter: new JobListFilter { Status = new[] { \"running\" } });\n\nvar jobId = JobId.Parse(listing.Jobs[0].JobId, null);\nvar sub = await client.SubscribeAsync(jobId, history: true);\nvar ack = sub.Acknowledged.Result;\nConsole.WriteLine($\"subscribed from seq={ack.SubscribedFrom} replayed={ack.Replayed}\");\n\nawait foreach (var ev in sub.Events())\n    Console.WriteLine($\"[seq={ev.EventSeq}] {ev.Kind}\");\n\nawait sub.UnsubscribeAsync();\n```\n\n### Error handling\n\nCatch the typed error taxonomy and respect the `retryable` flag — `LEASE_EXPIRED` and `BUDGET_EXHAUSTED` are never retryable; a naive retry fails identically.\n\n```csharp\nusing Arcp.Core.Errors;\n\ntry\n{\n    var handle = await client.SubmitAsync(\"flaky\", input: new { });\n    var outcome = await handle.Result;\n    outcome.EnsureSuccess();\n}\ncatch (ArcpException ex)\n{\n    if (ex.Code is ErrorCode.LeaseExpired or ErrorCode.BudgetExhausted)\n    {\n        throw; // resubmit with a fresh lease / budget instead\n    }\n    if (ex.Retryable)\n    {\n        // safe to retry with backoff (e.g. INTERNAL_ERROR, TIMEOUT, HEARTBEAT_LOST, AGENT_NOT_AVAILABLE)\n    }\n    throw;\n}\n```\n\n## Feature support\n\nARCP features this SDK negotiates during the `hello`/`welcome` handshake:\n\n| Feature flag | Status |\n|---|---|\n| `heartbeat` | Supported |\n| `ack` | Supported |\n| `list_jobs` | Supported |\n| `subscribe` | Supported |\n| `lease_expires_at` | Supported |\n| `cost.budget` | Supported |\n| `model.use` | Supported |\n| `provisioned_credentials` | Supported |\n| `progress` | Supported |\n| `result_chunk` | Supported |\n| `agent_versions` | Supported |\n\n## Transport\n\nARCP is transport-agnostic. This SDK ships a `WebSocketTransport` (default), a `StdioTransport` for in-process child runtimes, and a `MemoryTransport` for tests and same-process workers. WebSocket is the default for networked runtimes; stdio is used for in-process child runtimes. Select one by constructing the corresponding transport (`new WebSocketTransport(socket)`, `new StdioTransport(input, output)`, `MemoryTransport.Pair()`) and passing it to `ArcpClient.ConnectAsync(transport, options)`; host integrations under `Arcp.AspNetCore` attach the WebSocket upgrade to a Kestrel endpoint via `IEndpointRouteBuilder.MapArcp(server)`.\n\n## API reference\n\nFull API reference — every type, method, and event payload — is in [`docs/`](docs/).\n\n## Versioning and compatibility\n\nThis SDK speaks **ARCP v1.1 (draft)**. The SDK follows semantic versioning independently of the protocol; the protocol version it negotiates is shown above and in `session.hello`. A runtime advertising a different ARCP MAJOR is not guaranteed compatible. Feature mismatches degrade gracefully: the effective feature set is the intersection of what the client and runtime advertise, and the SDK will not use a feature outside it.\n\n## Contributing\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md). Protocol questions and proposed changes belong in the [spec repository](https://github.com/agentruntimecontrolprotocol/spec); SDK bugs and feature requests belong here.\n\n## License\n\nApache-2.0 — see [`LICENSE`](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagentruntimecontrolprotocol%2Fcsharp-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagentruntimecontrolprotocol%2Fcsharp-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagentruntimecontrolprotocol%2Fcsharp-sdk/lists"}