From c3ba59a41b4dc03d1eb2ed71cc83ab8748a7cae6 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 24 Feb 2026 11:16:45 +0800 Subject: [PATCH] Update sandbox integration tests and enhance JSON field parsing - Modify the sandbox integration test to load a different assistant configuration, ensuring accurate testing of sandbox capabilities. - Refactor JSON field parsing in the Xun store to handle both string and byte slice types, improving robustness in data processing and ensuring proper unmarshalling of JSON fields. --- agent/assistant/sandbox_integration_test.go | 4 ++-- agent/store/xun/xun.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/agent/assistant/sandbox_integration_test.go b/agent/assistant/sandbox_integration_test.go index d9276b57..024c5869 100644 --- a/agent/assistant/sandbox_integration_test.go +++ b/agent/assistant/sandbox_integration_test.go @@ -181,8 +181,8 @@ func TestHasSandboxMethod(t *testing.T) { require.NoError(t, err) assert.True(t, astWithSandbox.HasSandbox(), "Assistant with sandbox config should return true") - // Test assistant without sandbox (fullfields doesn't have sandbox) - astWithoutSandbox, err := assistant.LoadPath("/assistants/tests/fullfields") + // Test assistant without sandbox + astWithoutSandbox, err := assistant.LoadPath("/assistants/tests/simple-greeting") require.NoError(t, err) assert.False(t, astWithoutSandbox.HasSandbox(), "Assistant without sandbox config should return false") } diff --git a/agent/store/xun/xun.go b/agent/store/xun/xun.go index dc3d8559..e04a4131 100644 --- a/agent/store/xun/xun.go +++ b/agent/store/xun/xun.go @@ -168,9 +168,18 @@ func (store *Xun) getAssistantTable() string { func (store *Xun) parseJSONFields(data map[string]interface{}, fields []string) { for _, field := range fields { if val := data[field]; val != nil { - if strVal, ok := val.(string); ok && strVal != "" { + var jsonStr string + switch v := val.(type) { + case string: + jsonStr = v + case []byte: + jsonStr = string(v) + default: + continue + } + if jsonStr != "" { var parsed interface{} - if err := jsoniter.UnmarshalFromString(strVal, &parsed); err == nil { + if err := jsoniter.UnmarshalFromString(jsonStr, &parsed); err == nil { data[field] = parsed } }