feat(memory): use List Observations API for memory_mode="once" - #98
Open
bsahajsinghani wants to merge 1 commit into
Open
feat(memory): use List Observations API for memory_mode="once"#98bsahajsinghani wants to merge 1 commit into
bsahajsinghani wants to merge 1 commit into
Conversation
memory_mode="once" now fetches all observations via the List Observations
API (GET /Profiles/{id}/Observations) instead of the Recall API. This
avoids semantic search overhead (~750ms) on every call start and enables
LLM prefix caching since the memory block is static across turns.
memory_mode="always" is unchanged — it continues to use the Recall API
with the user's per-turn query for semantic relevance.
Observation count is configurable via TWILIO_MEMORY_OBSERVATIONS_LIMIT
env var (default 20, max 500). Example: TWILIO_MEMORY_OBSERVATIONS_LIMIT=500
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bsahajsinghani
requested review from
ryanrishi,
ryanrouleau and
xinghaohuang91
as code owners
August 4, 2026 20:57
wenzhu1587
reviewed
Aug 13, 2026
| async def list_observations( | ||
| self, | ||
| profile_id: str, | ||
| limit: int = 500, |
Contributor
There was a problem hiding this comment.
do we need the max number here? any latency implications with this number setting this high?
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
memory_mode="once"now fetches all observations via the List Observations API (GET /Profiles/{id}/Observations) instead of the Recall APImemory_mode="always"is unchanged — continues to use the Recall API with per-turn semantic searchTWILIO_MEMORY_OBSERVATIONS_LIMITenv var (default 20, max 500)Why
The Recall API runs a semantic vector search on every call. For
"once"mode — where the intent is to fetch everything upfront and cache it — this is the wrong tool:The List Observations API fetches a flat list of all observations with no semantic search, making the cached memory block static and predictable across turns — enabling prefix caching on voice calls.
API reference: https://www.twilio.com/docs/api/memory/v1/observations/list-profile-observations
Changes
src/tac/context/memory.py— addslist_observations()method onMemoryClientsrc/tac/core/tac.py— addslist_observations()onTACclass with profile resolutionsrc/tac/channels/base.py—"once"mode callstac.list_observations()instead oftac.retrieve_memory()Test plan
make testpasses (692 tests)make type-checkpasses (no new errors)memory_mode="once"and verify List API is called once at call start and cachedmemory_mode="always"and verify Recall API is still used per turn