Skip to content

fix(web): make web_search and web_fetch errors actionable#632

Merged
esengine merged 2 commits into
esengine:mainfrom
dimasd-angga:fix/issue-16-make-web-search-web-fetch-errors-actiona
May 11, 2026
Merged

fix(web): make web_search and web_fetch errors actionable#632
esengine merged 2 commits into
esengine:mainfrom
dimasd-angga:fix/issue-16-make-web-search-web-fetch-errors-actiona

Conversation

@dimasd-angga

Copy link
Copy Markdown

Summary

Errors thrown by web_search and web_fetch previously surfaced as bare status codes or terse refusals (web_search 429, web_fetch: url must start with http:// or https://), giving the model no signal about what to do next. Each error path now appends a short — try: … tail tailored to the failure mode so the model can self-correct (back off on 429, switch engine on 403, pick a smaller URL on oversize, etc.) without a human in the loop.

Changes

  • src/tools/web.ts: add searchStatusError / fetchStatusError helpers that branch on 429 and 403 and fall back to the generic status template; route the non-2xx throws in searchMojeek, searchSearxng, and webFetch through them.
  • src/tools/web.ts: track a timedOut flag around the internal AbortController in webFetch so a timer-driven abort throws the new fetchTimeout message (with {ms} and {url}), while a caller-cancelled abort re-throws unchanged.
  • src/i18n/EN.ts and src/i18n/zh-CN.ts: append — try: … tails to every existing webErrors template (status, mojeekBlocked, mojeekNoResults, invalidEndpoint, endpointMustBeHttp, cannotReach, searxngNoResults, fetchStatus, fetchTooLarge, fetchBodyTooLarge, fetchInvalidUrl) and add three new keys: rateLimit429, forbidden403, fetchRateLimit429, fetchForbidden403, fetchTimeout.
  • src/i18n/types.ts: extend the webErrors interface with the new keys so both locales stay in sync under the existing TranslationSchema typing.
  • tests/web-tools.test.ts: add coverage asserting the new tails — 429 returns the wait-and-retry hint, 403 returns the switch-engine hint on search and the bot-block hint on fetch, and the existing non-2xx test still matches its /web_search 429/ prefix.

Testing

npm run test -- web — the targeted web-tools suite passes, including the existing non-2xx assertion (the web_search 429 prefix is preserved ahead of the new tail) and the three new hint assertions.

Notes

The 429 and 403 branches are split out as their own keys rather than formatted inline so translators can tune the wording per locale; the generic status / fetchStatus templates still cover every other non-2xx code. The timedOut flag is deliberately scoped so only the internal timer produces the timeout hint — an Esc-driven caller abort still propagates as-is.

Closes #16

Bare HTTP status codes and terse refusal messages gave the model no signal about what to do next, leading it to either retry blindly or abandon the tool. Each error now carries a short " — try: …" tail tailored to the failure mode (429 backoff, 403 client-block, timeout, oversize body, unreachable SearXNG, invalid URL) so the model can self-correct without a human in the loop.
Biome's formatter flagged the existing single-line `expect(...).rejects.toThrow(...)` calls as needing the multi-line layout. Reformat to satisfy the formatter so `npm run lint` is clean.
@esengine esengine merged commit 8aed207 into esengine:main May 11, 2026
3 checks passed
@esengine esengine mentioned this pull request May 11, 2026
6 tasks
esengine added a commit that referenced this pull request May 11, 2026
Hotfix for 0.39.0 install failure: the `postinstall: patch-package`
hook + missing `patch-package` runtime dep + missing `patches/` in the
files array meant fresh `npm install` / `npx reasonix@latest` runs
crashed before the binary was usable. 0.39.0 has been deprecated on
npm and `latest` rolled back to 0.38.0.

Removes the patch-package machinery entirely — it can't work for a
published library since npm hoists `ink` out of reasonix's own
`node_modules`. The ink alt-screen render fix (#639) will return via
a forked ink + `npm:` alias (#663) in a later release.

Piggybacks three PRs that landed since 0.39.0:
- #632 fix(web): actionable web_search / web_fetch errors
- #661 feat(composer): Ctrl+X opens \$EDITOR
- #662 feat(composer): Ctrl+P / Ctrl+N picker navigation
esengine added a commit that referenced this pull request May 11, 2026
)

#632 actionable-error work stopped at 429 + 403 — generic 5xx still
fell through to the catch-all "rephrase the query / switch engine"
message, which is the wrong advice for a transient server-side
failure. Add serverError5xx + fetchServerError5xx pointing the model
at a browser sanity-check and a 30s retry instead.

Existing webSearch 503 test tightened from `/web_search 503.*try:/`
to assert on the new `retry in 30s` substring; a parallel webFetch
502 test added in the same shape.

Credit to @MyPrototypeWhat#671 surfaced the gap and the 503 test
case lands with this PR.
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
* fix(web): make web_search and web_fetch errors actionable

Bare HTTP status codes and terse refusal messages gave the model no signal about what to do next, leading it to either retry blindly or abandon the tool. Each error now carries a short " — try: …" tail tailored to the failure mode (429 backoff, 403 client-block, timeout, oversize body, unreachable SearXNG, invalid URL) so the model can self-correct without a human in the loop.

* style(tests): reformat web-tools assertions for biome

Biome's formatter flagged the existing single-line `expect(...).rejects.toThrow(...)` calls as needing the multi-line layout. Reformat to satisfy the formatter so `npm run lint` is clean.
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
Hotfix for 0.39.0 install failure: the `postinstall: patch-package`
hook + missing `patch-package` runtime dep + missing `patches/` in the
files array meant fresh `npm install` / `npx reasonix@latest` runs
crashed before the binary was usable. 0.39.0 has been deprecated on
npm and `latest` rolled back to 0.38.0.

Removes the patch-package machinery entirely — it can't work for a
published library since npm hoists `ink` out of reasonix's own
`node_modules`. The ink alt-screen render fix (esengine#639) will return via
a forked ink + `npm:` alias (esengine#663) in a later release.

Piggybacks three PRs that landed since 0.39.0:
- esengine#632 fix(web): actionable web_search / web_fetch errors
- esengine#661 feat(composer): Ctrl+X opens \$EDITOR
- esengine#662 feat(composer): Ctrl+P / Ctrl+N picker navigation
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…sengine#676)

esengine#632 actionable-error work stopped at 429 + 403 — generic 5xx still
fell through to the catch-all "rephrase the query / switch engine"
message, which is the wrong advice for a transient server-side
failure. Add serverError5xx + fetchServerError5xx pointing the model
at a browser sanity-check and a 30s retry instead.

Existing webSearch 503 test tightened from `/web_search 503.*try:/`
to assert on the new `retry in 30s` substring; a parallel webFetch
502 test added in the same shape.

Credit to @MyPrototypeWhatesengine#671 surfaced the gap and the 503 test
case lands with this PR.
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.

Make web_search / web_fetch errors actionable

2 participants