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
feat: Replace kwargs with explicit invocation_args parameter in Agent APIs
- Add invocation_args parameter to Agent.__call__, invoke_async, and stream_async methods
- Maintain backward compatibility with **kwargs (deprecated)
- Add deprecation warnings for kwargs usage
- invocation_args takes precedence over kwargs when both provided
- Add comprehensive unit tests (8 tests)
- Add end-to-end tests (15 tests)
- Add load tests (7 tests) for performance verification
- Update README.md with new API documentation
- Enable API evolution without breaking changes
Resolvesstrands-agents#919
response = agent("Use any tools you find in the tools directory")
103
103
```
104
104
105
+
### Advanced Agent Invocation
106
+
107
+
For advanced use cases, you can pass additional parameters using the `invocation_args` parameter:
108
+
109
+
```python
110
+
from strands import Agent
111
+
112
+
agent = Agent()
113
+
114
+
# Using the new invocation_args parameter (recommended)
115
+
response = agent(
116
+
"Analyze this data",
117
+
invocation_args={
118
+
"callback_handler": custom_handler,
119
+
"custom_param": "value"
120
+
}
121
+
)
122
+
123
+
# Async methods also support invocation_args
124
+
asyncdefanalyze_data():
125
+
result =await agent.invoke_async(
126
+
"Analyze this data",
127
+
invocation_args={"custom_param": "value"}
128
+
)
129
+
return result
130
+
131
+
# Streaming with invocation_args
132
+
asyncfor event in agent.stream_async(
133
+
"Analyze this data",
134
+
invocation_args={"custom_param": "value"}
135
+
):
136
+
print(event)
137
+
```
138
+
139
+
> **Note**: The legacy `**kwargs` syntax is still supported but deprecated. Use `invocation_args` for new code to ensure compatibility with future versions.
140
+
105
141
### MCP Support
106
142
107
143
Seamlessly integrate Model Context Protocol (MCP) servers:
0 commit comments