error-hint-change

A reference for changing error messages and error categories in a command-line program. It explains which failures come from the local program and which come from a remote service, such as an API.

In plain words
What is it for?
Use it when editing error text, hints, exit codes, authentication failures, network failures, or API error handling in a CLI. It also helps preserve the original message for server-side errors.
Why use it?
It prevents the command-line tool from mislabeling or rewriting errors that only the remote service can explain. Local input, file, login, network, and timeout failures are handled differently from server responses.

Agent

Install

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.

agentmods
npx agentmods add agents/modelstudioai/cli/error-hint-change
Clone the repo
git clone --depth 1 https://github.com/modelstudioai/cli
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,078 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02078
Opus 5 $0.00000 $0.01039
Sonnet 5 $0.00000 $0.00416
Haiku 4.5 $0.00000 $0.00208

Measured yesterday against content hash d9e28aa8720e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

error-hint-change 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 yesterday.

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.

docs/agents/error-hint-change.md · 133 lines

How it starts

The opening of the file, as written. The whole thing — 133 lines — stays where its author put it; the contents beside it link to each section on GitHub.

错误文案变更

触发条件

  • 修改 BailianError 的 message 或 hint
  • 调整 runtime 的 hint 增强逻辑(enhanceHint)
  • 改 auth stage / resolver 的鉴权失败文案
  • 改任何抛错位置的分类(exitCode)

注意:mapApiError 不再做错误分类(参见下方"边界原则")。如果你想给某种 HTTP 错误码加白名单分类,请先回到本文档读完"边界原则"再说。

边界原则:CLI 不翻译服务端错误

CLI 只为「自己能权威解释的错误」发出语义化信号,服务端的错误原样透传。

错误来源 归类 处理方式
命令解析、缺 flag、参数校验 内部 BailianError(USAGE)
文件 I/O(ENOENT/EACCES/...) 内部 BailianError(GENERAL) + errno-specific hint
本地 credentials 缺失(resolver / authStage 等) 内部 BailianError(AUTH)
fetch 自身失败(DNS/TCP/TLS/proxy) 内部 BailianError(NETWORK) + 读 err.cause.code 给 errno-hint
polling 客户端超时 内部 BailianError(TIMEOUT)
HTTP 4xx/5xx、HTTP 200 + 业务错码、async task FAILED 服务 BailianError(GENERAL),message 原样透传,不分类、不替换

判断标准:错误信息的"权威来源"在哪一侧 —— 来自服务端响应 → 服务错误,透传;来自本地(OS / Node / CLI 自己)→ 内部错误,包装。

反面 case(为什么这条原则是必要的)

历史上的几个错误处理 bug 都是因为越过了这条边界:

  1. mapApiError 白名单未覆盖 OpenAI 兼容错误码 —— qwen3.7 不存在时服务端返回 invalid_request_error,白名单只认 ModelNotFound,fall through 到 GENERAL,该是 USAGE 信号被丢
  2. bl auth login 用 try/catch 替换错误 —— key 有效但缺模型权限时,显示"API key validation failed"撒谎,误导用户去换 key
  3. error-handler.ts 用 message 关键词归并网络错误 —— ENOTFOUND / ECONNREFUSED / TLS 错误全归并成"Network request failed.",错误根源完全丢失

共同根因:我们试图在没有"权威信息"的位置代理服务端做分类。修复方案是统一退回到透传 + 让本地错误的真实诊断浮上来。

错误流的分层架构

core 抛出 BailianError(message, exitCode, hint, cause?)
  ↓ 沿调用栈冒泡
runtime/create-cli.ts: dispatch().catch(handleError)
  ↓
runtime/error-handler.ts:
  - 服务端错误(BailianError(GENERAL)) → text 直接打 message
  - 内部 AUTH/USAGE/NETWORK/TIMEOUT → 走 enhanceHint(只 AUTH 还有增强)
  - TypeError("fetch failed") → 读 err.cause.code 翻成 NETWORK
  - Node fs errno → 翻成 GENERAL + errno hint
  - `--output json` → stderr 输出两空格缩进的多行 error JSON;前面已有结构化 warning 时,两个 diagnostics 以空行分隔
  - 其它 Error → 默认走 cause 链
  ↓
process.exit(err.exitCode)

Read the full file on GitHub · 133 lines

Changes

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.

  1. yesterday First seen · 133 lines · 0 tokens per session scan A d9e28aa8720e

Subscribe to this mod's changes

error-hint-change is an agent published in the GitHub repository modelstudioai/cli (320 stars, last pushed 4d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,078 tokens. 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-30.