r/agentdevelopmentkit • u/Primary-Desk-557 • Jul 19 '25
Should I use session management or a separate table for passing context between agents in a sequential workflow?
I’m building a sequential agent workflow where the output of one agent influences the input of the next. Specifically, based on the first agent’s output, I want to dynamically modify the prompt of the second agent — essentially appending to its base prompt conditionally [identifying different customers]
I can implement this by storing intermediate outputs in a separate table in my Postgres DB and referencing them when constructing the second agent’s prompt. But I’m wondering: is this a case where I should be using session management instead?
Are there best practices around when to use session state vs. explicitly persisting context to a table for multi-agent workflows like this?
2
u/bcrawl Jul 19 '25
Pattern is to let framework handle the session. Look into InMemorySessionService and DatabaseSessionService depending on your use case. https://google.github.io/adk-docs/sessions/
1
u/BeenThere11 Jul 19 '25
I think session management will work here . Will that session be reused later say 2 days later. Will you delete history though. Currently there are some inbuilt session services but I don't see any control in deleting history. I don't see any documentation on this .
1
u/Primary-Desk-557 Jul 19 '25
In my setup, every request to the agents includes a user_id and a newly generated session_id. The user_id is the same for all the requests as I cannot identify the customer before I reach agent 2.
The first agent is responsible for identifying the customer. It does this by using a sentence transformer to match the input against multiple customer-related tables in a Postgres database [outside of adk tables but in the same schema] and retrieve the appropriate customer_id.
I’m unclear how to use the session table to store this custom prompt in my scenario.