Orleans 标志

Orleans

组织
managedcode
orleans

Design Microsoft Orleans systems from each primitive's purpose and failure model. USE FOR: grains, digital twins, state versus databases, transactions, messaging, streams, timers, reminders, Durable Jobs, stateless workers, grain services, startup, and hosting. DO NOT USE FOR: other actor stacks, batches, relational-only CRUD, or advice without an Orleans decision. INVOKES: inspect version and topology, choose the primitive, implement, and validate.

概览

发布者managedcode
代码仓库dotnet-skills
技能名称orleans
星标数
492
复刻数
38
附带文件
16
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 16 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 managedcode 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Orleans AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/managedcode/dotnet-skills/tree/main/catalog/Frameworks/Orleans/skills/orleans
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/managedcode/dotnet-skills.git /tmp/dotnet-skills
mkdir -p .claude/skills
cp -r /tmp/dotnet-skills/catalog/Frameworks/Orleans/skills/orleans .claude/skills/orleans
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Orleans,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Orleans。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Orleans 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Microsoft Orleans

Diagnostic Output Budget

Keep native test progress and ANSI visible; use the detected runner's supported flags (--progress on --ansi on for MTP/TUnit), not MTP switches on VSTest. Keep console logs at Warning or higher and one concise final summary. Do not replay progress redraws, successful-test output, or Information/Debug/Trace logs into model context. On failure/crash, show only the failing test/resource, root error, and relevant stack frames; deduplicate and cap each diagnostic response at 80 lines / 8 KiB. Never dump entire console/host/browser logs, HTML, TRX, or crash artifacts. Keep necessary artifacts size-bounded outside context, link them, and inspect exact bounded excerpts. Preserve the runner exit code through capture/filtering; disclose truncation. Silence alone does not establish a hang.

Start With Purpose

Do not begin with an Orleans API. First state:

  1. the business identity that owns the behavior;
  2. the invariant and what must survive activation or cluster failure;
  3. the required consistency, query shape, acknowledgement, durability, replay, fan-out, and timing.

Then select the smallest Orleans primitive whose guarantees match those requirements. Reject Orleans when the problem is primarily shared-memory computation, a finite batch, relational querying, or global coordination with few independent entities.

Inspect package versions for version-sensitive work. Orleans 10.3.1 ships Microsoft.Orleans.DurableJobs* and Microsoft.Orleans.Journaling* as 10.3.1-alpha.1; treat them as experimental until that status changes.

Orleans 10.3 makes Newtonsoft storage enforce the type allow-list, changes RPC telemetry keys, and requires custom grain-context activators to apply configurators before construction. Prefer generated/allowed types over permissive JSON and update affected tests, dashboards, and activators together. 10.3.1 services analyzer contract identities and documents placement hints.

Mental Model

  • A grain is a virtual actor with stable identity, behavior, and optional state, not a process, row, DTO, controller, or background job.
  • A grain reference is a location-transparent address. Getting a reference does not create a durable record or prove that an activation exists.
  • An activation is an ephemeral in-memory execution instance. Orleans creates, places, moves, deactivates, and recreates it. Never equate activation lifetime with entity lifetime.
  • A normal grain has at most one activation in the cluster by default and processes turns one at a time. This makes the grain a natural owner of per-identity invariants.
  • A silo hosts activations. Silos form a cluster; external clients or a co-hosted IGrainFactory call grains.
  • Calls are asynchronous messages even when they look like C# method calls. Network failure, timeout, serialization, retries, and duplicate side effects still matter.
  • A grain can model a digital twin when its identity and behavior map to a real or domain entity; that is a use case, not every grain's definition.
  • Orleans gives logical ownership and turn-based execution. It does not make external side effects transactional, turn arbitrary data into a queryable database, or provide exactly-once execution by default.

Workflow

  1. Inspect the solution, Orleans version, hosting topology, grain interfaces, providers, and tests.
  2. Identify domain identities and invariants. Prefer many independent, bounded entities over global coordinator grains.
  3. Choose state, communication, and time-based work from the tables below.
  4. Keep default non-reentrant scheduling and placement until a measured requirement justifies a change.
  5. Configure providers independently and test the failure model the design depends on.

