Skip to content

fix(callbacks): replace sonic JSON path for Go 1.24 compatibility#696

Closed
liusonglei796 wants to merge 1 commit intocloudwego:mainfrom
liusonglei796:fix/go124-sonic-callback-compat
Closed

fix(callbacks): replace sonic JSON path for Go 1.24 compatibility#696
liusonglei796 wants to merge 1 commit intocloudwego:mainfrom
liusonglei796:fix/go124-sonic-callback-compat

Conversation

@liusonglei796
Copy link
Copy Markdown

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.

Copilot AI review requested due to automatic review settings February 26, 2026 06:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: replaced sonic marshal/unmarshal usage in handler/state serialization with encoding/json.
  • callbacks/langfuse: replaced sonic marshal usage in handler paths with encoding/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.go imports it and uses sonic.Marshal/sonic.Unmarshal, and callbacks/langsmith/go.mod still requires it. If the goal is Go 1.24 compatibility by avoiding sonic/loader, the remaining usage/dependency should also be migrated to encoding/json (or removed) and go mod tidy re-run so sonic drops 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.

Comment on lines +17 to 18
github.com/bytedance/sonic v1.14.1 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
github.com/bytedance/sonic v1.14.1 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect

Copilot uses AI. Check for mistakes.
@liusonglei796 liusonglei796 closed this by deleting the head repository Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants