Skip to main content

Integrate decision models

Integrate the decision-model-preview model through your AI tool's extension mechanism: using automated comment moderation as the example, one request judges multiple comments in parallel and returns choice, probabilities, and confidence for confidence-based auto-approve, auto-hide, or human review.

Background: why a decision model

Comment moderation, ticket triage, and request routing are judgment tasks. The common approach is to have a chat model output JSON: the rules live in a prompt and can be steered off course by suggestive content; the output often arrives wrapped in code fences that parse unreliably; and the model generates a paragraph of analysis first, which adds token cost. decision-model-preview is a decision model built for exactly these judgments. Send state (the content to judge) and questions (typed questions) to the /compatible-mode/v1/systemone endpoint and get structured answers back: choice (the verdict), probabilities (the distribution), and confidence (how sure). No natural-language text is generated. Questions come in three types: Choice (pick from options), Score (rate against ordered levels), and Noul (return a 0-to-1 probability), and a single call can mix several questions evaluated in parallel. Compared with asking a chat model to "quickly classify this":
  • Judgment criteria are passed structurally in the criteria field, not depending on the wording of a long prompt
  • The response is JSON, with no fences and no extra prose, ready for agents and code to consume
  • Answers are short structures rather than long text, keeping output token cost low for high-frequency calls
Integrating decision models currently supports only Token Plan Personal Edition.

Example: integrate comment moderation in Claude Code

Claude Code is used here as the example, integrating the decision model through a Slash Command. Other tools follow the same pattern; only the extension mechanism and config file path differ.

Step 1: Create a Slash Command

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

User input: $ARGUMENTS (a comments 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. One comment per line, skip empty lines, number them starting from 1.

2. Call the decision model endpoint (run curl with the Bash tool) and judge all comments in one request. Each comment maps to one c<number> question in questions, with the same structure as c1 and the id in instructions replaced 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": "Ad or scam solicitation, bulk marketing scripts, buying or selling accounts or course materials"
        }
      }
    }
  }'
```

3. Read the choice, confidence, and probabilities fields of c1, c2, ... one by one from answers in the returned JSON.

4. Determine an action for each comment by the following rules and output a table (number, comment summary, verdict, confidence, action):
   - confidence >= 0.9 and choice is spam: auto-hide
   - confidence >= 0.9 and choice is pass: auto-approve
   - confidence < 0.9: human review

5. After the table, output one summary line: X comments handled automatically, Y sent to human review. For each human-review entry, add one sentence citing the spam probability from that entry's probabilities.

Step 2: Moderate comments

Prepare a comments file comments.txt with one comment per line: Enter /review-comments comments.txt in Claude Code. Example output: Two things in the output are worth noting:
  • #5 and #9 are criticism and an error report, both judged pass. The verdict reflects the nature of the content, not its tone. Criticism, questions, and error reports count as normal discussion, a rule written into criteria.
  • #8 is a technical share with a link, confidence only 0.69, sent to the human queue. The content sits between sharing and solicitation, and the distribution is not extreme either (spam 0.84 / pass 0.16): the model signals a leaning but insufficient certainty, exactly the kind of sample that criteria boundary descriptions exist to handle. The routing threshold lives in step 4 of the Command; raise it to be more conservative, lower it to automate more.

Read the three response fields

Answers come back under the same keys used in questions. Each Choice answer contains:
FieldMeaningHow to use it
choiceThe selected optionBranch basis: approve or hide
probabilitiesProbability of each option, summing to 1Display, sorting, weighting
confidenceHow sure, 0 to 1Threshold routing: high acts automatically, low goes to humans
Keys in questions are custom and take no part in inference. For degree-style judgments, switch to Noul (returns a 0-to-1 probability) or Score (rates against levels); a single call can mix them.

Other tools

The table below lists the extension mechanism and config file path for each tool, covering mainstream AI coding tools that support extension mechanisms. Save the Claude Code configuration above to the corresponding path.
ToolExtension mechanismConfig file path
Claude CodeSlash Command.claude/commands/review-comments.md
CodexSkill~/.codex/skills/token-plan-review/SKILL.md
Qwen CodeSkill~/.qwen/skills/review-comments/SKILL.md
OpenCodeAgent.opencode/agents/review-comments.md
OpenClawSkill~/.openclaw/workspace/skills/token-plan-review/SKILL.md
Hermes AgentSkill~/.hermes/skills/moderation/review-comments/SKILL.md
QoderSkill~/.qoder/skills/review-comments/SKILL.md
Skill-based tools (Codex, Qwen Code, OpenClaw, Hermes Agent, Qoder) need YAML front matter at the top of the config file. The complete config file:
---
name: "token-plan-review"
description: "Call the Token Plan decision model to moderate comments in batch and route them by confidence. Activated when the user asks to moderate or filter comments."
---

Call the Token Plan decision model to moderate comments in batch and route them by confidence.

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

## Steps

1. Read the comments. If the user input is a file path, read that file; if it is text, use it directly. One comment per line, skip empty lines, number them starting from 1.

2. Call the decision model endpoint (run curl with the Bash tool) and judge all comments in one request. Each comment maps to one c<number> question in questions, with the same structure as c1 and the id in instructions replaced 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": "Ad or scam solicitation, bulk marketing scripts, buying or selling accounts or course materials"
        }
      }
    }
  }'
```

