Skip to content

Commit cf0948f

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Allow Memory Revisions to be disabled
feat: Support TTL (per Memory Bank and per-request) for Memory Revisions PiperOrigin-RevId: 819923595
1 parent 9d1cd6e commit cf0948f

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

vertexai/_genai/memories.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ def _AgentEngineMemoryConfig_to_vertex(
5555
if getv(from_object, ["expire_time"]) is not None:
5656
setv(parent_object, ["expireTime"], getv(from_object, ["expire_time"]))
5757

58+
if getv(from_object, ["revision_expire_time"]) is not None:
59+
setv(
60+
parent_object,
61+
["revisionExpireTime"],
62+
getv(from_object, ["revision_expire_time"]),
63+
)
64+
65+
if getv(from_object, ["revision_ttl"]) is not None:
66+
setv(parent_object, ["revisionTtl"], getv(from_object, ["revision_ttl"]))
67+
68+
if getv(from_object, ["disable_memory_revisions"]) is not None:
69+
setv(
70+
parent_object,
71+
["disableMemoryRevisions"],
72+
getv(from_object, ["disable_memory_revisions"]),
73+
)
74+
5875
return to_object
5976

6077

@@ -114,6 +131,23 @@ def _GenerateAgentEngineMemoriesConfig_to_vertex(
114131
if getv(from_object, ["revision_labels"]) is not None:
115132
setv(parent_object, ["revisionLabels"], getv(from_object, ["revision_labels"]))
116133

134+
if getv(from_object, ["revision_expire_time"]) is not None:
135+
setv(
136+
parent_object,
137+
["revisionExpireTime"],
138+
getv(from_object, ["revision_expire_time"]),
139+
)
140+
141+
if getv(from_object, ["revision_ttl"]) is not None:
142+
setv(parent_object, ["revisionTtl"], getv(from_object, ["revision_ttl"]))
143+
144+
if getv(from_object, ["disable_memory_revisions"]) is not None:
145+
setv(
146+
parent_object,
147+
["disableMemoryRevisions"],
148+
getv(from_object, ["disable_memory_revisions"]),
149+
)
150+
117151
return to_object
118152

119153

@@ -314,6 +348,23 @@ def _UpdateAgentEngineMemoryConfig_to_vertex(
314348
if getv(from_object, ["expire_time"]) is not None:
315349
setv(parent_object, ["expireTime"], getv(from_object, ["expire_time"]))
316350

351+
if getv(from_object, ["revision_expire_time"]) is not None:
352+
setv(
353+
parent_object,
354+
["revisionExpireTime"],
355+
getv(from_object, ["revision_expire_time"]),
356+
)
357+
358+
if getv(from_object, ["revision_ttl"]) is not None:
359+
setv(parent_object, ["revisionTtl"], getv(from_object, ["revision_ttl"]))
360+
361+
if getv(from_object, ["disable_memory_revisions"]) is not None:
362+
setv(
363+
parent_object,
364+
["disableMemoryRevisions"],
365+
getv(from_object, ["disable_memory_revisions"]),
366+
)
367+
317368
if getv(from_object, ["update_mask"]) is not None:
318369
setv(
319370
parent_object, ["_query", "updateMask"], getv(from_object, ["update_mask"])

vertexai/_genai/types.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4475,6 +4475,10 @@ class ReasoningEngineContextSpecMemoryBankConfigTtlConfig(_common.BaseModel):
44754475
default=None,
44764476
description="""Optional. The granular TTL configuration of the memories in the Memory Bank.""",
44774477
)
4478+
memory_revision_default_ttl: Optional[str] = Field(
4479+
default=None,
4480+
description="""Optional. The default TTL duration of the memory revisions in the Memory Bank. This applies to all operations that create a memory revision. If not set, a default TTL of 365 days will be used.""",
4481+
)
44784482

44794483

44804484
class ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict(TypedDict, total=False):
@@ -4488,6 +4492,9 @@ class ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict(TypedDict, total=F
44884492
]
44894493
"""Optional. The granular TTL configuration of the memories in the Memory Bank."""
44904494

4495+
memory_revision_default_ttl: Optional[str]
4496+
"""Optional. The default TTL duration of the memory revisions in the Memory Bank. This applies to all operations that create a memory revision. If not set, a default TTL of 365 days will be used."""
4497+
44914498

44924499
ReasoningEngineContextSpecMemoryBankConfigTtlConfigOrDict = Union[
44934500
ReasoningEngineContextSpecMemoryBankConfigTtlConfig,
@@ -4518,6 +4525,10 @@ class ReasoningEngineContextSpecMemoryBankConfig(_common.BaseModel):
45184525
default=None,
45194526
description="""Optional. Configuration for automatic TTL ("time-to-live") of the memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource.""",
45204527
)
4528+
disable_memory_revisions: Optional[bool] = Field(
4529+
default=None,
4530+
description="""If true, no memory revisions will be created for any requests to the Memory Bank.""",
4531+
)
45214532

45224533

45234534
class ReasoningEngineContextSpecMemoryBankConfigDict(TypedDict, total=False):
@@ -4539,6 +4550,9 @@ class ReasoningEngineContextSpecMemoryBankConfigDict(TypedDict, total=False):
45394550
ttl_config: Optional[ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict]
45404551
"""Optional. Configuration for automatic TTL ("time-to-live") of the memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource."""
45414552

4553+
disable_memory_revisions: Optional[bool]
4554+
"""If true, no memory revisions will be created for any requests to the Memory Bank."""
4555+
45424556

45434557
ReasoningEngineContextSpecMemoryBankConfigOrDict = Union[
45444558
ReasoningEngineContextSpecMemoryBankConfig,
@@ -5400,6 +5414,18 @@ class AgentEngineMemoryConfig(_common.BaseModel):
54005414
default=None,
54015415
description="""Optional. Timestamp of when this resource is considered expired. This is *always* provided on output, regardless of what `expiration` was sent on input.""",
54025416
)
5417+
revision_expire_time: Optional[datetime.datetime] = Field(
5418+
default=None,
5419+
description="""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted.""",
5420+
)
5421+
revision_ttl: Optional[str] = Field(
5422+
default=None,
5423+
description="""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL.""",
5424+
)
5425+
disable_memory_revisions: Optional[bool] = Field(
5426+
default=None,
5427+
description="""Optional. Input only. If true, no revision will be created for this request.""",
5428+
)
54035429

54045430

54055431
class AgentEngineMemoryConfigDict(TypedDict, total=False):
@@ -5425,6 +5451,15 @@ class AgentEngineMemoryConfigDict(TypedDict, total=False):
54255451
expire_time: Optional[datetime.datetime]
54265452
"""Optional. Timestamp of when this resource is considered expired. This is *always* provided on output, regardless of what `expiration` was sent on input."""
54275453

5454+
revision_expire_time: Optional[datetime.datetime]
5455+
"""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted."""
5456+
5457+
revision_ttl: Optional[str]
5458+
"""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL."""
5459+
5460+
disable_memory_revisions: Optional[bool]
5461+
"""Optional. Input only. If true, no revision will be created for this request."""
5462+
54285463

54295464
AgentEngineMemoryConfigOrDict = Union[
54305465
AgentEngineMemoryConfig, AgentEngineMemoryConfigDict
@@ -5494,6 +5529,18 @@ class Memory(_common.BaseModel):
54945529
default=None,
54955530
description="""Optional. Input only. The TTL for this resource. The expiration time is computed: now + TTL.""",
54965531
)
5532+
revision_expire_time: Optional[datetime.datetime] = Field(
5533+
default=None,
5534+
description="""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted.""",
5535+
)
5536+
revision_ttl: Optional[str] = Field(
5537+
default=None,
5538+
description="""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL.""",
5539+
)
5540+
disable_memory_revisions: Optional[bool] = Field(
5541+
default=None,
5542+
description="""Optional. Input only. If true, no revision will be created for this request.""",
5543+
)
54975544
create_time: Optional[datetime.datetime] = Field(
54985545
default=None,
54995546
description="""Output only. Timestamp when this Memory was created.""",
@@ -5531,6 +5578,15 @@ class MemoryDict(TypedDict, total=False):
55315578
ttl: Optional[str]
55325579
"""Optional. Input only. The TTL for this resource. The expiration time is computed: now + TTL."""
55335580

5581+
revision_expire_time: Optional[datetime.datetime]
5582+
"""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted."""
5583+
5584+
revision_ttl: Optional[str]
5585+
"""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL."""
5586+
5587+
disable_memory_revisions: Optional[bool]
5588+
"""Optional. Input only. If true, no revision will be created for this request."""
5589+
55345590
create_time: Optional[datetime.datetime]
55355591
"""Output only. Timestamp when this Memory was created."""
55365592

@@ -5844,6 +5900,18 @@ class GenerateAgentEngineMemoriesConfig(_common.BaseModel):
58445900
default=None,
58455901
description="""Labels to apply to the memory revision. For example, you can use this to label a revision with its data source.""",
58465902
)
5903+
revision_expire_time: Optional[datetime.datetime] = Field(
5904+
default=None,
5905+
description="""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted.""",
5906+
)
5907+
revision_ttl: Optional[str] = Field(
5908+
default=None,
5909+
description="""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL.""",
5910+
)
5911+
disable_memory_revisions: Optional[bool] = Field(
5912+
default=None,
5913+
description="""Optional. Input only. If true, no revisions will be created for this request.""",
5914+
)
58475915

58485916

58495917
class GenerateAgentEngineMemoriesConfigDict(TypedDict, total=False):
@@ -5866,6 +5934,15 @@ class GenerateAgentEngineMemoriesConfigDict(TypedDict, total=False):
58665934
revision_labels: Optional[dict[str, str]]
58675935
"""Labels to apply to the memory revision. For example, you can use this to label a revision with its data source."""
58685936

5937+
revision_expire_time: Optional[datetime.datetime]
5938+
"""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted."""
5939+
5940+
revision_ttl: Optional[str]
5941+
"""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL."""
5942+
5943+
disable_memory_revisions: Optional[bool]
5944+
"""Optional. Input only. If true, no revisions will be created for this request."""
5945+
58695946

58705947
GenerateAgentEngineMemoriesConfigOrDict = Union[
58715948
GenerateAgentEngineMemoriesConfig, GenerateAgentEngineMemoriesConfigDict
@@ -6588,6 +6665,18 @@ class UpdateAgentEngineMemoryConfig(_common.BaseModel):
65886665
default=None,
65896666
description="""Optional. Timestamp of when this resource is considered expired. This is *always* provided on output, regardless of what `expiration` was sent on input.""",
65906667
)
6668+
revision_expire_time: Optional[datetime.datetime] = Field(
6669+
default=None,
6670+
description="""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted.""",
6671+
)
6672+
revision_ttl: Optional[str] = Field(
6673+
default=None,
6674+
description="""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL.""",
6675+
)
6676+
disable_memory_revisions: Optional[bool] = Field(
6677+
default=None,
6678+
description="""Optional. Input only. If true, no revision will be created for this request.""",
6679+
)
65916680
update_mask: Optional[str] = Field(
65926681
default=None,
65936682
description="""The update mask to apply. For the `FieldMask` definition, see
@@ -6618,6 +6707,15 @@ class UpdateAgentEngineMemoryConfigDict(TypedDict, total=False):
66186707
expire_time: Optional[datetime.datetime]
66196708
"""Optional. Timestamp of when this resource is considered expired. This is *always* provided on output, regardless of what `expiration` was sent on input."""
66206709

6710+
revision_expire_time: Optional[datetime.datetime]
6711+
"""Optional. Input only. Timestamp of when the revision is considered expired. If not set, the memory revision will be kept until manually deleted."""
6712+
6713+
revision_ttl: Optional[str]
6714+
"""Optional. Input only. The TTL for the revision. The expiration time is computed: now + TTL."""
6715+
6716+
disable_memory_revisions: Optional[bool]
6717+
"""Optional. Input only. If true, no revision will be created for this request."""
6718+
66216719
update_mask: Optional[str]
66226720
"""The update mask to apply. For the `FieldMask` definition, see
66236721
https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask."""

0 commit comments

Comments
 (0)