Skip to content

forgetMemoryRequest drops its 30s timeout whenever a caller passes a signal #1549

Description

@rajarshidattapy

Severity: Low (latent — defeats the fix from #1451)
File: packages/tools/src/shared/forget-memory.ts:35

Description

#1451 ("fix(tools): bound memory forget requests") added a 30-second abort so
a hung DELETE /v4/memories can't wedge the tool call. The two signals are
combined with ??, so they're mutually exclusive:

signal: options?.signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS),

Pass a cancellation signal and the request becomes unbounded again — exactly the
condition the commit set out to remove. A caller who wants both cancellation
and a timeout has no way to express it through this API.

No production call site passes options today (ai-sdk.ts:332 and
openai/tools.ts:490 both omit it), so this is latent rather than live. It
becomes a real hang the first time someone wires up cancellation.

Suggested fix

Compose the two instead of choosing between them:

signal: options?.signal
    ? AbortSignal.any([options.signal, AbortSignal.timeout(FETCH_TIMEOUT_MS)])
    : AbortSignal.timeout(FETCH_TIMEOUT_MS),

AbortSignal.any is available in Node 20+ (the repo's engines floor), Bun,
and workerd. packages/tools/src/tool-operations.test.ts already exercises the
signal path, so a case asserting the timeout still fires with a caller signal
present is a one-line addition.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions