Memory Client
agent_memory_hub.client.memory_client.MemoryClient
Client for accessing agent memory with region governance.
Source code in agent_memory_hub/client/memory_client.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
__init__(agent_id, session_id, region=DEFAULT_REGION, region_restricted=True, backend='adk', ttl_seconds=None, alloydb_config=None, redis_config=None, environment='prod')
Initialize the MemoryClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
Unique identifier for the agent. |
required |
session_id
|
str
|
Unique identifier for the session. |
required |
region
|
str
|
The cloud region where memory should be stored/retrieved. |
DEFAULT_REGION
|
region_restricted
|
bool
|
If True, enforces strict region checks. |
True
|
backend
|
str
|
Storage backend ("adk" for GCS, "alloydb" for AlloyDB). |
'adk'
|
ttl_seconds
|
Optional[int]
|
Time-to-live in seconds (None = no expiry). |
None
|
alloydb_config
|
Optional[AlloyDBConfig]
|
AlloyDB configuration (required if backend="alloydb"). |
None
|
redis_config
|
Optional[RedisConfig]
|
Redis configuration (optional if backend="redis"). |
None
|
environment
|
str
|
Environment context (e.g., "prod", "dev") for resource naming. |
'prod'
|
Source code in agent_memory_hub/client/memory_client.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
recall(key='default')
Recall a value from the memory store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key used during write. |
'default'
|
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
The stored value or None if not found. |
Source code in agent_memory_hub/client/memory_client.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
write(value, key='default')
Write a value to the memory store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The data to store. |
required |
key
|
str
|
specific key or context for the memory (e.g., 'episodic', 'semantic'). |
'default'
|
Source code in agent_memory_hub/client/memory_client.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
write_model(memory_model)
Write a semantic memory model to the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_model
|
BaseMemory
|
Pydantic model instance (EpisodicMemory, SemanticMemory, etc.) |
required |
Source code in agent_memory_hub/client/memory_client.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |