Detect Ambiguous OpenAPI Approval Targets with ACC v1.0.6
A tutorial demonstrates how identically named OpenAPI query and request-body fields can make an Agent tool’s approval condition ambiguous. Using ACC v1.0.6 and synthetic inventory-adjustment documents, the author rejects unresolved, mistyped, renamed, or invalid approval targets and recommends running normal and renamed-field examples together in CI. The static validation checks interface files only, so runtime acceptance tests with real request shapes are also required.
The approach gives Agent developers a concrete way to detect approval rules that may target the wrong input and catch related interface changes before deployment.
给库存调整接口接入 Agent 时,我想先回答一个具体问题。假设调整数量超过 1000 件需要人工审批,接口的查询参数和请求体里却都叫 quantity,审批规则应该读哪一个?
这在旧接口里并不罕见。查询参数可能是早期客户端留下的入口,后来调用方又把业务参数搬进 JSON 请求体。HTTP 请求仍能区分它们,服务端也可以分别读取。到了 Agent 的工具声明里,当条件只写一个 quantity,它就失去了原来的位置。
下面用一个合成的库存调整接口,演示怎么发现这类冲突,以及接口改版时如何用 CI 把它拦住。示例只校验接口文件。
1. HTTP 可以区分的两个值,工具声明里可能撞名
假设旧客户端仍传 ?quantity=1,新版请求体里写的是 {"quantity":1500}。两个值分别出现在 URL 和 JSON 里,业务接口完全可以接收。审批条件却是这样写的。
paths:
/stock-adjustments:
post:
operationId: requestStockAdjustment
parameters:
- name: quantity
in: query
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
$ref: "./request-schemas.json#/Flat"
x-agent-capability:
version: 1
enabled: true
scope: inventory.adjustment.request
subject:
required: true
approval:
when:
- param: quantity
op: ">"
value: 1000