Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/release-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
59 changes: 59 additions & 0 deletions internal/httpapi/agent_tool_argument_hint_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
43 changes: 41 additions & 2 deletions internal/httpapi/agent_tool_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions local/scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down