Creates and manages AI agent profiles in CrestApps.Core 2.0, where agents are invoked as tools by the primary model. Covers agent metadata, tool invocation, recursion guards, MCP exposure, and deployment inheritance.
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.
An agent is an AIProfile with Type = AIProfileType.Agent. The primary model sees each available agent as a tool that takes one prompt argument and returns the agent's answer. Each agent has its own system prompt, deployment and settings, so instructions do not collide.
AddCoreAIOrchestration() (or AddAISuite(...)) registers AgentToolRegistryProvider; nothing else is needed.Name and a strong Description. Agents with an empty name or description are skipped, and the description is all the model (or an MCP client) has to decide with.OnDemand for most agents and link them per profile. AlwaysAvailable agents are added to every request and cost tokens on every turn.AgentMetadata.AllowToolInvocation = true only when it needs its own tools; it then runs through its orchestrator, and agents inside it are still suppressed.ChatDeploymentName empty to inherit the caller's chat deployment, or name a cheaper or more capable model for the agent.using CrestApps.Core.AI.Models;
using CrestApps.Core.AI.Profiles;
var agent = await profileManager.NewAsync("translator");
agent.Type = AIProfileType.Agent;
agent.DisplayText = "Translator";
agent.Description = "Translates text between languages. Provide the target language and the text.";
agent.ChatDeploymentName = "gpt-5-mini";
agent.Put(new AIProfileMetadata { SystemMessage = "Translate faithfully. Return only the translation." });
agent.Put(new AgentMetadata { Availability = AgentAvailability.OnDemand });
await profileManager.CreateAsync(agent);
chatProfile.Put(new AgentInvocationMetadata
{
Names = ["translator", "code-reviewer"],
});
await profileManager.UpdateAsync(chatProfile);
The names flow to AICompletionContext.AgentNames; AgentToolRegistryProvider returns those agents plus every AlwaysAvailable agent as ToolRegistryEntrySource.Agent entries.
An agent is never offered to itself. AICompletionContext.RunningAgentName names the agent profile a context was built for (when an agent runs directly, such as on the sample Test page, and in every sub-agent run), and AgentToolRegistryProvider, the agent list in the system message and the A2A listAvailableAgents and findAgentForTask tools skip it through context.IsRunningAgent(name), even when it is AlwaysAvailable or its own AgentInvocationMetadata names it. Inside a sub-agent the two A2A tools list no local agent. The sample profile editors also leave the edited agent out of its own AI Agents list.
AgentProxyTool resolves the agent through IAIProfileManager.GetAsync(AIProfileType.Agent) and then:
IAICompletionContextBuilder, sets DisableTools = true, labels usage with AIUsagePurposes.SubAgent, resolves ResolveSlotAsync(AIDeploymentSlotNames.Chat, context.ChatDeploymentName) and calls IAICompletionService.CompleteAsync with the prompt.AllowToolInvocation = true: increments AIInvocationContext.AgentInvocationDepth, builds an orchestration context for the agent with AgentNames cleared, resolves IOrchestratorResolver.Resolve(agent.OrchestratorName) and collects the streamed text. Tool-capable agents only run while the depth is below one, so an agent can use its tools but never call another agent.A missing agent or a failure returns a descriptive message to the primary model instead of throwing. Without an AIInvocationScope the depth is unknown and the agent runs with tools disabled.
The MVC and Blazor sample agent editors set AllowToolInvocation from the Capabilities tab: on when at least one tool, tool instance, MCP connection or A2A connection is picked, off when none is.
agent.Put(new AgentMetadata
{
Availability = AgentAvailability.OnDemand,
AllowToolInvocation = true,
});
agent.Put(new FunctionInvocationMetadata { Names = ["query-orders"] });
Implement IAIProfileProvider for agents defined in code. Return agents only when type == AIProfileType.Agent; stored profiles with the same name win. Set IsSystem = true to keep an agent read-only and out of user-facing pickers while it stays available to orchestration and the A2A host.
using CrestApps.Core.AI.Models;
using CrestApps.Core.AI.Profiles;
public sealed class ComplianceAgentProvider : IAIProfileProvider
{
public ValueTask<IReadOnlyList<AIProfile>> GetProfilesAsync(
AIProfileType type,
CancellationToken cancellationToken = default)
{
if (type != AIProfileType.Agent)
{
return ValueTask.FromResult<IReadOnlyList<AIProfile>>([]);
}
var agent = new AIProfile
{
Type = AIProfileType.Agent,
Name = "compliance-checker",
DisplayText = "Compliance Checker",
Description = "Checks a draft reply against the company's compliance rules and lists violations.",
};
agent.Put(new AIProfileMetadata { SystemMessage = "List every rule the draft breaks, or say it is compliant." });
agent.Put(new AgentMetadata
{
Availability = AgentAvailability.AlwaysAvailable,
IsSystem = true,
});
return ValueTask.FromResult<IReadOnlyList<AIProfile>>([agent]);
}
}
builder.Services.TryAddEnumerable(ServiceDescriptor.Scoped<IAIProfileProvider, ComplianceAgentProvider>());
A provider can offer an agent only to one chat. The chat response handler stores the chat interaction and session in AIInvocationScope.Current before it builds the orchestration context, so read AIInvocationScope.Current?.ChatInteraction or ?.ChatSession inside GetProfilesAsync.
Built-in system agents follow the same pattern, each with AllowToolInvocation and hidden tools:
| Agent | Name | Registered by | Disable with |
|---|---|---|---|
| Tabular Data Agent | tabular-data-agent | document processing | |
| PDF Agent | pdf-agent | AddPdf() on the document processing builder | PdfAgentOptions.Enabled = false |
| Presentation Agent | presentation-agent | AddOpenXml() | PresentationAgentOptions.Enabled = false |
| Word Agent | word-agent | AddWord() | WordAgentOptions.Enabled = false |
An MCP server built with CrestApps.Core can publish agents as callable tools, one per allow-listed agent, named after the agent, described by its description, taking a single prompt.
using CrestApps.Core.AI.Mcp.Models;
builder.Services.Configure<McpServerOptions>(options =>
{
options.Agents = ["translator", "compliance-checker"];
// or options.ExposeAllAgents = true;
});
Agents have their own switch; ExposeAllTools never exposes agents.
An agent without a description is not listed. AgentAvailability is ignored here. An agent whose name collides with an exposed tool is skipped with a warning.
The agent's own tools are not filtered by the server's tool allow-list; what it uses internally is its own configuration.
Each MCP tool call runs inside an AIInvocationScope, so AllowToolInvocation agents get their tools and citation-emitting tools register their citations.
An agent reached over MCP gets a "was not run" result for its tools that require an approval, even when its profile runs them without asking (an MCP client is not a calling profile).
See crestapps-core-mcp for the server setup itself.
A tool registered with .RequireApproval() or as Destructive, External or Security keeps that requirement inside an agent:
| The run that calls the agent | When the agent calls such a tool |
|---|---|
| Can ask (an AG-UI chat run on the default orchestrator) | The agent pauses and the assistant's run ends with an interrupt naming the agent, the tool and its arguments. Allow continues the agent where it stopped and the tool runs; Deny continues it with a refusal. Earlier calls are not repeated |
Cannot ask (the SendMessage stream, a chat interaction, realtime, an MCP client, background work, the Claude or Copilot orchestrator) | The tool does not run; the agent's model gets a "was not run" result and reports it |
AgentProxyTool lets the agent's run ask only when its caller can (AgentToolApprovals); otherwise it removes AICompletionContextKeys.ToolApprovalSupported from the agent's context. A kept run is continued even when the resuming run cannot ask, so earlier calls never repeat. The paused run is kept in ChatTurnToolActivity.AgentRuns; see crestapps-core-ag-ui for the events and stored state.AIToolApprovalSettings lets such a tool run unasked inside an agent only when both the agent's profile and the calling profile allow its kind (ToolApprovalPolicy.ForAgent). An explicit .RequireApproval() always asks.AlwaysAvailable, and that an IAIProfileProvider filtering by chat reads AIInvocationScope.Current rather than IHttpContextAccessor.crestapps.core.ai.tool.denied, reason=approval). Use the agent from an AG-UI chat on the default orchestrator, or call .RequireApproval(false) on a tool that may run inside agents unasked.AllowToolInvocation is set.RunningAgentName).AlwaysAvailable and IsSystem agents are intentionally hidden from user selection.AICompletionContext.RunningAgentName, IsRunningAgent()).AgentProxyTool resolves the agent deployment through the chat slot (ResolveSlotAsync) instead of ResolveOrDefaultAsync(AIDeploymentPurpose.Chat, ...).ChatDeploymentName empty inherits the delegating conversation's chat deployment.SubAgent in usage records.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ai-agents, crestapps-core, agent-profiles, mcp-integration, sub-agents
/crestapps-core:crestapps-core-ai-agentsfrom 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