Choose the State Owner

PrimitivePurposeChoose it whenDo not use it as
Activation fieldsFast, temporary state for one activationThe value is derived, cached, disposable, or safe to rebuild after deactivation/failureDurable truth
IPersistentState<T>Durable current state owned by one grain identityThe grain needs a bounded snapshot loaded on activation and explicitly written after commandsA general query database or cross-grain table
External database/repositoryQueryable, indexed, relational, bulk, shared, or externally owned dataThe system needs joins, search, reporting, set-based updates, independent access, or an existing system of recordA replacement for grain ownership when serialized per-entity decisions are still required
Grain plus database/read modelSeparate command ownership from query/storage concernsA grain owns invariants and a small control snapshot while a database owns large records, history, projections, or reportingTwo competing sources of truth without an explicit contract
JournaledGrain<TState,TEvent>Persist domain events and reconstruct stateAudit history, business-event replay, log consistency, or multi-cluster event-sourced replication is a requirementA default persistence choice for ordinary CRUD state
Orleans.Journaling durable statesReplay durable collection/value operations through a journalThe experimental 10.3 journaling model, durable collections, or durable completion state solves a measured needStable default persistence; it is distinct from JournaledGrain business event sourcing
ITransactionalState<T>ACID, serializable all-or-nothing changes across transactional grain stateA short operation must atomically update multiple grain-owned states and compensation is unacceptableLong-running workflows or atomicity with arbitrary external systems
Saga/process managerDurable progress with compensation across steps and external systemsWork is long-running, spans services, waits for events, or cannot share one transactionInstant atomic commit

Grain State Versus a Database

Use grain state for bounded current state and per-identity invariants. Use a database/read model for joins, search, reporting, bulk work, history, shared access, or an external system of record. When using both, define one authority per field and recovery rules.

Never query or mutate another grain's persistence record behind the grain, or expose provider storage as the public query model merely because it uses SQL/Cosmos/Redis. Before using transactions, try one bounded grain owner; use a saga for external effects or long waits. Read references/persistence-api.md for the full boundary.

Choose Communication

Prefer a direct call for completion to a known owner. Use streams for decoupled provider-backed delivery, response streams for one caller, and broadcast/observers/one-way calls only for loss-tolerant notifications. A timeout does not prove whether an external effect committed; retries require idempotency. Read references/primitive-selection.md for the communication guarantees and execution choices.

Choose Time-Based and Background Work

PrimitivePurposeChoose it whenDo not choose it when
RegisterGrainTimerPeriodic or one-shot work tied to the current activationWork is frequent, local to an active grain, and safe to stop on deactivation or silo failureThe schedule must survive reactivation/restart
ReminderDurable recurring schedule definition associated with a grain identityLow-frequency recurring work must wake the grain after deactivation or cluster restartEvery missed occurrence must be replayed, timing must be precise, or work is high-frequency
Durable JobPersistent one-time future delivery to a target grain with cancellation/retry metadataA delayed command, expiry, notification, or workflow step must execute at least once around a due timeRecurring work, exactly-once side effects, or production work that cannot accept the current alpha package status
[StatelessWorker]Auto-scaled pool of local stateless grain activationsCPU/transform/routing/pre-aggregation work is not tied to one durable entityScheduling or durability; a stateless worker is not a job system
BackgroundServiceContinuous loop owned by each host processA silo/web host must poll or consume an external source and forward work into grainsOne global loop across replicas unless duplicates are safe or externally coordinated
IHostedServiceHost startup/shutdown action or simpler background componentInitialization or bounded host-lifetime work belongs to standard .NET hostingPer-entity durable work
Orleans startup taskFail-fast hook at a specific silo startup stageLegacy/framework integration truly requires Orleans lifecycle orderingGeneral background work; prefer BackgroundService or IHostedService
Silo lifecycle participantOrdered initialization/shutdown of an Orleans componentA provider or runtime service must start at an exact lifecycle stageBusiness scheduling
Grain servicePer-silo, cluster-partitioned runtime support serviceEvery silo hosts a long-lived service and responsibility for grains must be partitioned across silosAn ordinary domain entity, a singleton, or a durable job queue
External scheduler/workflow engineScheduling/orchestration outside OrleansCross-system workflows, cron calendars, human steps, broad operational control, or mature production guarantees dominatePer-grain work already solved by a stable Orleans primitive

