Crestapps core claude orchestrator

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core claude orchestrator is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for the Claude orchestrator in CrestApps.Core 2.0, a named IOrchestrator ("anthropic") built on the official Anthropic C# SDK. Covers AddClaudeOrchestrator and AddCoreAIClaudeOrchestrator registration, binding ClaudeOptions (ApiKey, BaseUrl, DefaultModel, EnablePromptCaching) yourself because

How to use this skill

Skill file

CrestApps.Core Claude Orchestrator

CrestApps.Core.AI.Claude adds ClaudeOrchestrator, an IOrchestrator named "anthropic" (title Claude). It talks to Anthropic through the official Anthropic NuGet package, so there is no CLI or external executable to install.

Guidelines

Registration

using CrestApps.Core.AI.Claude;
using CrestApps.Core.AI.Claude.Models;

builder.Services.AddCrestAppsCore(crestApps => crestApps
    .AddAISuite(ai => ai
        .AddClaudeOrchestrator()
    )
);

builder.Services.Configure<ClaudeOptions>(builder.Configuration.GetSection("Claude"));

Raw form: builder.Services.AddCoreAIClaudeOrchestrator(); after AddCoreAIServices() and AddCoreAIOrchestration().

{
  "Claude": {
    "ApiKey": "sk-ant-...",
    "BaseUrl": "https://api.anthropic.com",
    "DefaultModel": "claude-sonnet-4-6",
    "EnablePromptCaching": true
  }
}

ClaudeOptionsValidator (an IValidateOptions<ClaudeOptions>) fails when ApiKey is empty. Keep the key in user secrets or a key vault.

Registered Services

| Service | Implementation |

|---|---|

| IOrchestrator | ClaudeOrchestrator (ClaudeOrchestrator.OrchestratorName = "anthropic") |

| ClaudeClientService | Creates SDK clients and lists models from the Anthropic Models API |

| IChatInteractionSettingsHandler | ClaudeChatInteractionSettingsHandler persists chat interaction overrides |

| IOrchestrationContextBuilderHandler | ClaudeOrchestrationContextHandler copies ClaudeSessionMetadata into OrchestrationContext.Properties |

Use It

using CrestApps.Core.AI.Claude.Models;
using CrestApps.Core.AI.Claude.Services;

profile.OrchestratorName = ClaudeOrchestrator.OrchestratorName;

profile.Put(new ClaudeSessionMetadata
{
    ClaudeModel = "claude-opus-4-5",
    EffortLevel = ClaudeEffortLevel.Medium,
});

await profileManager.UpdateAsync(profile);

Or resolve it directly: var orchestrator = resolver.Resolve(ClaudeOrchestrator.OrchestratorName);.

ClaudeEffortLevel is None, Low, Medium or High; anything other than None is sent as the reasoning_effort additional property.

How a Turn Runs

  1. The model is ClaudeSessionMetadata.ClaudeModel, else ClaudeOptions.DefaultModel.
  2. Tools come from IToolRegistry.GetAllAsync(context.CompletionContext), the same scoped registry the default orchestrator uses, and are materialized into ChatOptions.Tools through IToolMaterializer. For a Chat Interaction the listable tools are re-checked against the current user (IUserAccessor) and denied ones are left out with a warning; AI sessions run the profile's tools as configured. DisableTools sends none.
  3. The Anthropic chat client is wrapped with AIUsageMetering.Meter(..., AIUsagePurposes.Conversation) before UseFunctionInvocation, so every round trip is a usage record with client name anthropic. With DefaultAIOptions.EnableOpenTelemetry on, UseOpenTelemetry sits below the tool loop, so every round trip also gets a gen_ai span (see crestapps-core-observability).
  4. Temperature, top-p, penalties and max tokens come from the completion context (a null value is not sent); the iteration cap from DefaultAIOptions.MaximumIterationsPerRequest (default 30).
  5. A provider failure ends the stream with "An unexpected error occurred while communicating with Anthropic. Please try again." and is logged.

Prompt Caching

With ClaudeOptions.EnablePromptCaching on (the default), each request marks ephemeral cache breakpoints on the last function tool, the end of the system prompt and the last block of the latest message. Later turns, and later round trips of the tool-calling loop within five minutes, read that prefix at the cache-read rate. Three of Anthropic's four breakpoints are used, and marked messages and tools are copies, so the caller's history is never changed. A prefix shorter than the model's minimum cacheable length is sent uncached without an error. Cache reads are metered as CachedInputTokenCount and cache writes as CacheWriteInputTokenCount. Turn it off only for workloads that never repeat a prefix within five minutes, since a cache write costs more than an uncached request.

Model Discovery

ClaudeClientService.CreateClient() returns a configured AnthropicClient, and ListModelsAsync(cancellationToken) returns ClaudeModelInfo entries for the API key so editors can offer a picker; fall back to free text when discovery is unavailable. The MVC and Blazor sample hosts wire Claude into settings, AI profiles, profile templates and chat interactions.

Troubleshooting

Upgrading Within 2.0 Previews

Upgrading from 1.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.