Skip to content

Commit 49ca47c

Browse files
committed
fix: scope tape callbacks to analyze runs
1 parent 511195d commit 49ca47c

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

cmd/lapp/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import (
44
"context"
55
"os"
66

7-
"github.com/cloudwego/eino/callbacks"
87
"github.com/joho/godotenv"
98
"github.com/spf13/cobra"
10-
"github.com/strrl/lapp/pkg/tape"
119
"github.com/strrl/lapp/pkg/tracing"
1210
)
1311

@@ -17,7 +15,6 @@ func main() {
1715

1816
flush := tracing.InitLangfuse()
1917
otelShutdown := tracing.InitOTel(context.Background())
20-
callbacks.AppendGlobalHandlers(tape.NewSlogHandler())
2118

2219
root := &cobra.Command{
2320
Use: "lapp",

pkg/analyzer/analyzer.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/cloudwego/eino-ext/adk/backend/local"
1111
"github.com/cloudwego/eino/adk"
1212
fsmw "github.com/cloudwego/eino/adk/middlewares/filesystem"
13-
"github.com/cloudwego/eino/callbacks"
1413
"github.com/go-errors/errors"
1514
einoacp "github.com/strrl/eino-acp"
1615
"github.com/strrl/lapp/pkg/tape"
@@ -107,12 +106,6 @@ func RunAgentWithPrompt(ctx context.Context, config Config, workDir, question, s
107106
attribute.String("model", config.Model),
108107
)
109108

110-
if config.TapePath != "" {
111-
jsonlStore := tape.NewJSONLStore(config.TapePath)
112-
callbacks.AppendGlobalHandlers(tape.NewHandler(jsonlStore))
113-
slog.Info("Tape recording enabled", "path", config.TapePath)
114-
}
115-
116109
slog.Info("Analyzing with ACP provider", "provider", provider, "model", config.Model)
117110

118111
chatModel, err := einoacp.NewChatModel(ctx, &einoacp.Config{
@@ -160,7 +153,13 @@ func RunAgentWithPrompt(ctx context.Context, config Config, workDir, question, s
160153
}
161154

162155
runner := adk.NewRunner(ctx, adk.RunnerConfig{Agent: agent})
163-
iter := runner.Query(ctx, userMessage)
156+
var runOptions []adk.AgentRunOption
157+
if config.TapePath != "" {
158+
jsonlStore := tape.NewJSONLStore(config.TapePath)
159+
runOptions = append(runOptions, adk.WithCallbacks(tape.NewHandler(jsonlStore)))
160+
slog.Info("Tape recording enabled", "path", config.TapePath)
161+
}
162+
iter := runner.Query(ctx, userMessage, runOptions...)
164163

165164
var result strings.Builder
166165
for {

0 commit comments

Comments
 (0)