Timer, Reminder, or Durable Job

Timer means “while this activation lives”; reminder means “wake this grain on a durable recurring schedule”; Durable Job means “invoke this target once around a future time, at least once.” Reminders persist definitions but miss ticks while the cluster is down. Durable Job handlers must be idempotent, and current alpha.1 packages are an explicit architecture risk.

BackgroundService means one loop per host replica, not one loop per cluster. Use a well-known grain or external lease/leader for one logical collector.

Read references/scheduling-and-services.md before implementing timers, reminders, Durable Jobs, hosted/startup tasks, silo lifecycle participants, or grain services.

Choose Execution and Scaling

Use standard grains for stateful identities and stateless workers for fungible work. Apply narrow interleaving attributes only after auditing invariants across every await; grain turns do not make reentrant workflows race-free. Preserve default placement unless a measured locality or compatibility requirement justifies changing it. See references/primitive-selection.md before changing scheduling or placement.

Hosting and Provider Boundaries

Keep concerns separate: clustering discovers silos; the grain directory locates activations; grain/reminder/transaction/job storage persist different records; stream providers carry events while PubSubStore tracks subscriptions; serialization defines wire and persistence compatibility.

In-memory clustering, storage, reminders, streams, Durable Jobs, and journaling are development/test choices unless loss is explicitly acceptable. Configure production providers, credentials, TLS/networking, server GC, graceful shutdown, and health/readiness for the deployment target. In Aspire, declare backing resources in AppHost and register the keyed clients expected by Orleans providers.

Contract and API Rules

  • Keep grain interfaces coarse-grained and asynchronous: Task, Task<T>, ValueTask<T>, or supported IAsyncEnumerable<T>.
  • Cancellation is cooperative, not proof that work did not finish.
  • Use [GenerateSerializer] and stable [Id(N)] values on messages/state. Use [Alias] for durable type identity and [Immutable] only for genuinely immutable values.
  • Never reuse removed field IDs; write state explicitly and propagate storage failures.
  • Bound external calls and use idempotency plus a saga/outbox when state writes and external effects must be reconciled.

Validate the Chosen Guarantees

  • Grain boundaries follow business identity and avoid hot global coordinators.
  • State is bounded, and the grain-state-versus-database choice is explicit.
  • Every time primitive matches activation, recurrence, durability, and delivery requirements.
  • Durable Job handlers/retried commands are idempotent; reminders tolerate missed ticks.
  • Broadcast channels, observers, and one-way calls carry only loss-tolerant signals.
  • Provider-backed tests prove delivery, ordering, replay, and failover claims.
  • Reentrancy tests cover state across await; transactions use transactional storage, [Reentrant], and PerformRead/PerformUpdate.
  • Hosted services are reviewed for per-replica duplication.
  • Production uses persistent providers, multi-silo tests, and observability wherever the guarantee depends on them.

Load References

Open only the references needed for the selected primitive:

Prefer Learn for stable APIs. For Durable Jobs and Orleans.Journaling, use version-tagged package READMEs/public API because Learn does not yet cover them fully.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Orleans AI 技能有什么作用?

Design Microsoft Orleans systems from each primitive's purpose and failure model. USE FOR: grains, digital twins, state versus databases, transactions, messaging, streams, timers, reminders, Durable Jobs, stateless workers, grain services, startup, and hosting. DO NOT USE FOR: other actor stacks, batches, relational-only CRUD, or advice without an Orleans decision. INVOKES: inspect version and topology, choose the primitive, implement, and validate.

为什么在 TypingMind 中使用 Orleans?

因为您只需安装一次,就能搭配任何模型使用。Orleans 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Orleans?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/managedcode/dotnet-skills/tree/main/catalog/Frameworks/Orleans/skills/orleans。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Orleans?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Orleans 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Orleans 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Orleans AI 技能免费吗?

是的。managedcode 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