fix: checkpoint store correctly initialize in multi-layered sub-workf… (#755)
This commit is contained in:
parent
c79ee64fe8
commit
3030d4d627
|
|
@ -42,6 +42,7 @@ func New(ctx context.Context, s *schema.NodeSchema,
|
||||||
inner compose.Runnable[map[string]any, map[string]any], // inner workflow for composite node
|
inner compose.Runnable[map[string]any, map[string]any], // inner workflow for composite node
|
||||||
sc *schema.WorkflowSchema, // the workflow this NodeSchema is in
|
sc *schema.WorkflowSchema, // the workflow this NodeSchema is in
|
||||||
deps *dependencyInfo, // the dependency for this node pre-calculated by workflow engine
|
deps *dependencyInfo, // the dependency for this node pre-calculated by workflow engine
|
||||||
|
requireCheckpoint bool,
|
||||||
) (_ *Node, err error) {
|
) (_ *Node, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if panicErr := recover(); panicErr != nil {
|
if panicErr := recover(); panicErr != nil {
|
||||||
|
|
@ -87,7 +88,7 @@ func New(ctx context.Context, s *schema.NodeSchema,
|
||||||
|
|
||||||
return &Node{Lambda: s.Lambda}, nil
|
return &Node{Lambda: s.Lambda}, nil
|
||||||
case entity.NodeTypeSubWorkflow:
|
case entity.NodeTypeSubWorkflow:
|
||||||
subWorkflow, err := buildSubWorkflow(ctx, s, sc.RequireCheckpoint())
|
subWorkflow, err := buildSubWorkflow(ctx, s, requireCheckpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ func (w *Workflow) addNodeInternal(ctx context.Context, ns *schema.NodeSchema, i
|
||||||
innerWorkflow = inner.inner
|
innerWorkflow = inner.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
ins, err := New(ctx, ns, innerWorkflow, w.schema, deps)
|
ins, err := New(ctx, ns, innerWorkflow, w.schema, deps, w.requireCheckpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -731,10 +731,7 @@ func (c *Config) Build(ctx context.Context, ns *schema2.NodeSchema, _ ...schema2
|
||||||
_ = g.AddEdge(llmNodeKey, outputConvertNodeKey)
|
_ = g.AddEdge(llmNodeKey, outputConvertNodeKey)
|
||||||
_ = g.AddEdge(outputConvertNodeKey, compose.END)
|
_ = g.AddEdge(outputConvertNodeKey, compose.END)
|
||||||
|
|
||||||
requireCheckpoint := false
|
requireCheckpoint := c.RequireCheckpoint()
|
||||||
if len(tools) > 0 {
|
|
||||||
requireCheckpoint = true
|
|
||||||
}
|
|
||||||
|
|
||||||
var compileOpts []compose.GraphCompileOption
|
var compileOpts []compose.GraphCompileOption
|
||||||
if requireCheckpoint {
|
if requireCheckpoint {
|
||||||
|
|
@ -759,11 +756,19 @@ func (c *Config) Build(ctx context.Context, ns *schema2.NodeSchema, _ ...schema2
|
||||||
|
|
||||||
func (c *Config) RequireCheckpoint() bool {
|
func (c *Config) RequireCheckpoint() bool {
|
||||||
if c.FCParam != nil {
|
if c.FCParam != nil {
|
||||||
if c.FCParam.WorkflowFCParam != nil || c.FCParam.PluginFCParam != nil {
|
if c.FCParam.WorkflowFCParam != nil {
|
||||||
|
if len(c.FCParam.WorkflowFCParam.WorkflowList) > 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.FCParam.PluginFCParam != nil {
|
||||||
|
if len(c.FCParam.PluginFCParam.PluginList) > 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1314,7 +1314,8 @@ func (r *RepositoryImpl) WorkflowAsTool(ctx context.Context, policy vo.GetPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts []compose.WorkflowOption
|
var opts []compose.WorkflowOption
|
||||||
opts = append(opts, compose.WithIDAsName(policy.ID))
|
opts = append(opts, compose.WithIDAsName(policy.ID),
|
||||||
|
compose.WithParentRequireCheckpoint()) // always assumes the 'parent' may pass a checkpoint ID
|
||||||
if s := execute.GetStaticConfig(); s != nil && s.MaxNodeCountPerWorkflow > 0 {
|
if s := execute.GetStaticConfig(); s != nil && s.MaxNodeCountPerWorkflow > 0 {
|
||||||
opts = append(opts, compose.WithMaxNodeCount(s.MaxNodeCountPerWorkflow))
|
opts = append(opts, compose.WithMaxNodeCount(s.MaxNodeCountPerWorkflow))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue