fix(callbacks): replace sonic JSON path for Go 1.24 compatibility#696
fix(callbacks): replace sonic JSON path for Go 1.24 compatibility#696liusonglei796 wants to merge 1 commit intocloudwego:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the callback submodules’ JSON serialization approach to avoid direct use of github.com/bytedance/sonic in callback handlers, aiming to improve Go 1.24 compatibility.
Changes:
callbacks/langsmith: replacedsonicmarshal/unmarshal usage in handler/state serialization withencoding/json.callbacks/langfuse: replacedsonicmarshal usage in handler paths withencoding/json.callbacks/langfuse: updated module metadata (go.mod/go.sum) after dependency cleanup.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| callbacks/langsmith/langsmith.go | Switches input/output JSON serialization in callback handler from sonic to encoding/json. |
| callbacks/langsmith/flow_trace.go | Switches span/state serialization from sonic to encoding/json. |
| callbacks/langfuse/langfuse.go | Switches handler JSON serialization from sonic to encoding/json (including streaming paths). |
| callbacks/langfuse/go.mod | Removes direct sonic requirement and updates indirect dependency set. |
| callbacks/langfuse/go.sum | Reflects dependency graph changes from go mod tidy. |
Comments suppressed due to low confidence (1)
callbacks/langsmith/langsmith.go:32
- This module still depends on
github.com/bytedance/sonic:callbacks/langsmith/client.goimports it and usessonic.Marshal/sonic.Unmarshal, andcallbacks/langsmith/go.modstill requires it. If the goal is Go 1.24 compatibility by avoidingsonic/loader, the remaining usage/dependency should also be migrated toencoding/json(or removed) andgo mod tidyre-run sosonicdrops from the module.
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"runtime/debug"
"sync"
"time"
"github.com/cloudwego/eino/callbacks"
"github.com/cloudwego/eino/schema"
"github.com/google/uuid"
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| github.com/bytedance/sonic v1.14.1 // indirect | ||
| github.com/bytedance/sonic/loader v0.3.0 // indirect |
There was a problem hiding this comment.
github.com/bytedance/sonic and github.com/bytedance/sonic/loader are still present in this module’s go.mod (even if indirect). If the intent is to eliminate Go 1.24 linker/runtime issues related to sonic/loader, this module will likely still pull it in via dependencies (e.g., github.com/cloudwego/eino-ext/libs/acl/langfuse in this repo currently imports sonic). Consider updating that dependency to stop using sonic and/or removing these indirect requirements once the dependency graph no longer needs them.
| github.com/bytedance/sonic v1.14.1 // indirect | |
| github.com/bytedance/sonic/loader v0.3.0 // indirect |
Background\nGo 1.24 environments can hit linker/runtime issues via transitive github.com/bytedance/sonic/loader dependency.\n\n## Changes\n- callbacks/langsmith: replace sonic marshal/unmarshal with encoding/json\n- callbacks/langfuse: replace sonic marshal calls with encoding/json\n- run go mod tidy in both callback submodules\n\n## Scope\nThis PR only updates callback submodules where sonic was directly imported and used for JSON serialization.\n\n## Notes\nMainline behavior is preserved; only JSON codec implementation is changed for compatibility.