Builds deployment-aware chat completion and streaming loops in CrestApps.Core 2.0 using IAICompletionService, AICompletionContext, slot-based deployment resolution, and orchestration pipeline execution.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill is the server-side completion and orchestration surface. Persisted conversations, hubs, chat UI and response handlers are covered by crestapps-core-chat-interactions; voice sessions by crestapps-core-realtime-voice; providers by crestapps-core-openai, crestapps-core-azure-openai, crestapps-core-ollama and crestapps-core-azure-ai-inference.
IAICompletionService (namespace CrestApps.Core.AI.Completions), not IChatCompletionService. It returns Microsoft.Extensions.AI ChatResponse and ChatResponseUpdate.IStoreCommitter before a long completion and read entries again afterwards, as the chat hubs do (see crestapps-core-chat-interactions).AIDeployment first, through a slot: ResolveSlotAsync(AIDeploymentSlotNames.Chat, ...) for answers and ResolveUtilityOrDefaultAsync(...) for background work. Do not construct provider clients in application code.AICompletionContext for the system message, sampling, tool selection, data source, and model parameters.IOrchestrator.ExecuteStreamingAsync(...) when the request needs a profile's tools, agents, RAG, MCP connections, or progressive tool scoping.toolCalling, structuredOutputs, reasoning or streaming.using CrestApps.Core.AI.OpenAI;
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddOpenAI()
)
);
Configure a connection and at least one deployment that declares textGeneration (plus toolCalling and streaming for chat). See the provider skills for the configuration shape.
using System.Runtime.CompilerServices;
using CrestApps.Core.AI.Completions;
using CrestApps.Core.AI.Deployments;
using CrestApps.Core.AI.Models;
using Microsoft.Extensions.AI;
namespace MyApp.Services;
public sealed class SupportAnswerService
{
private readonly IAICompletionService _completionService;
private readonly IAIDeploymentManager _deploymentManager;
public SupportAnswerService(
IAICompletionService completionService,
IAIDeploymentManager deploymentManager)
{
_completionService = completionService;
_deploymentManager = deploymentManager;
}
public async IAsyncEnumerable<string> StreamAsync(
string prompt,
string deploymentName = null,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var deployment = await _deploymentManager.ResolveSlotAsync(
AIDeploymentSlotNames.Chat,
deploymentName,
cancellationToken: cancellationToken)
?? throw new InvalidOperationException("No deployment can fill the chat slot.");
var context = new AICompletionContext
{
SystemMessage = "You are a concise support assistant.",
Temperature = 0.2f,
MaxTokens = 800,
};
// Applied only when the deployment declares the reasoning feature and the reasoningEffort parameter.
context.ModelParameters[AIDeploymentParameterNames.ReasoningEffort] = "Low";
await foreach (var update in _completionService.CompleteStreamingAsync(
deployment,
[new ChatMessage(ChatRole.User, prompt)],
context,
cancellationToken))
{
if (!string.IsNullOrEmpty(update.Text))
{
yield return update.Text;
}
}
}
}
Use CompleteAsync(...) for a single ChatResponse (read response.Text).
Titles, summaries, data extraction and query rewriting belong on the utility deployment:
var deployment = await deploymentManager.ResolveUtilityOrDefaultAsync(
utilityDeploymentName: profile.UtilityDeploymentName,
chatDeploymentName: profile.ChatDeploymentName)
?? throw new InvalidOperationException("No text deployment is configured.");
var context = new AICompletionContext
{
SystemMessage = "Summarize the conversation in one sentence.",
IsUtilityCompletion = true,
DisableTools = true,
};
context.UtilityModelParameters[AIDeploymentParameterNames.ReasoningEffort] = "None";
The chain is explicit utility name, site default utility (DefaultAIDeploymentSettings.DefaultUtilityDeploymentName), explicit chat name, site default chat, then the first text-capable deployment. IsUtilityCompletion makes the named completion path use the utility deployment and the UtilityModelParameters. A host that resolves an IChatClient directly from IAIClientFactory applies the same selections with ChatClientBuilder.UseModelParameters(...) or UseUtilityModelParameters(...).
Outside the chat hubs, build the orchestration context from a profile (or a ChatInteraction), open an AIInvocationScope in the method that enumerates the whole stream, and push tokens to the caller:
using System.Text;
using CrestApps.Core.AI.Orchestration;
using CrestApps.Core.AI.Profiles;
using Microsoft.Extensions.AI;
namespace MyApp.Services;
public sealed class ProfileRunner
{
private readonly IAIProfileManager _profileManager;
private readonly IOrchestrationContextBuilder _contextBuilder;
private readonly IOrchestratorResolver _orchestratorResolver;
public ProfileRunner(
IAIProfileManager profileManager,
IOrchestrationContextBuilder contextBuilder,
IOrchestratorResolver orchestratorResolver)
{
_profileManager = profileManager;
_contextBuilder = contextBuilder;
_orchestratorResolver = orchestratorResolver;
}
public async Task<string> RunAsync(
string profileName,
string prompt,
IList<ChatMessage> history,
Func<string, Task> onToken,
CancellationToken cancellationToken = default)
{
var profile = await _profileManager.FindByNameAsync(profileName, cancellationToken)
?? throw new InvalidOperationException($"Profile '{profileName}' was not found.");
// Tools such as data source search read their context from this ambient scope. It is an AsyncLocal,
// so open it in the method that enumerates the whole stream, not in an async iterator that yields.
using var invocationScope = AIInvocationScope.Begin();
var context = await _contextBuilder.BuildAsync(
profile,
ctx =>
{
ctx.UserMessage = prompt;
ctx.ConversationHistory = history;
},
cancellationToken);
invocationScope.Context.CompletionContext = context.CompletionContext;
invocationScope.Context.DataSourceId = context.CompletionContext.DataSourceId;
var orchestrator = _orchestratorResolver.Resolve(profile.OrchestratorName);
var answer = new StringBuilder();
await foreach (var update in orchestrator.ExecuteStreamingAsync(context, cancellationToken))
{
if (string.IsNullOrEmpty(update.Text))
{
continue;
}
answer.Append(update.Text);
await onToken(update.Text);
}
return answer.ToString();
}
}
IOrchestratorResolver.Resolve(null) returns the default orchestrator. A tool that requires an approval (.RequireApproval(), or a Destructive, External or Security kind) does not run in this run, because nothing here can answer an approval: the model gets a "was not run" result instead. Only AG-UI chat runs (which set AICompletionContextKeys.ToolApprovalSupported) pause for an approval, unless the profile's AIToolApprovalSettings lets the kind run without asking. The built-in AIChatResponseHandler follows the same steps, storing the chat session or interaction on AIInvocationScope.Current before the build.
| Need | Use |
|---|---|
| One prompt, one answer, no profile | IAICompletionService.CompleteAsync |
| Streamed tokens without tools or RAG | IAICompletionService.CompleteStreamingAsync |
| A profile's tools, agents, RAG and MCP | IOrchestrator.ExecuteStreamingAsync |
| Stored sessions, hubs, chat UI | crestapps-core-chat-interactions |
| Speech-to-speech conversations | crestapps-core-realtime-voice |
| Let the chat run tools the user's browser page exposes | crestapps-core-webmcp |
| Show tool calls, ask before a tool runs, share page state (AG-UI) | crestapps-core-ag-ui |
None is sent to the Responses API with store: false; everything else uses Chat Completions. The connection's ChatApi (Auto, ChatCompletions, Responses) controls it.streaming is completed as one response and replayed as a single update.ResolveOrDefaultAsync(AIDeploymentPurpose.Chat, ...) becomes ResolveSlotAsync(AIDeploymentSlotNames.Chat, ...); AIDeploymentManagerExtensions.ResolveAsync(purpose, ...) becomes ResolveSlotOrThrowAsync(slotName, ...); GetByPurposeAsync/GetAllByPurposeAsync become GetAllBySlotAsync.AIDeploymentPurpose, AIDeploymentType, AIDeployment.Purpose, SupportsPurpose and CanServeTextCompletion() are removed. A realtime deployment can never fill the chat or utility slot.AICompletionServiceBase.ResolveDeploymentAsync takes a slot name instead of a purpose.IsUtilityCompletion = true so they run on the utility deployment with its own model parameters.What SKILL.md sets; muted values are Claude Code's defaults
/crestapps-core:crestapps-core-chatfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs.Other plugins' skills for the same job