Crestapps core ai agents

From CrestApps/CrestApps.AgentSkills · View interactive version

Crestapps core ai agents is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for AI agents in CrestApps.Core 2.0, specialized AIProfile records of type Agent that the primary model invokes as tools. Covers creating agent profiles with AgentMetadata availability (OnDemand or AlwaysAvailable), linking them with AgentInvocationMetadata, how AgentProxyTool runs an agent wi

How to use this skill

Skill file

CrestApps.Core AI Agents

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.

Guidelines

Create an 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);

Link Agents to a Chat Profile

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.

How an Agent Runs

AgentProxyTool resolves the agent through IAIProfileManager.GetAsync(AIProfileType.Agent) and then:

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.

agent.Put(new AgentMetadata
{
    Availability = AgentAvailability.OnDemand,
    AllowToolInvocation = true,
});

agent.Put(new FunctionInvocationMetadata { Names = ["query-orders"] });

Code-Defined and System Agents

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 |

Agents as MCP Server Tools

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;
});

See crestapps-core-mcp for the server setup itself.

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.