Repository navigation
Conversation
…dispatch When a model-generated tool call omits a required field or passes a wrong-typed/nested argument, the executor previously forwarded the raw arguments straight to the downstream HTTP service, which failed with an opaque 4xx instead of a structured error the agent loop could use to self-correct. - ToolExecutor.execute() now validates arguments against the tool's input_schema before the HTTP dispatch (sync and detached-submit paths) - Returns a new SCHEMA_INVALID ToolError listing up to 5 validation issues (missing required fields, type mismatches, dotted JSON paths) without issuing the HTTP request - None / empty / non-dict / malformed schemas are logged and skipped, preserving existing behaviour for legacy tools - MCP and A2A paths are intentionally untouched: their schemas belong to the provider, which is contractually responsible for validation - No new dependencies (jsonschema is already a backend dep), no DB, API, or ToolError structure changes
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决的问题
HTTP Tool 执行链存在一个参数校验缺失的问题。
此前,ToolExecutor 在将模型生成的
arguments发送到下游 HTTP 服务之前,没有根据工具自身的input_schema进行校验。当模型出现以下情况时:
required必填字段这些错误参数会直接发送到下游服务,可能导致远端返回 4xx 或工具执行失败,Agent 获取到的错误信息不够明确,不利于后续自动纠正。
实现方式
在
ToolExecutor.execute()的 HTTP Tool 执行路径中增加执行前的 JSON Schema 参数校验。具体行为:
input_schema为None或{}:保持原有行为input_schema不是字典:记录 warning 并跳过校验input_schema本身非法:记录 warning 并跳过校验,避免影响历史工具SCHEMA_INVALID本次使用项目已有的
jsonschema依赖,没有增加新的依赖,也没有修改ToolError的数据结构。影响范围
本次修改仅涉及 HTTP Tool 的执行前参数校验。
未修改:
测试
新增测试覆盖:
input_schemanullinput_schema测试结果:
test_tool_executor.py:28/28 通过git diff --check通过UI 验证
Route:
/workspace/toolsRole:
admin通过工具管理页面“测试工具”按钮对应的 REST API:
POST /api/enterprise/tools/{id}/test使用
order.query进行了验证:order_id→ 返回SCHEMA_INVALIDorder_id类型错误 → 返回SCHEMA_INVALIDorder_id→ 正常执行由于当前验证环境没有 GUI 浏览器,因此这里采用的是页面对应 REST API 的 fallback 验证,并非浏览器点击级验证。
兼容性
为了避免影响历史工具:
nullschema 不进行校验合法的 HTTP Tool 调用保持原有执行流程。
范围说明
这是一次 HTTP Tool 执行链的可靠性修复,重点解决模型生成无效参数时无法在请求发送前发现的问题。
本 PR 不涉及 MCP/A2A 的参数校验,也不改变现有 ToolError 结构。