sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[FEATURE] Provide session manager access in AgentInitializedEvent

Open nagabharann opened this issue 10 months ago • 3 comments

Problem Statement

The session manager is not accessible in the AgentInitializedEvent hook. This prevents us from rehydrating conversation history when resuming paused conversations, forcing us to recreate agents for each invocation.

Proposed Solution

Include the session manager in the AgentInitializedEvent context, similar to how it's available in other events. This would allow hook handlers to access and modify conversation history during agent initialization.

Use Case

We are building a persistence layer for agent state. When an agent is resumed:

  1. The AgentInitializedEvent fires
  2. Our hook needs to load the previous conversation history from the persistence backend
  3. The session manager should be populated with this history before the agent continues

Without session manager access at this point, we cannot implement seamless conversation continuation.

Alternatives Solutions

We currently work around this by recreating agents with pre-populated history, but this adds latency and complexity.

Additional Context

No response

nagabharann avatar Jan 29 '26 20:01 nagabharann

@nagabharann can you expand why you need access to the session-manager directly?

The session-manager itself is a hook provider that registers for AgentInitializedEvent (see https://github.com/strands-agents/sdk-python/blob/8fa9c12a3aab1d2d6a7d8bb999d7f2daf1351d39/src/strands/agent/agent.py#L265) and so it's usually responsible for populating the agent. Why have a hook trigger the session-manager instead of letting the session-manager do it?

zastrowm avatar Jan 30 '26 20:01 zastrowm

This issue has been automatically closed as it was marked for auto-closure by the team and no additional responses was received within 7 days.

github-actions[bot] avatar Mar 04 '26 14:03 github-actions[bot]

Ok so looks like we can just workaround by creating our own Session Manager instead and repopulate the agent when the AgentInitializedEvent event fires.

nagabharann avatar Apr 06 '26 21:04 nagabharann