fix(runtime): 运行稳定性 - 修复技能种子、任务续租与回归检查
保留社区技能作者与时间戳修复、Agent 参数约束、资源删除 worker 生命周期、PostgreSQL/Redis 测试门禁及相关回归。 Original-Commit: 0d05ff88bbe6c875d01964041788023a662ff7e8
This commit is contained in:
1 parent
6a3e454141
commit
7f44332914
21 files changed
+644
-354
No files matched your search
@@ -2,7 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -24,31 +24,37 @@ func TestCloudAgentToolSchemaStaysCompact(t *testing.T) {
|
||||
tools, raw := platformToolSchema(t)
|
||||
t.Logf("platform tool schema: %d tools, %d bytes", len(tools), len(raw))
|
||||
|
||||
// 顶层 type 枚举 + 服务端按 action 强校验已经表达了"每种操作要哪些字段",
|
||||
// 再挂一份 oneOf 只是重复:同一个约束会被下发两遍。
|
||||
// 条件必填不是 type 枚举能表达的约束,压缩描述不能删掉协议语义。
|
||||
found := false
|
||||
for _, tool := range tools {
|
||||
function, _ := tool["function"].(map[string]any)
|
||||
if function["name"] != "canvas_apply_ops" {
|
||||
continue
|
||||
}
|
||||
found = true
|
||||
parameters, _ := function["parameters"].(map[string]any)
|
||||
ops, _ := parameters["properties"].(map[string]any)
|
||||
items, _ := ops["ops"].(map[string]any)
|
||||
opItem, _ := items["items"].(map[string]any)
|
||||
if _, exists := opItem["oneOf"]; exists {
|
||||
t.Fatal("canvas_apply_ops 的 ops.items 不该再带重复的 oneOf")
|
||||
want := []map[string]any{
|
||||
{"properties": map[string]any{"type": map[string]any{"const": "add_node"}}, "required": []string{"nodeType"}},
|
||||
{"properties": map[string]any{"type": map[string]any{"const": "update_node"}}, "required": []string{"patch"}},
|
||||
{"properties": map[string]any{"type": map[string]any{"const": "connect_nodes"}}, "required": []string{"fromNodeId", "toNodeId"}},
|
||||
}
|
||||
if !reflect.DeepEqual(opItem["oneOf"], want) {
|
||||
t.Fatalf("操作类型条件必填约束丢失: %#v", opItem["oneOf"])
|
||||
}
|
||||
if props, ok := opItem["properties"].(map[string]any); !ok || len(props) == 0 {
|
||||
t.Fatal("canvas_apply_ops 的 ops.items 必须保留 properties")
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("canvas_apply_ops 未暴露")
|
||||
}
|
||||
|
||||
// 体积预算:当前 20 个工具约 22.4 KB,这里留 ~7% 余量;新增工具或字段时请重新测量并
|
||||
// 有意识地调整这个数字,而不是让 schema 悄悄膨胀(它每一步都要发、还在前缀最前面)。
|
||||
if len(raw) > 24000 {
|
||||
t.Fatalf("平台工具 schema 体积 %d 字节超出预算 24000:请压缩描述或显式调整预算", len(raw))
|
||||
}
|
||||
if strings.Count(string(raw), "oneOf") > 2 {
|
||||
t.Fatalf("工具 schema 里出现了过多 oneOf:%s", string(raw[:200]))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user