Skip to content

feat(typescript-client): add AbortSignal support to all HindsightClient methods#1198

Merged
nicoloboschi merged 3 commits intovectorize-io:mainfrom
harryplusplus:feat/typescript-client-abort-signal
May 4, 2026
Merged

feat(typescript-client): add AbortSignal support to all HindsightClient methods#1198
nicoloboschi merged 3 commits intovectorize-io:mainfrom
harryplusplus:feat/typescript-client-abort-signal

Conversation

@harryplusplus
Copy link
Copy Markdown
Contributor

@harryplusplus harryplusplus commented Apr 22, 2026

Summary

Expose per-request AbortSignal support on every public method of the TypeScript HindsightClient. The generated @hey-api/openapi-ts SDK already accepts signal on each request call (its RequestOptions type extends RequestInit), but the high-level HindsightClient wrapper did not surface it to callers.

Motivation

In an agent harness, Hindsight calls (retain, recall, reflect) run under a time budget — best-effort before the next LLM invocation. When a call exceeds the budget, the caller drops the promise and moves on — but without an explicit AbortSignal, the server has no way to know that. It keeps running the full pipeline (fact extraction, embedding, consolidation) for a result no one is waiting for. Passing AbortSignal gives the server the chance to stop when the client is done waiting. Without this change, the only way to pass an AbortSignal is to drop down to the low-level generated sdk namespace.

Changes

hindsight-clients/typescript/src/index.ts

Added signal?: AbortSignal to the options bag of all public methods and forwarded it to the underlying generated SDK call. Formatted with the root .prettierrc.json (trailingComma: es5, printWidth: 100) per the lint.sh that now covers the TypeScript client.

Methods grouped by how they expose the option:

  • Optional-options methods (retain, retainBatch, retainFiles, recall, reflect, listMemories, createDirective, listDirectives, createMentalModel, listMentalModels, listDocuments): signal is an optional field inside the existing options bag.
  • Required-options methods (createBank, updateBankConfig, updateDirective, updateMentalModel, updateDocument): signal added as an optional field alongside the required fields — no breaking change.
  • No-options methods (setMission, getBankProfile, getBankConfig, resetBankConfig, deleteBank, getDirective, deleteDirective, getMentalModel, refreshMentalModel, deleteMentalModel, getMentalModelHistory, getDocument, deleteDocument): accept a new optional options?: { signal?: AbortSignal } parameter — backwards-compatible since it's optional.

hindsight-clients/typescript/tests/main_operations.test.ts

Added TestAbortSignal suite with 3 unit tests that mock the generated SDK and verify the signal is passed through:

  • retain passes abort signal to SDK
  • recall passes abort signal to SDK
  • getBankProfile passes abort signal to SDK

These tests do not require a running Hindsight API server.

skills/hindsight-docs/

Regenerated docs skill files via ./scripts/generate-docs-skill.sh to sync with latest main changes (Oracle storage docs, Pydantic Logfire monitoring link). The verify-generated-files CI job requires these generated files to be up to date.

hindsight-tools/self-driving-agents/src/cli.ts

Applied prettier formatting to fix a multi-line template literal that was inconsistent with the root .prettierrc.json config. Caught by lint.sh in CI where $CI triggers LINT_TOOLS_ALL=1.

Usage Example

import { HindsightClient } from "@vectorize-io/hindsight-client";

const client = new HindsightClient({ baseUrl: "http://localhost:8888" });

// Cancel a long-running retain
const controller = new AbortController();
setTimeout(() => controller.abort(), 5000);

await client.retain("alice", "Alice loves AI", {
  signal: controller.signal,
});

Checklist

  • Rebased onto latest main (v0.5.6)
  • npm run build passes
  • ./scripts/hooks/lint.sh passes (root .prettierrc.json)
  • tsc --noEmit passes
  • Tests added for new behavior (3/3 pass with mocked SDK)
  • No generated code modified (only src/index.ts)
  • No OpenAPI spec changes (no client regeneration needed)
  • ./scripts/generate-docs-skill.sh produces no diff (skills files up to date)
  • ./scripts/hooks/lint.sh produces no diff in CI (all tools formatted)

@harryplusplus harryplusplus force-pushed the feat/typescript-client-abort-signal branch 2 times, most recently from 623b1d1 to 0a67289 Compare April 28, 2026 18:37
harryplusplus added a commit to harryplusplus/hindsight that referenced this pull request Apr 28, 2026
…nt methods (vectorize-io#1198)

* Add signal?: AbortSignal to every public method's options bag so callers
  can cancel in-flight requests without dropping down to the raw SDK.

* Methods with optional options (retain, recall, reflect, listMemories,
  createDirective, listDirectives, createMentalModel, listMentalModels,
  listDocuments): signal is an optional field inside the existing options.

* Methods with required options (createBank, updateBankConfig,
  updateDirective, updateMentalModel, updateDocument): signal added as
  an optional field alongside the required fields.

* Methods that previously took no options (getBankProfile, getBankConfig,
  resetBankConfig, deleteBank, getDirective, deleteDirective, getMentalModel,
  refreshMentalModel, deleteMentalModel, getMentalModelHistory, getDocument,
  deleteDocument): accept an optional options?: { signal?: AbortSignal }.

* Add TestAbortSignal suite with 3 unit tests that mock the generated SDK
  and verify signal is passed through on retain, recall, and getBankProfile.
@harryplusplus harryplusplus force-pushed the feat/typescript-client-abort-signal branch from 9ab1bc9 to 0a67289 Compare April 28, 2026 18:47
…nt methods (vectorize-io#1198)

* Add signal?: AbortSignal to every public method's options bag so callers
  can cancel in-flight requests without dropping down to the raw SDK.

* Methods with optional options (retain, recall, reflect, listMemories,
  createDirective, listDirectives, createMentalModel, listMentalModels,
  listDocuments): signal is an optional field inside the existing options.

* Methods with required options (createBank, updateBankConfig,
  updateDirective, updateMentalModel, updateDocument): signal added as
  an optional field alongside the required fields.

* Methods that previously took no options (getBankProfile, getBankConfig,
  resetBankConfig, deleteBank, getDirective, deleteDirective, getMentalModel,
  refreshMentalModel, deleteMentalModel, getMentalModelHistory, getDocument,
  deleteDocument): accept an optional options?: { signal?: AbortSignal }.

* Add TestAbortSignal suite with 3 unit tests that mock the generated SDK
  and verify signal is passed through on retain, recall, and getBankProfile.
@harryplusplus harryplusplus force-pushed the feat/typescript-client-abort-signal branch from 0a67289 to 4f8a218 Compare May 2, 2026 02:07
harryplusplus added a commit to harryplusplus/hindsight that referenced this pull request May 2, 2026
@harryplusplus harryplusplus force-pushed the feat/typescript-client-abort-signal branch from 4f8a218 to 11d6883 Compare May 2, 2026 02:15
@harryplusplus harryplusplus force-pushed the feat/typescript-client-abort-signal branch from 11d6883 to 8843995 Compare May 2, 2026 02:16
Copy link
Copy Markdown
Collaborator

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nicoloboschi nicoloboschi merged commit 8367930 into vectorize-io:main May 4, 2026
54 checks passed
liling pushed a commit to liling/hindsight that referenced this pull request May 5, 2026
…nt methods (vectorize-io#1198)

* feat(typescript-client): add AbortSignal support to all HindsightClient methods (vectorize-io#1198)

* Add signal?: AbortSignal to every public method's options bag so callers
  can cancel in-flight requests without dropping down to the raw SDK.

* Methods with optional options (retain, recall, reflect, listMemories,
  createDirective, listDirectives, createMentalModel, listMentalModels,
  listDocuments): signal is an optional field inside the existing options.

* Methods with required options (createBank, updateBankConfig,
  updateDirective, updateMentalModel, updateDocument): signal added as
  an optional field alongside the required fields.

* Methods that previously took no options (getBankProfile, getBankConfig,
  resetBankConfig, deleteBank, getDirective, deleteDirective, getMentalModel,
  refreshMentalModel, deleteMentalModel, getMentalModelHistory, getDocument,
  deleteDocument): accept an optional options?: { signal?: AbortSignal }.

* Add TestAbortSignal suite with 3 unit tests that mock the generated SDK
  and verify signal is passed through on retain, recall, and getBankProfile.

* chore(skills): regenerate hindsight-docs skill files

* chore(self-driving-agents): apply prettier formatting
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.

2 participants