Skip to content

Conversation

mkmeral
Copy link
Contributor

@mkmeral mkmeral commented Sep 25, 2025

Description

This PR documents the new multi-agent shared state feature that allows passing invocation_state to Graph and Swarm patterns. The feature enables sharing configuration, credentials, and context data across all agents in multi-agent patterns without exposing this information to the LLM.

Type of Change

  • New content addition
  • Content update/revision
  • Structure/organization improvement
  • Typo/formatting fix
  • Bug fix
  • Other (please describe):

Motivation and Context

Following the implementation of PR #816 in the SDK, this documentation update is needed to help developers understand how to use the new invocation_state parameter with multi-agent patterns. The feature addresses a key customer need for sharing configuration and credentials across agents while maintaining proper separation of concerns.

The original SDK PR introduced kwargs support to Graph and Swarm, allowing developers to pass shared state that gets propagated to all agents, tools, and hooks without being visible in LLM prompts.

Areas Affected

  • Multi-agent documentation:
    • docs/user-guide/concepts/multi-agent/graph.md - Added "Shared State" section
    • docs/user-guide/concepts/multi-agent/swarm.md - Added "Shared State" section
  • Tools documentation:
    • docs/user-guide/concepts/tools/python-tools.md - Added "Accessing Invocation State in Tools" section
  • Hooks documentation:
    • docs/user-guide/concepts/agents/hooks.md - Added "Accessing Invocation State in Hooks" section

Screenshots

N/A - Documentation changes only

Checklist

  • I have read the CONTRIBUTING document
  • My changes follow the project's documentation style
  • I have tested the documentation locally using mkdocs serve
  • Links in the documentation are valid and working
  • Images/diagrams are properly sized and formatted
  • All new and existing tests pass

Additional Notes

This documentation covers three key integration points for the shared state feature:

  1. Multi-agent patterns (Graph/Swarm): How to pass invocation_state and what gets propagated
  2. Tools: How to access shared state via ToolContext.invocation_state
  3. Hooks: How to access shared state in tool-related hook events

The documentation emphasizes the important distinction between:

  • Shared Context: Information visible to LLMs for collaboration
  • Shared State: Hidden configuration passed via invocation_state

Cross-references between sections help developers understand the complete integration story across the framework.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mkmeral mkmeral enabled auto-merge (squash) September 25, 2025 18:19
result = graph(
"Analyze customer data",
invocation_state={
"api_key": "secret-key-123",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove references to api keys/tool-configs from invocation_state usages?

The python-tools section update is good, but the examples throughout the other pages should be updated as well

4. **Custom Parameters**: Pass any additional data that hooks might need

```python
from strands.experimental.hooks import BeforeToolInvocationEvent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been updated, lets point to the main location

Suggested change
from strands.experimental.hooks import BeforeToolInvocationEvent
from strands.hooks import BeforeToolCallEvent

Comment on lines +165 to +167
user_id="user123",
session_id="sess456",
environment="staging"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we give an example where we are passing a non-json serializable object through invocation state? Right now, its not really clear what its benefit is over AgentState

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants