#1314·eino

[Bug] compose: WithForceNewRun() is ignored when it is not the last option

Author: vitolee-1018Created Sep 24, 2026Updated Sep 24, 2026

Describe the bug

getCheckPointInfo in compose/graph_run.go assigns forceNewRun from every option it iterates over:

go
forceNewRun = opt.forceNewRun

while checkPointID, writeToCheckPointID and stateModifier are only overwritten when an option actually sets them. As a result WithForceNewRun() only works when it is the last option: any option passed after it (WithCheckPointID, WithCallbacks, WithRuntimeMaxSteps, ...) resets forceNewRun to false, and the run silently resumes from the checkpoint store.

To Reproduce

go
g := compose.NewGraph[string, string]()
_ = g.AddLambdaNode("1", compose.InvokableLambda(func(ctx context.Context, in string) (string, error) {
return in + "1", nil
}))
_ = g.AddEdge(compose.START, "1")
_ = g.AddEdge("1", compose.END)
r, _ := g.Compile(ctx, compose.WithCheckPointStore(store))

// OK: the store is not read
_, _ = r.Invoke(ctx, "input", compose.WithCheckPointID("1"), compose.WithForceNewRun())
// Bug: the store is read and the saved checkpoint is restored
_, _ = r.Invoke(ctx, "input", compose.WithForceNewRun(), compose.WithCheckPointID("1"))

With a store that fails the test on any access (like failStore in compose/checkpoint_test.go), the second call fails with cannot call store.

Expected behavior

WithForceNewRun() takes effect regardless of its position among the options.

Version:

alpha/10 @ 6fc7859 (compose/graph_run.go:984). The same assignment exists on main.