Skip to main content

Connect to the Decision Model

Connect the decision-model-preview model through an AI tool's extension mechanism. The example uses automated comment moderation: one request evaluates multiple items in parallel, returns choice, probabilities, and confidence, and routes each comment to auto-approve, hide, or manual review.

Background: Why use a decision model

For judgments such as comment moderation, ticket classification, and request routing, a common approach is to have a chat model output JSON. The rules live in the prompt and are easy to derail with adversarial content. Output is often wrapped in code fences and is unstable to parse. Each call first generates analysis text, which adds token overhead. decision-model-preview is a decision model built for these judgments. Send state (the content to evaluate) and questions (typed questions) to the /compatible-mode/v1/systemone endpoint, and it returns structured answers directly: choice (the conclusion), probabilities (the distribution), and confidence (how certain the model is). It does not generate natural language. Questions support three types: Choice (pick an option), Score (rate by level), and Noul (return a probability from 0 to 1). One request can mix multiple questions and evaluate them in parallel. Compared with asking a chat model to "make a judgment along the way":
  • Judgment criteria are passed structurally in the criteria field, independent of the wording of a long prompt.
  • The response is JSON, with no fences or extra text, so agents and code can consume it directly.
  • Answers are short structures rather than long text, which reduces output token overhead and suits high-frequency calls.
Connecting to the decision model is currently supported only in Token Plan Personal Edition.

Example: Add comment moderation in Claude Code

This example uses Claude Code to connect the decision model through a Slash Command. Other tools work the same way; only the extension mechanism and configuration file path differ.

Step 1: Create a Slash Command

Configure the plan API Key (prefixed with sk-sp-) as the $ANTHROPIC_AUTH_TOKEN environment variable for curl authentication. Create .claude/commands/review-comments.md in the project root and add the following content:
Call the Token Plan decision model to batch-review comments and route them by confidence.

User input: $ARGUMENTS (a comment file path, or multiple comments pasted directly)

## Steps

1. Read the comments. If $ARGUMENTS is a file path, read that file; if it is text, use it directly. Put one comment per line, ignore empty lines, and number them from 1.

2. Call the decision model endpoint (run curl with the Bash tool) to evaluate all comments in one request. In questions, each comment maps to a c<number> question with the same structure as c1; replace the id in instructions accordingly:

```
curl -s -X POST "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "state": {
      "comments": [
        {"id": 1, "text": "<comment 1>"},
        {"id": 2, "text": "<comment 2>"}
      ]
    },
    "model": "decision-model-preview",
    "questions": {
      "c1": {
        "type": "choice",
        "instructions": "Which category does the comment with id 1 in `comments` belong to?",
        "criteria": {
          "pass": "Normal discussion, including criticism, questions, and error reports",
          "spam": "Advertising, scam referrals, bulk marketing scripts, or buying and selling accounts or course resources"
        }
      }
    }
  }'
```

3. From the answers in the response JSON, read the choice, confidence, and probabilities fields for c1, c2, and so on.

4. Determine an action for each comment using these rules, then output a table (number, comment summary, judgment, confidence, action):
   - confidence >= 0.9 and choice is spam: hide automatically
   - confidence >= 0.9 and choice is pass: approve automatically
   - confidence < 0.9: send to manual review

5. After the table, output one summary line: X handled automatically, Y sent to manual review. For each item sent to manual review, add a note that cites the spam probability from its probabilities.

Step 2: Review comments

Prepare a comment file comments.txt with one comment per line: Enter /review-comments comments.txt in Claude Code. Example output: Two points in the output are worth noting:
  • #5 and #9 are negative feedback and an error report, and both are judged pass. Judgment looks at the nature of the content, not the tone. Criticism, questions, and error reports are normal discussion, and this rule is written into criteria.
  • #8 is a technical share with a link, and confidence is only 0.69, so it enters the manual queue. The content sits between sharing and promotion, and the probability distribution is not extreme (spam 0.84 / pass 0.16). The model clearly has a preference but is not confident enough. This is the kind of sample that the boundary descriptions in criteria are meant to handle. The routing threshold is set in step 4 of the Command. Raise it for more conservative behavior, or lower it for more automation.

Understand the three returned fields

Answers are returned under the same keys as questions. Each Choice answer contains:
FieldMeaningHow to use it
choiceThe selected optionBranching: approve or hide
probabilitiesProbability of each option; the sum is 1Display, sort, or weight
confidenceConfidence in the judgment, from 0 to 1Threshold routing: high values run automatically, low values go to manual review
Keys in questions are user-defined and do not participate in reasoning. For "degree" judgments, use Noul (return a probability from 0 to 1) or Score (rate by level). One request can mix them.

Other tools

The following table lists extension mechanisms and configuration file paths for mainstream AI coding tools that support extensions. Save the configuration from the Claude Code example to the corresponding path.

Tool

Extension mechanism

Configuration file path

Claude Code

Slash Command

.claude/commands/review-comments.md

Codex

Skill

~/.codex/skills/token-plan-review/SKILL.md

Qwen Code

Skill

~/.qwen/skills/review-comments/SKILL.md

OpenCode

Agent

.opencode/agents/review-comments.md

OpenClaw

Skill

~/.openclaw/workspace/skills/token-plan-review/SKILL.md

Hermes Agent

Skill

~/.hermes/skills/moderation/review-comments/SKILL.md

Qoder

Skill

~/.qoder/skills/review-comments/SKILL.md

Skill-based tools (Codex, Qwen Code, OpenClaw, Hermes Agent, and Qoder) require YAML front matter at the top of the configuration file. The complete configuration follows:
---
name: "token-plan-review"
description: "Call the Token Plan decision model to batch-review comments and route them by confidence. Use when the user asks to review comments or filter spam comments."
---

Call the Token Plan decision model to batch-review comments and route them by confidence.

User input: a comment file path, or multiple comments pasted directly.

## Steps

1. Read the comments. If the input is a file path, read that file; if it is text, use it directly. Put one comment per line, ignore empty lines, and number them from 1.

2. Call the decision model endpoint (run curl with the Bash tool) to evaluate all comments in one request. In questions, each comment maps to a c<number> question with the same structure as c1; replace the id in instructions accordingly:

```
curl -s -X POST "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "state": {
      "comments": [
        {"id": 1, "text": "<comment 1>"},
        {"id": 2, "text": "<comment 2>"}
      ]
    },
    "model": "decision-model-preview",
    "questions": {
      "c1": {
        "type": "choice",
        "instructions": "Which category does the comment with id 1 in `comments` belong to?",
        "criteria": {
          "pass": "Normal discussion, including criticism, questions, and error reports",
          "spam": "Advertising, scam referrals, bulk marketing scripts, or buying and selling accounts or course resources"
        }
      }
    }
  }'
```

3. From the answers in the response JSON, read the choice, confidence, and probabilities fields for c1, c2, and so on.

4. Determine an action for each comment using these rules, then output a table (number, comment summary, judgment, confidence, action):
   - confidence >= 0.9 and choice is spam: hide automatically
   - confidence >= 0.9 and choice is pass: approve automatically
   - confidence < 0.9: send to manual review

5. After the table, output one summary line: X handled automatically, Y sent to manual review. For each item sent to manual review, add a note that cites the spam probability from its probabilities.
The OpenCode Agent uses different front matter. The complete configuration follows:
---
description: "Call the Token Plan decision model to batch-review comments and route them by confidence."
mode: subagent
tools:
  bash: true
  write: false
  edit: false
---

Call the Token Plan decision model to batch-review comments and route them by confidence.

User input: a comment file path, or multiple comments pasted directly.

## Steps

1. Read the comments. If the input is a file path, read that file; if it is text, use it directly. Put one comment per line, ignore empty lines, and number them from 1.

2. Call the decision model endpoint (run curl with the Bash tool) to evaluate all comments in one request. In questions, each comment maps to a c<number> question with the same structure as c1; replace the id in instructions accordingly:

```
curl -s -X POST "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/systemone" \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "state": {
      "comments": [
        {"id": 1, "text": "<comment 1>"},
        {"id": 2, "text": "<comment 2>"}
      ]
    },
    "model": "decision-model-preview",
    "questions": {
      "c1": {
        "type": "choice",
        "instructions": "Which category does the comment with id 1 in `comments` belong to?",
        "criteria": {
          "pass": "Normal discussion, including criticism, questions, and error reports",
          "spam": "Advertising, scam referrals, bulk marketing scripts, or buying and selling accounts or course resources"
        }
      }
    }
  }'
```

3. From the answers in the response JSON, read the choice, confidence, and probabilities fields for c1, c2, and so on.

4. Determine an action for each comment using these rules, then output a table (number, comment summary, judgment, confidence, action):
   - confidence >= 0.9 and choice is spam: hide automatically
   - confidence >= 0.9 and choice is pass: approve automatically
   - confidence < 0.9: send to manual review

5. After the table, output one summary line: X handled automatically, Y sent to manual review. For each item sent to manual review, add a note that cites the spam probability from its probabilities.

Notes

  • Write judgment boundaries in criteria. For edge cases such as "what counts as spam" (for example, a technical share with a link), a clear option description works better than repeated rewording of the question.
  • Break complex judgments into smaller ones: ask one clear question at a time, evaluate each dimension separately, and combine the results in the routing rules of the Command.
  • A low confidence means the model is explicitly unsure. Routing to manual review works better than retrying. The 0.9 threshold is an example; adjust it based on the cost of a wrong judgment.
  • Handle request failures by status code: 401 means check the API Key, 422 means request body validation failed (the response body identifies the invalid field), and 429 and 529 should be retried with backoff.
  • The model outputs a judgment and a confidence level, not a guarantee of fact. Keep human review for high-risk actions such as account bans and financial actions.