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.

The Coder subagent is FrostAgent’s built-in specialist for programming tasks. When the main agent identifies a code generation request — writing functions, debugging snippets, explaining algorithms, or producing boilerplate — it delegates the work to the Coder via use_subagent. The Coder runs as an independent LLM call powered by Alibaba’s qwen-coder-plus model, keeping its context clean and its system prompt tightly focused on programming assistance.

Configuration

The Coder subagent requires a single environment variable to authenticate with Alibaba DashScope:
CODER_API_KEY=sk-your-dashscope-api-key-here
CODER_API_KEY must be a valid Alibaba DashScope API key. You can obtain one from the DashScope console. Standard OpenAI keys will not work here because the Coder subagent calls the DashScope-compatible endpoint directly.
SettingValue
Modelqwen-coder-plus
Endpointhttps://dashscope.aliyuncs.com/compatible-mode/v1
System prompt你是编程助手。 (“You are a programming assistant.”)
Auth env varCODER_API_KEY

CallCoder Function

The Coder subagent is implemented as a single exported function in subagent/coder.go:
func CallCoder(client *llm.Client, baseURL, apiKey, _ string, contentBlocks string) string

Parameters

ParameterTypeDescription
client*llm.ClientShared HTTP client passed down from the main agent engine.
baseURLstringCurrently unused — the endpoint is hardcoded to DashScope.
apiKeystringCurrently unused — the key is read from CODER_API_KEY at runtime.
_stringUnnamed/reserved parameter, ignored.
contentBlocksstringThe code task description forwarded by the main agent.

Return value

CallCoder returns the model’s response as a JSON-marshalled string. On error, it returns the error message string directly and logs the failure via the internal logs package.
The baseURL and apiKey parameters are currently ignored. CallCoder always connects to https://dashscope.aliyuncs.com/compatible-mode/v1 and reads credentials from the CODER_API_KEY environment variable, regardless of what values are passed in. This behaviour is noted in the source as a temporary hardcode and is expected to change in a future version.

Full source

package subagent

import (
    "FrostAgent/internal/llm"
    "FrostAgent/internal/logs"
    "encoding/json"
    "os"
)

const CoderPrompt = "你是编程助手。"

func CallCoder(client *llm.Client, baseURL, apiKey, _, contentBlocks string) string {
    // 这边先硬编码,到时候我回来改
    messages := []llm.ChatMessage{
        {Role: "system", Content: CoderPrompt},
        {Role: "user", Content: contentBlocks},
    }
    responseMsg, err := client.CallAPI("https://dashscope.aliyuncs.com/compatible-mode/v1", os.Getenv("CODER_API_KEY"), "qwen-coder-plus", messages, nil)
    if err != nil {
        logs.Error(logs.SYSTEM, err.Error())
        return err.Error()
    }

    bytes, _ := json.Marshal(responseMsg.Content)
    return string(bytes)
}

How the Main Agent Triggers the Coder

The main agent selects the Coder automatically when the user’s request involves writing, reviewing, or explaining code. Because use_subagent is a registered tool, the LLM reasons about the available tools the same way it would any other function call. A system prompt or user message like the following is enough to cause the main agent to route the task:
User: Write a Go function to calculate Fibonacci numbers.
The main agent will:
  1. Recognise this as a programming task.
  2. Call send_message to tell the user it is delegating to the Coder agent.
  3. Call use_subagent with subagent_name: "Coder" and the original request as content.

Example Interaction

1

User sends a coding request

The user submits a message to the main FrostAgent:
Write a Go function to calculate Fibonacci numbers.
2

Main agent notifies the user

The main agent calls send_message before delegating:
I'll hand this off to the Coder agent — just a moment.
3

Main agent calls use_subagent

The main agent emits a tool call:
{
  "tool": "use_subagent",
  "arguments": {
    "subagent_name": "Coder",
    "content": "Write a Go function to calculate Fibonacci numbers."
  }
}
4

Coder subagent responds

CallCoder sends the task to qwen-coder-plus with the system prompt 你是编程助手。 and returns the generated code:
// Fibonacci returns the nth Fibonacci number.
func Fibonacci(n int) int {
    if n <= 1 {
        return n
    }
    a, b := 0, 1
    for i := 2; i <= n; i++ {
        a, b = b, a+b
    }
    return b
}
5

Main agent presents the result

The main agent receives the Coder’s output as the tool result and incorporates it into its final reply to the user, optionally adding explanation or usage examples.

For an overview of all available subagents and instructions on adding your own, see the Subagents overview.

Build docs developers (and LLMs) love