fix: checkpoint store correctly initialize in multi-layered sub-workf… (#755)

This commit is contained in:
shentongmartin 2025-08-14 16:34:39 +08:00 committed by GitHub
parent c79ee64fe8
commit 3030d4d627
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 9 deletions

View File

@ -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
} }

View File

@ -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
} }

View File

@ -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,8 +756,16 @@ 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 {
return true if len(c.FCParam.WorkflowFCParam.WorkflowList) > 0 {
return true
}
}
if c.FCParam.PluginFCParam != nil {
if len(c.FCParam.PluginFCParam.PluginList) > 0 {
return true
}
} }
} }

View File

@ -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))
} }