Tags: akazwz/twilight-ai
Tags
fix(sdk): harden step loop cancellation and parallelize tool execution - Add ctx.Err() checks at step loop entry in both StreamText and GenerateText to bail out immediately when the context is cancelled, instead of attempting another DoStream/DoGenerate call. - Add a second ctx.Err() check in StreamText after the inner stream consumption loop exits, so a cancelled context skips step result processing and tool execution. - Refactor executeTools into two phases: sequential approval checking followed by parallel tool.Execute via goroutines, using indexed result slots to avoid races. Single-tool calls skip goroutine overhead.
fix: resolve all golangci-lint issues across codebase - errcheck: check json.Unmarshal return values - goconst: extract repeated string literals into constants - gocritic: pass large structs by pointer, fix rangeValCopy, ifElseChain, evalOrder, typeSwitchVar - prealloc: preallocate slices where possible - staticcheck: use type switch assignment, struct conversion - unused: remove unused type