Skip to content

refactor: Update interfaces to include kwargs to enable backwards compatibility #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 11, 2025

Conversation

mkmeral
Copy link
Contributor

@mkmeral mkmeral commented Jul 11, 2025

Description

This PR adds **kwargs parameters to all model and tool interfaces to enable backwards compatibility and future extensibility.

Note: This is a breaking change that will require users who have implemented custom tools or model providers to update their code to match the new interface
signatures.

Key Changes:

Model Interfaces: Added **kwargs to stream() and structured_output() methods across all model providers (Bedrock, LiteLLM, LlamaAPI,
Mistral, Ollama, OpenAI, Writer)
Tool System: Refactored tool interfaces to use invocation_state: dict[str, Any], **kwargs: Any instead of kwargs: dict[str, Any] for better API clarity
Event Loop: Updated event loop functions to use invocation_state parameter naming for consistency
Hook System: Updated tool invocation events (BeforeToolInvocationEvent, AfterToolInvocationEvent) to use invocation_state instead of kwargs
Telemetry/Tracing: Updated tracer methods to use invocation_state parameter naming throughout the tracing system
Documentation: Added parameter descriptions for all new **kwargs parameters

The refactoring improves API clarity by separating invocation context (invocation_state) from extensibility parameters (**kwargs), while enabling future extensibility without breaking changes.

Breaking Changes:

• Custom tool implementations must update their stream() method signature from stream(self, tool_use: ToolUse, kwargs: dict[str, Any]) to
stream(self, tool_use: ToolUse, invocation_state: dict[str, Any], **kwargs: Any)
• Custom model providers must add **kwargs: Any to their stream() and structured_output() method signatures
• Hook handlers using tool invocation events must update references from kwargs to invocation_state

Related Issues

Documentation PR

Type of Change

Breaking change

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-
docs, agents-tools, agents-cli

• [ x ] I ran hatch run prepare

Testing Coverage:
• All existing tests updated to reflect new parameter naming
• Test coverage maintained across all affected components
• Model provider tests verify **kwargs acceptance
• Tool system tests verify invocation_state and **kwargs handling
• Hook system tests updated for new event parameter structure
• Tracing/telemetry tests updated for invocation_state usage

Checklist

• [ x ] I have read the CONTRIBUTING document
• [ x ] I have added any necessary tests that prove my fix is effective or my feature works
• [ x ] I have updated the documentation accordingly
• [ ] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
• [ x ] My changes generate no new warnings
• [ x ] Any dependent changes have been merged and published

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

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

zastrowm
zastrowm previously approved these changes Jul 11, 2025
zastrowm
zastrowm previously approved these changes Jul 11, 2025
Unshure
Unshure previously approved these changes Jul 11, 2025
@mkmeral mkmeral dismissed stale reviews from Unshure and zastrowm via d33a1a8 July 11, 2025 14:27
@mkmeral mkmeral temporarily deployed to manual-approval July 11, 2025 14:28 — with GitHub Actions Inactive
@mkmeral mkmeral changed the title [REFACTOR] Update interfaces to include kwargs to enable backwards com… refactor: Update interfaces to include kwargs to enable backwards com… Jul 11, 2025
@mkmeral mkmeral changed the title refactor: Update interfaces to include kwargs to enable backwards com… refactor: Update interfaces to include kwargs to enable backwards compatibility Jul 11, 2025
@mkmeral mkmeral merged commit bd15b04 into strands-agents:main Jul 11, 2025
12 checks passed
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