fix(agent-core): honor abort signal in WebSearch and FetchURL tools - #1108
fix(agent-core): honor abort signal in WebSearch and FetchURL tools#1108Caldalis wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: a1c5358 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Clean threading of the abort signal through every layer — nice work. Tests covering both providers are solid. One small thing: |
Thanks addressed in a follow-up: MoonshotFetchURLProvider.fetch now rethrows when the caller's signal is aborted, so a cancelled request surfaces as a clean abort instead of kicking off a fallback fetch. Genuine Moonshot failures (network errors) still fall back to the local fetcher as before. Added a test covering the abort doesn't fall back path. |
120345b to
a41a165
Compare
|
I've rebased this onto the latest
|
Thread the turn's AbortSignal through the FetchURL/WebSearch tools and the UrlFetcher / WebSearchProvider interfaces into every underlying fetch, so cancelling a turn aborts the in-flight request instead of leaving it running. Covers the Moonshot fetch/search providers and the local fallback fetcher's per-hop request. A caller-driven abort of the Moonshot fetch is re-thrown instead of retrying the local fallback, so cancellation surfaces cleanly.
a41a165 to
a1c5358
Compare
Related Issue
Resolve #1106
Problem
WebSearchandFetchURLignored the per-callAbortSignal. Cancelling a turn(Ctrl-C / turn abort) did not cancel an in-flight network request — it kept
running in the background, holding a connection, and on a slow or hung server it
lingered until undici's default timeouts.
Every other I/O-bound builtin tool (Bash, Grep, Agent, AskUser) already threads
ctx.signalinto its work; the two web tools were the only exception, with nocomment explaining the omission, so this reads as an overs
intentional choice.
What changed
signalto theUrlFetcherandWebSearchProvideroption objects.FetchURLTool/WebSearchToolnow forwardctx.signal they destructured onlytoolCallId`).LocalFetchURLProvider,MoonshotFetchURLProvider, andMoonshotWebSearchProviderpass the signal to the underlyingfetch(), which aborts both the header wait and the body read. The Moonshot → loc options object, so the signal flows through automatically.fetch.This matches the existing cancellation pattern used by Bash/Grep/Agent and keeps the change focused. The touched interfaces (
UrlFetcher/WebSearchProvider) are internal toagent-coreand are rface.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update