You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AgentCoreSessionService extending BaseSessionService for AgentCore Memory #6920
Is your feature request related to a specific problem?
I'm trying to use AWS AgentCore Memory with an ADK Agent.
Describe the Solution You'd Like
The session_serivce is a required param in the adk Agent so it would be nice if there was an implementation for AgentCore Memory.
As for the implementation, two things caught my eyes so far:
Session
There isn't an exact session translation to agentcore memory so need to think about that.
Events and Short-term memory
STM is where events are saved (user message, llm response) in AgentCore memory. In adk they are more fine-grained, but in agentcore they represent a turn - user message is one and what the agent responded is another - maybe we can construct a whole event that consists of all the little ADK events and then flush those to agentcore's short-term memory as, what aws calls, an event.
Impact on your work
No timeline but would make it easier. This will allow for better integration with AWS AgentCore memory
Willingness to contribute
Are you interested in implementing this feature yourself or submitting a PR?
Yes, I am happy to work on an implementation myself
Hi @divakaivan , Thanks for bringing this and taking time to raise a PR. Your request is currently being reviewed, and we will let you know if anything further is needed. We appreciate your contribution.
I created a basic PoC here. Works... on a basic level - the memories are created from user messages saved messages. But will see as I use/test it more. And would appreciate feedback 🙏
Hi @divakaivan — thank you for writing this up, and especially for sharing the PoC. I went through agentcore_session_service carefully before touching ADK, and the design you landed on is what this is built from. I wanted to say that plainly, because the hard part of this issue was never “call boto3”; it was the session translation you already worked through.
Your README and session.py are what I treated as the spec:
What I kept from your PoC
There is no AgentCore session object, so ADK Session is a mapping, not a 1:1 resource. create_session cannot be a real create on their side.
Short-term memory is where the turns live. You were right that ADK events are finer-grained than an AgentCore event, and that the practical approach is to flush each complete ADK event as one AgentCore event rather than inventing a different turn type.
The dual payload is the piece that makes this actually work: a conversational item (USER / ASSISTANT / TOOL) so AgentCore can extract from the text, and a blob of the full ADK Event JSON so get_session can rebuild history without dropping tool calls, state, or metadata. That is exactly the shape in your example payload, and I did not replace it.
Reconstructing ADK events by walking the payload for a JSON blob and Event.model_validate_json.
Paginated list_events / list_sessions on the bedrock-agentcore client, with boto3 calls off the event loop via asyncio.to_thread.
delete_session has no API on their side. You noted they charge for creates, not storage, and left it as a no-op for the PoC. I kept that constraint in mind; in the ADK class I did implement delete by deleting the events in that session, only because BaseSessionService.delete_session is part of the contract runners actually call. Happy to hear if you would rather that stay a no-op.
What I added so it can sit next to Redis/Firestore as an ADK integration
Your PoC is a working runner script, which is the right way to learn the API. For google.adk.integrations.agentcore I had to cover the rest of BaseSessionService so Runner does not surprise people:
Generate a session id when the caller does not pass one.
get_session returns None when the session was never written (your getter always returned a Session, which is correct for a PoC and a bit loose for the ADK method signature).
AlreadyExistsError on a duplicate create_session.
Skip partial=True events. BaseSessionService.append_event already returns those without appending; your override still called create_event afterward, so streaming chunks would have been written to STM. I only flush after the base class accepts the event.
A bootstrap blob on create_session (extractionMode=SKIP) so the session exists in AgentCore before the first user message. AgentCore drops empty sessions after about a day, and without this get_session / list_sessions right after create would not see anything.
actorId = {app_name}:{user_id} instead of user_id alone, so two ADK apps sharing one Memory resource do not mix. Your PoC did not need that because it is one app. If you would rather keep actorId = user_id for compatibility with memories you already wrote, that is a fair objection.
list_sessions without user_id (via list_actors), oldest-first, events stripped on the listing as the base class documents.
Session state round-trip by replaying state_delta from the restored events (temp: keys are not persisted, same as the other backends). App/user-scoped state is not shared across sessions the way Redis does; I called that out as a limitation rather than pretending AgentCore has those extra documents.
Lazy boto3 import, injectable client, google-adk[agentcore] extra, unit tests against a fake client (12 passed), and a short developer guide.
The code lives in src/google/adk/integrations/agentcore/ on #6944. I tried to keep your names and your payload shape so it still reads as your mapping, just fitted to the ADK service interface.
I am sure I have missed things you will hit once you keep using this against a real Memory resource — you said the PoC works on a basic level and you wanted to test it more, and that still matters more than the unit tests. If the actor namespacing, the bootstrap event, or deleting via delete_event is the wrong call for how you use STM, I would rather hear that from you than guess. Thank you again for putting the PoC up; this would have been a much worse first cut without it.
You already have the issue, and @divakaivan’s PoC is what the implementation follows. The ADK-shaped version is in #6944 (AgentCoreSessionService under integrations/agentcore). I would be grateful for a maintainer pass whenever it fits your queue. No rush, and thank you for the time.
hi @divakaivan, thanks for putting together the poc, and thanks @a2105z for picking it up in #6944. we've decided not to merge #6944 because agentcore short-term memory is an append-only event stream, which maps better to BaseMemoryService than BaseSessionService, and we're keeping core adk limited to integrations with broad adoption. this would live much better as a standalone package, and you can add it to the catalog at https://adk.dev/integrations/ with a docs page in google/adk-docs. thanks again to both of you for the work here.
Activity
[-]AgentCoreSessionService[/-][+]AgentCoreSessionService extending BaseSessionService for AgentCore Memory[/+]sanketpatil06 commentedon Aug 27, 2026
Hi @divakaivan , Thanks for bringing this and taking time to raise a PR. Your request is currently being reviewed, and we will let you know if anything further is needed. We appreciate your contribution.
divakaivan commentedon Aug 27, 2026
I created a basic PoC here. Works... on a basic level - the memories are created from user messages saved messages. But will see as I use/test it more. And would appreciate feedback 🙏
a2105z commentedon Aug 29, 2026
Hi @divakaivan — thank you for writing this up, and especially for sharing the PoC. I went through agentcore_session_service carefully before touching ADK, and the design you landed on is what this is built from. I wanted to say that plainly, because the hard part of this issue was never “call boto3”; it was the session translation you already worked through.
Your README and
session.pyare what I treated as the spec:What I kept from your PoC
Sessionis a mapping, not a 1:1 resource.create_sessioncannot be a real create on their side.conversationalitem (USER/ASSISTANT/TOOL) so AgentCore can extract from the text, and ablobof the full ADKEventJSON soget_sessioncan rebuild history without dropping tool calls, state, or metadata. That is exactly the shape in your example payload, and I did not replace it.function_response→TOOL,author == "user"→USER, otherwiseASSISTANT.Event.model_validate_json.list_events/list_sessionson thebedrock-agentcoreclient, with boto3 calls off the event loop viaasyncio.to_thread.delete_sessionhas no API on their side. You noted they charge for creates, not storage, and left it as a no-op for the PoC. I kept that constraint in mind; in the ADK class I did implement delete by deleting the events in that session, only becauseBaseSessionService.delete_sessionis part of the contract runners actually call. Happy to hear if you would rather that stay a no-op.What I added so it can sit next to Redis/Firestore as an ADK integration
Your PoC is a working runner script, which is the right way to learn the API. For
google.adk.integrations.agentcoreI had to cover the rest ofBaseSessionServicesoRunnerdoes not surprise people:get_sessionreturnsNonewhen the session was never written (your getter always returned aSession, which is correct for a PoC and a bit loose for the ADK method signature).AlreadyExistsErroron a duplicatecreate_session.partial=Trueevents.BaseSessionService.append_eventalready returns those without appending; your override still calledcreate_eventafterward, so streaming chunks would have been written to STM. I only flush after the base class accepts the event.create_session(extractionMode=SKIP) so the session exists in AgentCore before the first user message. AgentCore drops empty sessions after about a day, and without thisget_session/list_sessionsright after create would not see anything.actorId = {app_name}:{user_id}instead ofuser_idalone, so two ADK apps sharing one Memory resource do not mix. Your PoC did not need that because it is one app. If you would rather keepactorId = user_idfor compatibility with memories you already wrote, that is a fair objection.list_sessionswithoutuser_id(vialist_actors), oldest-first, events stripped on the listing as the base class documents.state_deltafrom the restored events (temp:keys are not persisted, same as the other backends). App/user-scoped state is not shared across sessions the way Redis does; I called that out as a limitation rather than pretending AgentCore has those extra documents.google-adk[agentcore]extra, unit tests against a fake client (12 passed), and a short developer guide.The code lives in
src/google/adk/integrations/agentcore/on #6944. I tried to keep your names and your payload shape so it still reads as your mapping, just fitted to the ADK service interface.I am sure I have missed things you will hit once you keep using this against a real Memory resource — you said the PoC works on a basic level and you wanted to test it more, and that still matters more than the unit tests. If the actor namespacing, the bootstrap event, or deleting via
delete_eventis the wrong call for how you use STM, I would rather hear that from you than guess. Thank you again for putting the PoC up; this would have been a much worse first cut without it.a2105z commentedon Aug 29, 2026
Hi @sanketpatil06, @wukath, @GWeale — when you have a moment, would you be willing to take a look at this?
You already have the issue, and @divakaivan’s PoC is what the implementation follows. The ADK-shaped version is in #6944 (
AgentCoreSessionServiceunderintegrations/agentcore). I would be grateful for a maintainer pass whenever it fits your queue. No rush, and thank you for the time.GWeale commentedon Oct 26, 2026
hi @divakaivan, thanks for putting together the poc, and thanks @a2105z for picking it up in #6944. we've decided not to merge #6944 because agentcore short-term memory is an append-only event stream, which maps better to BaseMemoryService than BaseSessionService, and we're keeping core adk limited to integrations with broad adoption. this would live much better as a standalone package, and you can add it to the catalog at https://adk.dev/integrations/ with a docs page in google/adk-docs. thanks again to both of you for the work here.