Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GuaiZai233/FrostAgent/llms.txt

Use this file to discover all available pages before exploring further.

FrostAgent’s subagent system allows the main orchestrating agent to offload specialized work to purpose-built sub-agents, each carrying a focused system prompt tuned for a particular domain. Rather than burdening a single model with every kind of task, the main agent identifies when a specialist is better suited, calls use_subagent, and seamlessly incorporates the result into its final response — keeping interactions coherent while improving output quality for targeted tasks like code generation.

The use_subagent Tool

The use_subagent tool is the main agent’s only entry point into the subagent system. It is registered under the tool name use_subagent and is backed by a dispatch manager whose guiding prompt is:
SubAgentManagerPrompt = "你是子Agent的调度和管理工具。"
(“You are the scheduling and management tool for sub-agents.”)
The tool description instructs the main agent to call send_message before invoking a subagent. This ensures the user receives immediate feedback — such as “I’m delegating this to the Coder agent” — rather than experiencing a silent pause while the subagent runs.

Parameters

ParameterTypeRequiredDescription
subagent_namestringThe name of the subagent to invoke. Currently only "Coder" is supported.
contentstringThe task description or content to pass to the subagent.

JSON Schema

{
  "type": "object",
  "properties": {
    "subagent_name": {
      "type": "string",
      "description": "要调用的子agent名称"
    },
    "content": {
      "type": "string",
      "description": "发送给子代理的具体任务内容或代码片段"
    }
  },
  "required": ["subagent_name", "content"]
}

How Subagent Dispatch Works

When the main LLM decides that a task is best handled by a subagent, the following sequence takes place:
1

Main LLM decides to delegate

The main agent’s reasoning loop identifies a task that matches a known subagent — for example, a code generation request triggers use_subagent.
2

send_message is called first

Before dispatching, the main agent calls send_message to notify the user that work has been assigned to a subagent (e.g., “I’m asking the Coder agent to handle this”).
3

SubAgentTool.Execute is called

The FrostAgent engine invokes SubAgentTool.execute(args) with a JSON-encoded string containing subagent_name and content.
4

Parameters are parsed

The tool unmarshals the JSON arguments into a typed struct, extracting SubagentName and Content.
5

Appropriate subagent function is called

Based on SubagentName, the tool calls the matching subagent function — for "Coder", it calls subagent.CallCoder(client, "", "", "", params.Content).
6

Result is returned to the main LLM

The subagent’s response string is returned as the tool result. The main agent incorporates it into its final answer for the user.

Available Subagents

NamePurposeAPI Key Env Var
CoderCode generation and programming tasksCODER_API_KEY
Each subagent runs as a separate, stateless LLM call with its own system prompt. This keeps subagent context narrow and output focused, without polluting the main conversation history.

Adding New Subagents

Extending the subagent system with a new specialist requires three steps: 1. Implement the subagent function Create a new file in the subagent/ package. Follow the same pattern as coder.go: accept a *llm.Client, relevant configuration parameters, and the task content; return the model’s response as a string.
// subagent/mytool.go
package subagent

import "FrostAgent/internal/llm"

const MyToolPrompt = "You are a specialist in..."

func CallMyTool(client *llm.Client, contentBlocks string) string {
    messages := []llm.ChatMessage{
        {Role: "system", Content: MyToolPrompt},
        {Role: "user",   Content: contentBlocks},
    }
    responseMsg, err := client.CallAPI("<base-url>", "<api-key>", "<model>", messages, nil)
    if err != nil {
        return err.Error()
    }
    // marshal and return
    ...
}
2. Add a case in SubAgentTool.execute Open internal/tools/subagent.go and add a branch for the new name inside the execute closure:
if params.SubagentName == "MyTool" {
    result := subagent.CallMyTool(client, params.Content)
    return result, nil
}
3. Update the tool description Add the new subagent’s name and purpose to the description field of the Tool struct so the main LLM knows it exists and when to use it.
For a deep dive into the built-in Coder subagent, see the Coder subagent reference. To learn how to build fully custom tools from scratch, see the Custom Tools guide.

Build docs developers (and LLMs) love