From cfb4b725873491a0cb814f92e238d5bc577a8997 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jul 2026 17:51:34 +0800 Subject: [PATCH] fix: CORE_REGISTER_TOOL fallback to raw string on unmarshal error Previously the wrapper silently ignored json.Unmarshal errors and returned nil, causing tools returning raw JSON strings (via C ABI bridge's json.Marshal) to appear as empty map[] to the agent. --- internal/plugin/cabi/loader.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/plugin/cabi/loader.go b/internal/plugin/cabi/loader.go index 11b3f64..643d408 100644 --- a/internal/plugin/cabi/loader.go +++ b/internal/plugin/cabi/loader.go @@ -279,7 +279,9 @@ func go_core_dispatch(methodID C.int, ctx unsafe.Pointer, s1, s2, s3 *C.char, i1 if err != nil { return nil, err } if r == "" { return nil, nil } var res map[string]interface{} - json.Unmarshal([]byte(r), &res) + if err := json.Unmarshal([]byte(r), &res); err != nil { + return r, nil + } return res, nil }) return 0