DRAFT: feat: add execute_tool API endpoint for direct tool execution on conversations#2356
DRAFT: feat: add execute_tool API endpoint for direct tool execution on conversations#2356
Conversation
…ersations
Add the ability to execute tools (like the terminal) directly on a
conversation without going through the agent loop. This enables pre-run
setup operations like running .openhands/setup.sh through the agent's
persistent terminal session so environment changes persist.
Changes:
- Add ExecuteToolRequest/Response models
- Add EventService.execute_tool() method
- Add ConversationService.execute_tool() method
- Add POST /conversations/{id}/execute_tool endpoint
- Implement RemoteConversation.execute_tool() (was NotImplementedError)
- Add AsyncRemoteWorkspace.execute_tool() convenience method
Co-authored-by: openhands <openhands@all-hands.dev>
API breakage checks (Griffe)Result: Passed |
Agent server REST API breakage checks (OpenAPI)Result: Failed Log excerpt (first 1000 characters) |
|
@OpenHands please fix https://github.com/OpenHands/software-agent-sdk/actions/runs/22794005415/job/66125654112?pr=2356 and https://github.com/OpenHands/software-agent-sdk/actions/runs/22794005420/job/66125654134?pr=2356 Then help me review the PR and test if this PR is working - When you are done, upload artifacts to |
|
I'm on it! xingyaoww can track my progress at all-hands.dev |
- Fix pyright errors in event_service.py by capturing _conversation in a local variable before the closure (type narrowing) - Fix Observation ABC instantiation in remote_conversation.py by using a concrete _RemoteObservation subclass - Update test to verify new execute_tool implementation behavior - Fix line-too-long issues in docstrings and field descriptions Co-authored-by: openhands <openhands@all-hands.dev>
|
📁 PR Artifacts Notice This PR contains a
|
Summary of Work DoneI fixed both failing CI checks on PR #2356, reviewed the PR, functionally tested the new endpoint, and pushed everything (including CI Fixes (commit
|
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Add the ability to execute tools (like the terminal) directly on a conversation without going through the agent loop. This enables pre-run setup operations like running
.openhands/setup.shthrough the agent's persistent terminal session so environment changes persist.Problem
In V1,
setup.shwas executed viaAsyncRemoteWorkspace.execute_command()which runs commands in an ephemeral subprocess — environment changes (exported variables, sourced files, PATH modifications, etc.) don't persist to the agent's terminal session. This madesetup.sheffectively broken in V1 compared to V0.Solution
Add a new
POST /api/conversations/{id}/execute_toolendpoint that allows executing a tool directly on a conversation. The endpoint:_ensure_agent_ready())LocalConversation.execute_tool()Changes
Agent Server:
models.py: AddedExecuteToolRequest/ExecuteToolResponsemodelsevent_service.py: AddedEventService.execute_tool()— runs a tool throughLocalConversation.execute_tool()in a thread executorconversation_service.py: AddedConversationService.execute_tool()— delegates toEventServiceconversation_router.py: AddedPOST /conversations/{id}/execute_toolendpoint with 404/400 error handlingSDK:
remote_conversation.py: ImplementedRemoteConversation.execute_tool()(wasNotImplementedError) — calls the new server endpointasync_remote_workspace.py: AddedAsyncRemoteWorkspace.execute_tool()convenience methodCompanion PR
This PR is used by the OpenHands companion PR: OpenHands/OpenHands (feat/setup-sh-via-terminal-tool) which restructures the V1 startup flow to run
setup.shthrough the terminal tool.Testing
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:54b9759-pythonRun
All tags pushed for this build
About Multi-Architecture Support
54b9759-python) is a multi-arch manifest supporting both amd64 and arm6454b9759-python-amd64) are also available if needed