3. Read the choice, confidence, and probabilities fields of c1, c2, ... one by one from answers in the returned JSON.

4. Determine an action for each comment by the following rules and output a table (number, comment summary, verdict, confidence, action):
   - confidence >= 0.9 and choice is spam: auto-hide
   - confidence >= 0.9 and choice is pass: auto-approve
   - confidence < 0.9: human review

5. After the table, output one summary line: X comments handled automatically, Y sent to human review. For each human-review entry, add one sentence citing the spam probability from that entry's probabilities.
The OpenCode Agent uses a different front matter format. The complete config file:
---
description: "Call the Token Plan decision model to moderate comments in batch and route them by confidence."
mode: subagent
tools:
  bash: true
  write: false
  edit: false
---

Call the Token Plan decision model to moderate comments in batch and route them by confidence.

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

## Steps

1. Read the comments. If the user input is a file path, read that file; if it is text, use it directly. One comment per line, skip empty lines, number them starting from 1.

2. Call the decision model endpoint (run curl with the Bash tool) and judge all comments in one request. Each comment maps to one c<number> question in questions, with the same structure as c1 and the id in instructions replaced 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": "Ad or scam solicitation, bulk marketing scripts, buying or selling accounts or course materials"
        }
      }
    }
  }'
```

3. Read the choice, confidence, and probabilities fields of c1, c2, ... one by one from answers in the returned JSON.

4. Determine an action for each comment by the following rules and output a table (number, comment summary, verdict, confidence, action):
   - confidence >= 0.9 and choice is spam: auto-hide
   - confidence >= 0.9 and choice is pass: auto-approve
   - confidence < 0.9: human review

5. After the table, output one summary line: X comments handled automatically, Y sent to human review. For each human-review entry, add one sentence citing the spam probability from that entry's probabilities.

Notes

  • Judgment boundaries live in criteria. Describe borderline cases (such as technical shares with links) as explicit option descriptions; that works better than repeatedly rewording the question.
  • Split complex judgments: ask one specific question at a time, judge each dimension separately, and combine the results in the Command's routing rules.
  • A low confidence is the model explicitly signaling uncertainty; routing to humans beats retrying. The 0.9 threshold is an example value, adjust it to your cost of misjudgment.
  • Handle failures by status code: 401 check the API Key, 422 means request body validation failed (the response body names the offending field), 429 and 529 retry after backoff.
  • The model outputs a verdict and its certainty, not a guarantee of fact. Keep a human review step for high-risk actions such as account bans or fund handling.
Model Playground
Fine-tuning
Model Compression
Statistics and Monitoring
Support