Skip to content

feat(gateway): the gateway speaks English, and its errors carry a code - #54

Merged
fylorn merged 1 commit into
mainfrom
i18n/gateway-errors
Sep 20, 2026
Merged

fylorn merged 1 commit into
mainfrom
i18n/gateway-errors

Conversation

@fylorn

@fylorn fylorn commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Everything the gateway said about a failure was Chinese: the body a Claude Code
or Codex session prints when a request is refused, and the RequestFailed event
the desktop app renders in its traffic table. Neither audience is reliably
Chinese-reading, and the app has to say it in whichever of its two languages is
in use.

GatewayError carries a Msg instead of a String, and so does
Event::RequestFailed. The sentence that reaches an AI client is detail.text,
in English, behind the [ThinkWatch] prefix it always had; the app reads
detail.code and says it in its own words. About fifty messages carry a code
now, from gw.auth.key_disabled to gw.toolcall.cut.

Two that stopped being strings in a more useful way

The failover chain used to be pasted onto the end of the message:

err.message = format!("{}(已尝试:{})", err.message, attempts.join(" → "));

It is with_attempts now, which leaves the code alone and puts the chain in
args, so an app can put it where its own sentence wants it.

A stream that breaks mid-flight keeps the code of whatever broke it and only
prefixes the English text, instead of becoming a new, codeless
"响应流中断:…".

The rest of the crate

English too: the thiserror messages in access, limits and oauth; the
ChatGPT sign-in and token paths; the probe and inference-test results; the tool
wall's (unnamed) and (response text); the fixture replay's field names;
every tracing line and every expect. crates/tw-gateway/src no longer
contains a Chinese string literal.

tw-store writes message.text to the history row, so a row's error column
is English now — the app renders a row from the event, not from that column.

Tests

Tests that read a message read a code where one exists
(assert_eq!(e.detail.code, "gw.config.proxy_undefined")), which is shorter and
no longer breaks when a sentence is reworded. The no-key test also checks the
key never reaches args, not only the text.

Still Chinese

Everything outside tw-gateway: tw-control, tw-adopt, tw-config,
tw-scan, tw-engine and the twcore CLI.

Verified

cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (78 suites, 0 failures) and
./scripts/smoke.sh (51 passed, 0 failed). The smoke script's check that a cut
request is recorded with its usage reads the English text now.

🤖 Generated with Claude Code

Everything the gateway said about a failure was Chinese: the body a
Claude Code or Codex session prints when a request is refused, and the
`RequestFailed` event the desktop app renders in its traffic table.
Neither audience is reliably Chinese-reading, and the app has to say it
in whichever of its two languages is in use.

`GatewayError` carries a `Msg` instead of a `String`, and so does
`Event::RequestFailed`. The sentence that reaches an AI client is
`detail.text`, in English, behind the `[ThinkWatch]` prefix it always
had; the app reads `detail.code` and says it in its own words. About
fifty messages carry a code now, from `gw.auth.key_disabled` to
`gw.toolcall.cut`.

Two of them stopped being strings in a more useful way:

- The failover chain used to be pasted onto the end of the message
  (`"…(已尝试:a → b)"`). It is `with_attempts`, which leaves the code
  alone and puts the chain in `args`, so an app can put it where its own
  sentence wants it.
- A stream that breaks mid-flight keeps the code of whatever broke it
  and only prefixes the English text, instead of becoming a new,
  codeless "响应流中断:…".

The rest of the crate is English too: the `thiserror` messages in
`access`, `limits` and `oauth`; the ChatGPT sign-in and token paths; the
probe and inference-test results; the tool wall's "(unnamed)" and
"(response text)"; the fixture replay's field names; every `tracing`
line and every `expect`. `crates/tw-gateway/src` no longer contains a
Chinese string literal.

`tw-store` writes `message.text` to the history row, so a row's `error`
column is English now — the app renders a row from the event, not from
that column.

Tests that read a message read a code where one exists
(`assert_eq!(e.detail.code, "gw.config.proxy_undefined")`), which is
shorter and no longer breaks when a sentence is reworded. The no-key
test also checks the key never reaches `args`, not only the text.

Still Chinese, and not in this change: everything outside `tw-gateway`
— `tw-control`, `tw-adopt`, `tw-config`, `tw-scan`, `tw-engine` and the
`twcore` CLI.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 9353ec9 into main Sep 20, 2026
1 check passed
@fylorn
fylorn deleted the i18n/gateway-errors branch September 20, 2026 05:26
This was referenced Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant