feat(plugin): append special headers (agentId, userId, conversationId and logId) to plugin http request, which can be used by plugin server (#2191)

This commit is contained in:
大鹏
2025-09-19 14:00:44 +08:00
committed by GitHub
parent 315a93f8c0
commit b05004f188
14 changed files with 60 additions and 8 deletions

View File

@ -19,6 +19,7 @@ package middleware
import (
"context"
"fmt"
"github.com/coze-dev/coze-studio/backend/types/consts"
"net/http"
"path/filepath"
"strings"
@ -84,7 +85,7 @@ func AccessLogMW() app.HandlerFunc {
func SetLogIDMW() app.HandlerFunc {
return func(ctx context.Context, c *app.RequestContext) {
logID := uuid.New().String()
ctx = context.WithValue(ctx, "log-id", logID)
ctx = context.WithValue(ctx, consts.CtxLogIDKey, logID)
c.Header("X-Log-ID", logID)
c.Next(ctx)

View File

@ -24,6 +24,9 @@ type ExecuteToolOption struct {
ToolVersion string
Operation *Openapi3Operation
InvalidRespProcessStrategy InvalidResponseProcessStrategy
AgentID int64
ConversationID int64
}
type ExecuteToolOpt func(o *ExecuteToolOption)
@ -65,3 +68,10 @@ func WithAutoGenRespSchema() ExecuteToolOpt {
o.AutoGenRespSchema = true
}
}
func WithPluginHTTPHeader(agentID, conversationID int64) ExecuteToolOpt {
return func(o *ExecuteToolOption) {
o.AgentID = agentID
o.ConversationID = conversationID
}
}

View File

@ -112,6 +112,8 @@ type ExecuteRequest struct {
History []*schema.Message
ResumeInfo *InterruptInfo
PreCallTools []*agentrun.ToolsRetriever
ConversationID int64
}
type AgentIdentity struct {