fix: handle malformed tool names with XML tag fragments#2819
fix: handle malformed tool names with XML tag fragments#2819juanmichelini wants to merge 2 commits intomainfrom
Conversation
When LLMs like qwen3-coder-next emit malformed tool names such as 'str_replace </parameter' or 'str_replace</function>', extract the first valid identifier and map it to the correct tool. This reduces errors for models that emit XML/HTML tag fragments appended to tool names. Co-authored-by: openhands <openhands@all-hands.dev>
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
|
Still some errors but looking better Will try on SWTbench which is the crucial one |
|
Errors are down, but score in SWT is still low. Might be interested to merge it anyway |
|
@OpenHands /codereview-raosted |
|
I'm on it! juanmichelini can track my progress at all-hands.dev |
SummaryI performed a code review of PR #2819 which fixes handling of malformed tool names like Review findings: ✅ All checks passed - No issues found
Changes reviewed:
Recommendation: APPROVE - The PR is low-risk and ready to merge. |
Summary
When LLMs like qwen3-coder-next emit malformed tool names such as
str_replace </parameterorstr_replace</function>, extract the first valid identifier and map it to the correct tool.This addresses issue #2818 which reported a 77.1% error rate for qwen3-coder-next, with the most common error (35.8%) being
Tool 'str_replace </parameter' not found.Changes
_try_fix_malformed_tool_name()function inopenhands-sdk/openhands/sdk/agent/utils.pynormalize_tool_call()to use the new function before applying aliasesTesting
test_tool_call_compatibility.pypassFixes #2818
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-nodejs22-slimgolang: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:ff8d7a6-pythonRun
All tags pushed for this build
About Multi-Architecture Support
ff8d7a6-python) is a multi-arch manifest supporting both amd64 and arm64ff8d7a6-python-amd64) are also available if needed