From a8e3a8f2e52d54323d9291e9d3848e1ce02c18f8 Mon Sep 17 00:00:00 2001 From: Walternater <11957989+Walternater@users.noreply.github.com> Date: Thu, 19 Nov 2026 19:57:51 +0800 Subject: [PATCH 1/2] fix(local): require ripgrep for the forbidden-content scans The validate and release-local workflows never installed ripgrep, and validate.sh reads a missing rg (exit 127) as "no match" inside if-rg, so every forbidden-content scan skipped silently while the job printed "Validation passed." (issue #1044). - validate.sh now fails loudly when rg is not on PATH. - Both workflows install ripgrep before running validate.sh. Merge after #909: apt ships rg 15.1.0 on resolute (ubuntu-latest) and 14.1.0 on noble; with rg present, 15.x glob handling self-matches scripts/validate.sh in scan 1 (the known bug #909 fixes, noble unaffected). Until #909 merges, validate (3.12) shows that known failure on this branch. Co-Authored-By: Claude Code --- .github/workflows/release-local.yml | 5 ++++- .github/workflows/validate.yml | 2 ++ local/scripts/validate.sh | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-local.yml b/.github/workflows/release-local.yml index e4331554d..ac634f8a8 100644 --- a/.github/workflows/release-local.yml +++ b/.github/workflows/release-local.yml @@ -84,7 +84,10 @@ jobs: } >> "$GITHUB_OUTPUT" - name: Install validation dependencies - run: python3 -m pip install pyyaml==6.0.3 + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends ripgrep + python3 -m pip install pyyaml==6.0.3 - name: Validate release contents run: | diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 8b3ed6bc9..52fa3ae24 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -24,6 +24,8 @@ jobs: python-version: ["3.8", "3.12"] steps: - uses: actions/checkout@v7.0.1 + # validate.sh gates its forbidden-content scans on ripgrep being present. + - run: sudo apt-get update && sudo apt-get install -y --no-install-recommends ripgrep - uses: actions/setup-python@v5.6.0 with: python-version: ${{ matrix.python-version }} diff --git a/local/scripts/validate.sh b/local/scripts/validate.sh index 9df7543b1..34106e770 100755 --- a/local/scripts/validate.sh +++ b/local/scripts/validate.sh @@ -4,6 +4,13 @@ set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT_DIR" +# A missing rg exits 127, which `if rg` treats like "no match", silently +# skipping every scan below (issue #1044). Fail loudly instead. +command -v rg >/dev/null 2>&1 || { + echo "ripgrep (rg) is required; the forbidden-content scans cannot run." >&2 + exit 1 +} + echo "[1/6] Checking forbidden public content" if rg --hidden -n \ -e 'Tencent/multi-agents-dev-workflow-open-source' \ From b7587a84f4092070713c5fd43a1d097863983ed1 Mon Sep 17 00:00:00 2001 From: Walternater <11957989+Walternater@users.noreply.github.com> Date: Thu, 19 Nov 2026 20:57:20 +0800 Subject: [PATCH 2/2] fix(platform): tell the model which wrapper a tool argument goes in Read-only tools described their arguments as "Query: projectId" while their input schema accepts only path/query/body at the top level, so the model passed a top-level projectId and got "unknown field" on its first call, then retried with the right shape (issue #1084). - /api/workflows GET now declares its projectId and q query parameters; the handler already read them but the contract omitted them, so the generated schema had an empty query object. - Tool descriptions now name the wrapper objects the schema actually accepts and show one example, for read-only and write tools alike. Co-Authored-By: Claude Code --- docs/api/openapi.yaml | 3 + .../httpapi/agent_tool_argument_hint_test.go | 59 +++++++++++++++++++ internal/httpapi/agent_tool_catalog.go | 43 +++++++++++++- 3 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 internal/httpapi/agent_tool_argument_hint_test.go diff --git a/docs/api/openapi.yaml b/docs/api/openapi.yaml index fad8b3b10..86b26078f 100644 --- a/docs/api/openapi.yaml +++ b/docs/api/openapi.yaml @@ -2102,6 +2102,9 @@ paths: get: tags: [Workflows] operationId: listWorkflows + parameters: + - { name: projectId, in: query, schema: { type: string }, description: "That project's SOPs plus generic templates" } + - { name: q, in: query, schema: { type: string }, description: "Match id, name, or description" } responses: "200": $ref: "#/components/responses/WorkflowList" diff --git a/internal/httpapi/agent_tool_argument_hint_test.go b/internal/httpapi/agent_tool_argument_hint_test.go new file mode 100644 index 000000000..bf1aa546c --- /dev/null +++ b/internal/httpapi/agent_tool_argument_hint_test.go @@ -0,0 +1,59 @@ +package httpapi + +import ( + "strings" + "testing" + + "agentflow/internal/application" +) + +// Issue #1084: a read-only tool description said "Query: projectId" while the +// schema only accepts arguments inside a query object, so models passed a +// top-level projectId and hit "unknown field" on the first call. +func TestPlatformToolArgumentHintNamesTheWrapper(t *testing.T) { + ops := map[string]application.Operation{} + for _, op := range application.PublicOperations() { + ops[op.Name] = op + } + + list, ok := ops["workflows_list"] + if !ok { + t.Fatal("workflows_list missing from public operations") + } + hint := platformToolArgumentHint(list) + if !strings.Contains(hint, "query") { + t.Fatalf("GET tool hint does not name query: %q", hint) + } + if !strings.Contains(hint, `"query": {...}`) { + t.Fatalf("GET tool hint does not show the wrapped shape: %q", hint) + } + if strings.Contains(hint, "body") { + t.Fatalf("GET tool hint offers a body wrapper it does not accept: %q", hint) + } + + save, ok := ops["workflows_save"] + if !ok { + t.Fatal("workflows_save missing from public operations") + } + saveHint := platformToolArgumentHint(save) + if !strings.Contains(saveHint, "body") { + t.Fatalf("PUT tool hint does not name body: %q", saveHint) + } + + // Routing tools carry their id in the path, so the hint must name it too. + get, ok := ops["workflows_get"] + if !ok { + t.Fatal("workflows_get missing from public operations") + } + if getHint := platformToolArgumentHint(get); !strings.Contains(getHint, "path") { + t.Fatalf("path-parameterised tool hint does not name path: %q", getHint) + } +} + +// A tool whose schema has no wrappers must not grow a hint that names them. +func TestPlatformToolArgumentHintIsEmptyWithoutWrappers(t *testing.T) { + op := application.Operation{Name: "noargs", Method: "GET", Path: "/api/noargs", ReadOnly: true} + if hint := platformToolArgumentHint(op); hint != "" { + t.Fatalf("hint for a tool with no wrapper arguments: %q", hint) + } +} diff --git a/internal/httpapi/agent_tool_catalog.go b/internal/httpapi/agent_tool_catalog.go index 314056766..74902805e 100644 --- a/internal/httpapi/agent_tool_catalog.go +++ b/internal/httpapi/agent_tool_catalog.go @@ -370,7 +370,7 @@ func (h *agentToolGateway) buildCatalog(ctx context.Context, session *AgentToolS schema, _ := json.Marshal(platformToolInputSchema(op)) out = append(out, agentToolDescriptor{ Name: ns, - Description: op.Description + " (" + op.Method + " " + op.Path + ")", + Description: op.Description + " (" + op.Method + " " + op.Path + ")" + platformToolArgumentHint(op), InputSchema: schema, Kind: "agentflow", UpstreamName: name, @@ -397,7 +397,7 @@ func (h *agentToolGateway) buildCatalog(ctx context.Context, session *AgentToolS } out = append(out, agentToolDescriptor{ Name: ns, - Description: writePolicy + op.Description + " (" + op.Method + " " + op.Path + ")", + Description: writePolicy + op.Description + " (" + op.Method + " " + op.Path + ")" + platformToolArgumentHint(op), InputSchema: schema, Kind: "agentflow", UpstreamName: name, @@ -475,6 +475,45 @@ func platformToolInputSchema(op application.Operation) map[string]any { return mcpserver.ToolInputSchema(op) } +// platformToolArgumentHint names the wrapper object each argument has to go in. +// The schema accepts only path/query/body at the top level, but operation +// descriptions say things like "Query: projectId", which models take as a +// top-level field and get "unknown field" on the first call (issue #1084). +func platformToolArgumentHint(op application.Operation) string { + properties, _ := mcpserver.ToolInputSchema(op)["properties"].(map[string]any) + wrappers := make([]string, 0, 3) + example := "" + for _, name := range []string{"path", "query", "body"} { + wrapper, _ := properties[name].(map[string]any) + if !wrapperHasArguments(name, wrapper) { + continue + } + wrappers = append(wrappers, name) + if example == "" { + example = name + } + } + if len(wrappers) == 0 { + return "" + } + return " Arguments go inside " + strings.Join(wrappers, "/") + ", for example {\"" + example + "\": {...}}." +} + +// wrapperHasArguments reports whether a path/query/body wrapper can carry a +// field. ToolInputSchema always emits a query object, even an empty one, so its +// presence says nothing; body is emitted only when the contract has a body, and +// it is a JSON Schema rather than a properties map (issue #1084). +func wrapperHasArguments(name string, wrapper map[string]any) bool { + if wrapper == nil { + return false + } + if name == "body" { + return true + } + fields, _ := wrapper["properties"].(map[string]any) + return len(fields) > 0 +} + func lookupAgentTool(catalog []agentToolDescriptor, name string) (agentToolDescriptor, bool) { name = stripAgentToolServerPrefix(name) for _, item := range catalog {