Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add wan-huiyan/agent-traffic-control --skill cjk-structured-llm-output-truncates-json-needs-2x-tokensgit clone --depth 1 https://github.com/wan-huiyan/agent-traffic-controlWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/cjk-structured-llm-output-truncates-json-needs-2x-tokens)<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/cjk-structured-llm-output-truncates-json-needs-2x-tokens"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/cjk-structured-llm-output-truncates-json-needs-2x-tokens/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/cjk-structured-llm-output-truncates-json-needs-2x-tokens"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/cjk-structured-llm-output-truncates-json-needs-2x-tokens.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00227 | $0.01321 |
| Opus 5.5 | $0.00091 | $0.00528 |
| Sonnet 5.5 | $0.00045 | $0.00264 |
| Haiku 4.5 | $0.00023 | $0.00132 |
Grade A, and why
cjk-structured-llm-output-truncates-json-needs-2x-tokens scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Long CJK structured output truncates JSON — budget ~2× tokens, and salvage the rest
Problem
You ask an OpenAI-compatible LLM for a long JSON report. In English it returns valid JSON. In Chinese
(or Japanese/Korean) the identical request returns a string that starts with valid JSON but is cut off
mid-object → json.loads fails, your regex \{.*\} grabs an unbalanced blob, and you get "no parseable JSON".
Why
- CJK is token-dense. One Han character is often 1–2 BPE tokens; English averages ~0.25 tokens/char. The
same report is ~1.5–2× more output tokens in Chinese. A
max_tokensthat comfortably fit the English report truncates the Chinese one. - Per-model output caps differ and some are low. Requesting
max_tokensabove a model's hard cap is either rejected (400 ... Range of max_tokens should be [1, 8192]) or silently clamped, then the long CJK report truncates. Observed: qwen-max hard-caps at 8192 (can't emit a full Chinese report); glm-4.6 / minimax ≈16K; qwen-plus / qwen3-235b / glm-5.2 / kimi / deepseek handle 24–32K. Reasoning models also spend tokens onreasoning_contentbefore the JSON, compounding it.
Fix
- Budget ~2× the English max_tokens for CJK (e.g. 16000–32000 for a full report), per model, up to its cap.
- Probe the cap if a
400appears — binary-searchmax_tokens(a tiny call that 400s vs 200s reveals the ceiling). For reasoning models, leave headroom forreasoning_content. - Salvage truncated JSON instead of failing — close the object after the last complete top-level section.
Walk the string tracking brace/bracket depth and string/escape state; record the index each time depth returns
to 1 (a top-level value just closed); cut there and append
}:
Truncation then degrades gracefully — the report keeps its complete sections, and the missing tail shows up as lower "comprehensiveness" in scoring rather than a hard failure.def salvage(c): s = c[c.find("{"):]; depth=0; instr=False; esc=False; cut=None for i,ch in enumerate(s): if esc: esc=False; continue if instr: if ch=="\\": esc=True elif ch=='"': instr=False continue if ch=='"': instr=True elif ch in "{[": depth+=1 elif ch in "}]": depth-=1 if depth==1: cut=i+1 if cut: try: d=json.loads(s[:cut].rstrip().rstrip(",")+"}") if isinstance(d,dict) and len(d)>=MIN_SECTIONS: return d except Exception: pass return None - Also strip reasoning prefixes before parsing: some models inline chain-of-thought as
<think>…</think>before the JSON (MiniMax-M3) —re.sub(r"(?is)^.*?</think>","",c)first.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3mo ago First seen · 86 lines · 227 tokens per session scan A d7218f2a8f2c
cjk-structured-llm-output-truncates-json-needs-2x-tokens is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (3 stars, last pushed 3d ago), licensed MIT. It adds 227 tokens to every session and 1,321 once invoked, about $0.0009 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
cjk-structured-llm-output-truncates-json-needs-2x-tokens compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| cjk-structured-llm-output-truncates-json-needs-2x-tokenswan-huiyan/agent-traffic-control | Skill | 3 | 3d ago | MIT | A | 227 | Claude Code |
| cloudflare-workers-aisecondsky/claude-skills | Skill | 257 | 8d ago | MIT | A | 39 | Claude Code |
| ask-claudethoughtbot/rails-consultant | Skill | 39 | 9d ago | MIT | A | 97 | Claude Code |
| rag-vs-finetune-decisionVandanaAjayDubey111/great-pm | Skill | 3 | 2mo ago | MIT | A | 109 | Claude Code |
| ai-use-case-scopingVandanaAjayDubey111/great-pm | Skill | 3 | 2mo ago | MIT | A | 85 | Claude Code |
| prompt-mininidhinjs/prompt-mini | Skill | 31 | 8mo ago | MIT | A | 37 | Claude Code |
| fable-promptingjjilli/fable-flow | Skill | 2 | 4mo ago | MIT | A | 89 | Claude Code |