Skip to content

feat(python-client): expose retain_async in retain() and aretain()#1306

Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom
harryplusplus:feat/aretain-async
Apr 29, 2026
Merged

feat(python-client): expose retain_async in retain() and aretain()#1306
nicoloboschi merged 1 commit intovectorize-io:mainfrom
harryplusplus:feat/aretain-async

Conversation

@harryplusplus
Copy link
Copy Markdown
Contributor

Summary

The REST API's /v1/default/banks/{bank_id}/memories endpoint accepts async: bool on every retain request, and both retain_batch() / aretain_batch() already expose this via retain_async: bool = False. However, the single-memory convenience wrappers retain() / aretain() have never exposed it. Since these wrappers simply delegate to the batch methods, there is no technical reason to omit the parameter — users who want async on a single memory today must switch to the batch API, which is an unnecessary friction.

The TypeScript SDK also exposes async?: boolean on its retain() method, so this brings the Python SDK in line.

PR #709 fixed aretain_batch() to actually pass retain_async through to the request model (it was silently dropped before), but the convenience wrappers were left without the parameter.

Changes

Fully backwards compatible — default is False, matching existing behavior.

Test plan

  • Pre-commit hooks pass
  • retain(bank_id, content) and aretain(bank_id, content) bind correctly without the new kwarg
  • New unit tests: 4/4 pass (tests/test_retain_async_kwarg.py)

Both single-memory convenience wrappers now accept retain_async and
forward it to retain_batch() / aretain_batch() respectively.  Default
is False so existing call sites are unaffected.

The REST API's /v1/default/banks/{bank_id}/memories endpoint accepts
async: bool on every retain request, and both batch methods already
expose this via retain_async: bool = False.  Since the convenience
wrappers simply delegate to the batch methods, there is no technical
reason to omit the parameter — users who want async on a single memory
today must switch to the batch API, which is an unnecessary friction.

This brings the Python SDK in line with the TypeScript SDK where
retain() exposes async?: boolean.  PR vectorize-io#709 fixed aretain_batch() to
actually pass retain_async through to the request model (it was
silently dropped before), but the convenience wrappers were left
without the parameter.

Also adds unit tests verifying the kwarg is forwarded to prevent
silent regressions.
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 daae822 into vectorize-io:main Apr 29, 2026
47 of 48 checks passed
r266-tech added a commit to r266-tech/hindsight that referenced this pull request Apr 29, 2026
r266-tech added a commit to r266-tech/hindsight that referenced this pull request Apr 29, 2026
nicoloboschi pushed a commit that referenced this pull request Apr 30, 2026
* docs(python-sdk): document retain_async kwarg per #1306

* docs(python-sdk-mirror): document retain_async kwarg per #1306
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