-
Notifications
You must be signed in to change notification settings - Fork 39
Add conv_state parameter to ToolDefinition.create() method #1008
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
base: main
Are you sure you want to change the base?
Conversation
…wnstream usage - Add conv_state: ConversationState parameter to ToolDefinition.create() base method - Update all tool subclasses to accept conv_state parameter: - FinishTool, ThinkTool, MCPToolDefinition, BrowserUseTool - Update all call sites that invoke .create() method throughout the codebase - Fix all test files to pass conv_state parameter correctly - All 1061 SDK tests pass (excluding browser and e2e tests) Co-authored-by: openhands <[email protected]>
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
|
@OpenHands please fix the failing actions on PR #1008 at branch |
|
I'm on it! xingyaoww can track my progress at all-hands.dev |
…nversationState - Add **kwargs with noqa: ARG003 comment to all tool create() methods to match base class signature - Export ConversationState from SDK __init__.py for type checking - Fix example file (02_custom_tools.py) and test file (test_registry.py) to match base class signature - All pre-commit checks now pass (ruff format, ruff lint, pycodestyle, pyright) Co-authored-by: openhands <[email protected]>
✅ Successfully Fixed Failing Pre-commit Checks on PR #1008I've fixed all the failing pre-commit checks and pushed the changes to the Issues Fixed1. Pyright Type Checking Errors
2. Ruff Linter Warnings (ARG003)
3. Missing ConversationState Export
Files Modified
Verification✅ All pre-commit hooks pass:
✅ Changes committed and pushed to branch The PR should now pass all CI checks! |
Description
This PR adds a
conv_state: ConversationStateparameter to theToolDefinition.create()base method and updates all downstream usage to pass this parameter correctly.Changes
1. Updated ToolDefinition Base Class
conv_state: ConversationStateas the first parameter toToolDefinition.create()methodcreate(cls, conv_state: ConversationState) -> Sequence[Self]2. Updated Tool Subclasses
All tool subclasses have been updated to accept and use the
conv_stateparameter:.create()signature.create()signature.create()to acceptconv_stateas first parameter.create()to acceptconv_stateas first parameter3. Updated Call Sites
All locations that call
.create()on tools have been updated:openhands/sdk/agent/base.py: Updated tool initialization in agentopenhands/sdk/mcp/utils.py: Updatedcreate_mcp_tools()to accept and passconv_statemock_conversation_statefixture4. Test Updates
test_mcp_tool.py: Converted to fixture-based setup, addedpytestimporttest_mcp_tool_immutability.py: Converted to fixture-based setuptest_mcp_tool_kind_field.py: Updated fixtures to passconv_statetest_mcp_tool_serialization.py: Added fixture parameters to test functionstest_builtins.py,test_tool_serialization.pytest_agent_serialization.pytest_browser_toolset.pyTesting
✅ All 1061 SDK tests pass (excluding browser and e2e tests)
✅ All pre-commit hooks pass (ruff format, ruff lint, pycodestyle, pyright)
✅ All MCP tests (47 tests) pass
Motivation
This change standardizes the
.create()method signature across all tool definitions by requiringConversationStateas a parameter. This provides tools with access to conversation context during creation, enabling:Backward Compatibility
.create()on tool classes must now passconv_stateas the first parameter.Related Issues
Related to PR #971 (ToolDefinition architecture refactoring)
Checklist
@xingyaoww can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
golang:1.21-bookwormeclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22Pull (multi-arch manifest)
Run
All tags pushed for this build
The
777953etag is a multi-arch manifest (amd64/arm64); your client pulls the right arch automatically.