generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 73
feat(memory): update session manager for Strands integration #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akshseh
wants to merge
5
commits into
aws:main
Choose a base branch
from
akshseh:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+545
−370
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f76f2c
feat(memory): update session manager.
akshseh 58ed5f7
fix(session_manager): update session_manager
akshseh 40f319c
Merge branch 'aws:main' into main
akshseh ec7eea3
feat(session_manager): update create_session functionality
akshseh dcba595
Merge branch 'main' of https://github.com/akshseh/bedrock-agentcore-s…
akshseh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,27 @@ | ||
| """Configuration for AgentCore Memory Session Manager.""" | ||
|
|
||
| from typing import Dict, Optional | ||
| from typing import Dict, List, Optional | ||
|
|
||
| from pydantic import BaseModel, Field | ||
| from pydantic import BaseModel, Field, field_validator | ||
|
|
||
| from bedrock_agentcore.memory.constants import MessageRole | ||
| from bedrock_agentcore.memory.models import StringValue | ||
|
|
||
|
|
||
| class BranchConfig(BaseModel): | ||
| """Configuration for AgentCore Memory branching. | ||
|
|
||
| Attributes: | ||
| name: Descriptive name for the branch | ||
| root_event_id: ID of the event from which this branch originates | ||
| """ | ||
|
|
||
| name: str = Field(min_length=1) | ||
| root_event_id: Optional[str] = "" | ||
|
|
||
| def to_agentcore_format(self) -> dict: | ||
| """Convert to AgentCore Memory API format.""" | ||
| return {"name": self.name, "rootEventId": self.root_event_id} | ||
|
|
||
|
|
||
| class RetrievalConfig(BaseModel): | ||
|
|
@@ -21,6 +40,13 @@ class RetrievalConfig(BaseModel): | |
| initialization_query: Optional[str] = None | ||
|
|
||
|
|
||
| class ShortTermRetrievalConfig(BaseModel): | ||
| """Configuration for Short term memory retrieval operations""" | ||
|
|
||
| branch_filter: Optional[bool] = True | ||
| metadata: Optional[Dict[str, StringValue]] = None | ||
|
|
||
|
|
||
| class AgentCoreMemoryConfig(BaseModel): | ||
| """Configuration for AgentCore Memory Session Manager. | ||
|
|
||
|
|
@@ -29,9 +55,29 @@ class AgentCoreMemoryConfig(BaseModel): | |
| session_id: Required unique ID for the session | ||
| actor_id: Required unique ID for the agent instance/user | ||
| retrieval_config: Optional dictionary mapping namespaces to retrieval configurations | ||
| default_branch: Optional default branch configuration for the session | ||
| message_types: Optional list of message types to filter | ||
| metadata: Optional dictionary of metadata to include with events | ||
| """ | ||
|
|
||
| memory_id: str = Field(min_length=1) | ||
| session_id: str = Field(min_length=1) | ||
| actor_id: str = Field(min_length=1) | ||
| retrieval_config: Optional[Dict[str, RetrievalConfig]] = None | ||
| default_branch: Optional[BranchConfig] = Field( | ||
| default_factory=lambda: BranchConfig(name="main", root_event_id="") | ||
| ) | ||
| short_term_retrieval_config: Optional[ShortTermRetrievalConfig] = ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this needs it's own variable? Can we allow for this to be set to the |
||
| ShortTermRetrievalConfig() | ||
| ) | ||
| message_types: Optional[List[str]] = Field(default=["user", "assistant"]) | ||
| metadata: Optional[Dict[str, StringValue]] = ( | ||
| None # Currently only supports agent_id. Will be extended further. | ||
| ) | ||
|
|
||
| @field_validator("memory_id", "session_id", "actor_id") | ||
| @classmethod | ||
| def validate_non_empty_strings(cls, v: str) -> str: | ||
| if not v or not v.strip(): | ||
| raise ValueError("must be a non-empty string") | ||
| return v | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a plan to have branching on LTM? We can refactor later but then we should consider lifting the
branch_filterinto a base class