feat(typescript-client): add AbortSignal support to all HindsightClient methods#1198
Open
harryplusplus wants to merge 2 commits intovectorize-io:mainfrom
Open
feat(typescript-client): add AbortSignal support to all HindsightClient methods#1198harryplusplus wants to merge 2 commits intovectorize-io:mainfrom
harryplusplus wants to merge 2 commits intovectorize-io:mainfrom
Conversation
Reformat src/index.ts and tests/main_operations.test.ts with the client-local .prettierrc. These files were previously unformatted. No functional changes.
…nt methods Expose per-request AbortSignal on every public method of HindsightClient. The generated @hey-api/openapi-ts SDK already accepts signal on each request call (its RequestOptions type extends RequestInit), but the high-level wrapper did not surface it. Added signal?: AbortSignal to the options bag of all 29 public methods and forwarded it to the underlying generated SDK call. Added TestAbortSignal suite with 3 unit tests that mock the generated SDK and verify the signal is passed through (retain, recall, getBankProfile). These tests do not require a running API server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expose per-request
AbortSignalsupport on every public method of the TypeScriptHindsightClient. The generated@hey-api/openapi-tsSDK already acceptssignalon each request call (itsRequestOptionstype extendsRequestInit), but the high-levelHindsightClientwrapper 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 moves on — but without
AbortSignal, the HTTP request continues in the background on both the client and server, wasting resources. Cancelling early on the client side lets the server stop unnecessary computation (fact extraction, embedding, consolidation) as well. Without this change, the only way to pass anAbortSignalis to drop down to the low-level generatedsdknamespace.Changes
hindsight-clients/typescript/src/index.tsAdded
signal?: AbortSignalto the options bag of all public methods and forwarded it to the underlying generated SDK call:retain,retainBatch,retainFiles,recall,reflectcreateBank,setMission,getBankProfile,getBankConfig,updateBankConfig,resetBankConfig,deleteBankcreateDirective,listDirectives,getDirective,updateDirective,deleteDirectivecreateMentalModel,listMentalModels,getMentalModel,refreshMentalModel,updateMentalModel,deleteMentalModel,getMentalModelHistorygetDocument,listDocuments,deleteDocument,updateDocumentlistMemoriesMethods that already had a required
optionsparameter (e.g.,createBank,updateBankConfig,updateDirective,updateMentalModel,updateDocument) keep it required —signalis added as an optional field inside the existing options object.hindsight-clients/typescript/tests/main_operations.test.tsAdded
TestAbortSignalsuite with 3 unit tests that mock the generated SDK and verify thesignalis passed through:retain passes abort signal to SDKrecall passes abort signal to SDKgetBankProfile passes abort signal to SDKThese tests do not require a running Hindsight API server.
Usage Example
Checklist
mainnpm run buildpassesprettier --writeapplied./scripts/hooks/lint.shpassessrc/index.ts)