diff --git a/backend/crossdomain/plugin/model/option.go b/backend/crossdomain/plugin/model/option.go index 2eca3ff0a..d1986b088 100644 --- a/backend/crossdomain/plugin/model/option.go +++ b/backend/crossdomain/plugin/model/option.go @@ -70,7 +70,7 @@ func WithAutoGenRespSchema() ExecuteToolOpt { } } -func WithPluginHTTPHeader(conversationID int64) ExecuteToolOpt { +func WithConversationID(conversationID int64) ExecuteToolOpt { return func(o *ExecuteToolOption) { o.ConversationID = conversationID } diff --git a/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go b/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go index fd2cf135d..dd6078b75 100644 --- a/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go +++ b/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go @@ -136,7 +136,7 @@ func (p *pluginInvokableTool) InvokableRun(ctx context.Context, argumentsInJSON model.WithInvalidRespProcessStrategy(consts.InvalidResponseProcessStrategyOfReturnDefault), model.WithToolVersion(p.toolInfo.GetVersion()), model.WithProjectInfo(p.projectInfo), - model.WithPluginHTTPHeader(p.conversationID), + model.WithConversationID(p.conversationID), } resp, err := crossplugin.DefaultSVC().ExecuteTool(ctx, req, opts...) diff --git a/backend/domain/workflow/internal/nodes/plugin/exec.go b/backend/domain/workflow/internal/nodes/plugin/exec.go index 23e4e41b7..0bf593468 100644 --- a/backend/domain/workflow/internal/nodes/plugin/exec.go +++ b/backend/domain/workflow/internal/nodes/plugin/exec.go @@ -65,6 +65,14 @@ func ExecutePlugin(ctx context.Context, input map[string]any, pe *vo.PluginEntit if pe.PluginVersion != nil { execOpts = append(execOpts, model.WithToolVersion(*pe.PluginVersion)) } + if cfg.ConversationID != nil { + execOpts = append(execOpts, model.WithConversationID(*cfg.ConversationID)) + } + if cfg.AgentID != nil { + execOpts = append(execOpts, model.WithProjectInfo(&model.ProjectInfo{ + ProjectID: *cfg.AgentID, + })) + } r, err := crossplugin.DefaultSVC().ExecuteTool(ctx, req, execOpts...) if err != nil { diff --git a/backend/domain/workflow/plugin/plugin.go b/backend/domain/workflow/plugin/plugin.go index 3068d4413..2f22d36e5 100644 --- a/backend/domain/workflow/plugin/plugin.go +++ b/backend/domain/workflow/plugin/plugin.go @@ -336,8 +336,15 @@ func (p *pluginInvokeTool) Info(ctx context.Context) (_ *schema.ToolInfo, err er } func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg workflowModel.ExecuteConfig) (string, error) { + var uID string + if cfg.AgentID != nil { + uID = cfg.ConnectorUID + } else { + uID = conv.Int64ToStr(cfg.Operator) + } + req := &model.ExecuteToolRequest{ - UserID: conv.Int64ToStr(cfg.Operator), + UserID: uID, PluginID: p.pluginEntity.PluginID, ToolID: p.toolInfo.ID, ExecScene: consts.ExecSceneOfWorkflow, @@ -348,7 +355,14 @@ func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON str execOpts := []model.ExecuteToolOpt{ model.WithInvalidRespProcessStrategy(consts.InvalidResponseProcessStrategyOfReturnDefault), } - + if cfg.ConversationID != nil { + execOpts = append(execOpts, model.WithConversationID(*cfg.ConversationID)) + } + if cfg.AgentID != nil { + execOpts = append(execOpts, model.WithProjectInfo(&model.ProjectInfo{ + ProjectID: *cfg.AgentID, + })) + } if p.pluginEntity.PluginVersion != nil { execOpts = append(execOpts, model.WithToolVersion(*p.pluginEntity.PluginVersion)) }