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
|
||||
sc *schema.WorkflowSchema, // the workflow this NodeSchema is in
|
||||
deps *dependencyInfo, // the dependency for this node pre-calculated by workflow engine
|
||||
requireCheckpoint bool,
|
||||
) (_ *Node, err error) {
|
||||
defer func() {
|
||||
if panicErr := recover(); panicErr != nil {
|
||||
|
|
@ -87,7 +88,7 @@ func New(ctx context.Context, s *schema.NodeSchema,
|
|||
|
||||
return &Node{Lambda: s.Lambda}, nil
|
||||
case entity.NodeTypeSubWorkflow:
|
||||
subWorkflow, err := buildSubWorkflow(ctx, s, sc.RequireCheckpoint())
|
||||
subWorkflow, err := buildSubWorkflow(ctx, s, requireCheckpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ func (w *Workflow) addNodeInternal(ctx context.Context, ns *schema.NodeSchema, i
|
|||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -731,10 +731,7 @@ func (c *Config) Build(ctx context.Context, ns *schema2.NodeSchema, _ ...schema2
|
|||
_ = g.AddEdge(llmNodeKey, outputConvertNodeKey)
|
||||
_ = g.AddEdge(outputConvertNodeKey, compose.END)
|
||||
|
||||
requireCheckpoint := false
|
||||
if len(tools) > 0 {
|
||||
requireCheckpoint = true
|
||||
}
|
||||
requireCheckpoint := c.RequireCheckpoint()
|
||||
|
||||
var compileOpts []compose.GraphCompileOption
|
||||
if requireCheckpoint {
|
||||
|
|
@ -759,11 +756,19 @@ func (c *Config) Build(ctx context.Context, ns *schema2.NodeSchema, _ ...schema2
|
|||
|
||||
func (c *Config) RequireCheckpoint() bool {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if c.FCParam.PluginFCParam != nil {
|
||||
if len(c.FCParam.PluginFCParam.PluginList) > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1314,7 +1314,8 @@ func (r *RepositoryImpl) WorkflowAsTool(ctx context.Context, policy vo.GetPolicy
|
|||
}
|
||||
|
||||
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 {
|
||||
opts = append(opts, compose.WithMaxNodeCount(s.MaxNodeCountPerWorkflow))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue