Skip to content

AgentCoreSessionService extending BaseSessionService for AgentCore Memory #6920

Closed as not planned

Description

@divakaivan

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:

  1. Session
    There isn't an exact session translation to agentcore memory so need to think about that.
  2. 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

Activity

  1. changed the title [-]AgentCoreSessionService[/-] [+]AgentCoreSessionService extending BaseSessionService for AgentCore Memory[/+] on Aug 26, 2026
  2. changed the issue type fromtoon Aug 27, 2026
  3. added
    agent engine[Component] This issue is related to Vertex AI Agent Engine
    on Aug 27, 2026
  4. sanketpatil06 commented on Aug 27, 2026

    @sanketpatil06

    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.

  5. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Aug 27, 2026
  6. divakaivan commented on Aug 27, 2026

    @divakaivan
    Author

    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 🙏

  7. a2105z commented on Aug 29, 2026

    @a2105z
    Contributor

    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.
    • Role mapping: function_response → TOOL, author == "user" → USER, otherwise ASSISTANT.
    • 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.

  8. a2105z commented on Aug 29, 2026

    @a2105z
    Contributor

    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 (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.

  9. self-assigned this
    on Oct 26, 2026
  10. GWeale commented on Oct 26, 2026

    @GWeale
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent engine[Component] This issue is related to Vertex AI Agent Engineneeds review[Status] The PR/issue is awaiting review from the maintainer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions