From 38857d651ab1c2cda57e775dba8f690c95cc87d9 Mon Sep 17 00:00:00 2001 From: JianFeeeee <109188060+JianFeeeee@users.noreply.github.com> 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 11b3f64a..643d4084 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