diff options
| author | Yulong Zhang <yulongzhang@google.com> | 2026-01-28 20:53:52 +0000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-30 08:54:25 +0000 |
| commit | e16b988300c8bba1bc7ebddbec56e1ad65345362 (patch) | |
| tree | 0932e1502ccb5e83649921be7d148a5ca7fe2b54 /pkg/aflow/flow/patching/patching.go | |
| parent | bfa73b7bfb58dfb6a92b13840be3fee14c88e9ce (diff) | |
pkg/aflow: adding sliding window summary feature
This adds a flow feature (and creates a new flow using it) called
"sliding window summary".
It works by asking the AI to always summarize the latest knowledge,
and then we toss the old messages if they fall outside the context
sliding window.
Diffstat (limited to 'pkg/aflow/flow/patching/patching.go')
| -rw-r--r-- | pkg/aflow/flow/patching/patching.go | 107 |
1 files changed, 60 insertions, 47 deletions
diff --git a/pkg/aflow/flow/patching/patching.go b/pkg/aflow/flow/patching/patching.go index 9ec36ec3f..7c82e77d4 100644 --- a/pkg/aflow/flow/patching/patching.go +++ b/pkg/aflow/flow/patching/patching.go @@ -50,58 +50,71 @@ type Recipient struct { To bool // whether the recipient should be on the To or Cc line } -func init() { +func createPatchingFlow(name string, summaryWindow int) *aflow.Flow { commonTools := slices.Clip(append([]aflow.Tool{codeexpert.Tool}, codesearcher.Tools...)) + return &aflow.Flow{ + Name: name, + Root: aflow.Pipeline( + baseCommitPicker, + kernel.Checkout, + kernel.Build, + // Ensure we can reproduce the crash (and the build boots). + crash.Reproduce, + codesearcher.PrepareIndex, + &aflow.LLMAgent{ + Name: "debugger", + Model: aflow.BestExpensiveModel, + Reply: "BugExplanation", + Temperature: 1, + Instruction: debuggingInstruction, + Prompt: debuggingPrompt, + Tools: commonTools, + SummaryWindow: summaryWindow, + }, + kernel.CheckoutScratch, + &aflow.DoWhile{ + Do: aflow.Pipeline( + &aflow.LLMAgent{ + Name: "patch-generator", + Model: aflow.BestExpensiveModel, + Reply: "PatchExplanation", + Temperature: 1, + Instruction: patchInstruction, + Prompt: patchPrompt, + Tools: append(commonTools, codeeditor.Tool), + SummaryWindow: summaryWindow, + }, + crash.TestPatch, // -> PatchDiff or TestError + ), + While: "TestError", + MaxIterations: 10, + }, + getMaintainers, + &aflow.LLMAgent{ + Name: "description-generator", + Model: aflow.BestExpensiveModel, + Reply: "PatchDescription", + Temperature: 1, + Instruction: descriptionInstruction, + Prompt: descriptionPrompt, + Tools: commonTools, + SummaryWindow: summaryWindow, + }, + ), + } +} +func init() { aflow.Register[Inputs, Outputs]( ai.WorkflowPatching, "generate a kernel patch fixing a provided bug reproducer", - &aflow.Flow{ - Root: aflow.Pipeline( - baseCommitPicker, - kernel.Checkout, - kernel.Build, - // Ensure we can reproduce the crash (and the build boots). - crash.Reproduce, - codesearcher.PrepareIndex, - &aflow.LLMAgent{ - Name: "debugger", - Model: aflow.BestExpensiveModel, - Reply: "BugExplanation", - Temperature: 1, - Instruction: debuggingInstruction, - Prompt: debuggingPrompt, - Tools: commonTools, - }, - kernel.CheckoutScratch, - &aflow.DoWhile{ - Do: aflow.Pipeline( - &aflow.LLMAgent{ - Name: "patch-generator", - Model: aflow.BestExpensiveModel, - Reply: "PatchExplanation", - Temperature: 1, - Instruction: patchInstruction, - Prompt: patchPrompt, - Tools: append(commonTools, codeeditor.Tool), - }, - crash.TestPatch, // -> PatchDiff or TestError - ), - While: "TestError", - MaxIterations: 10, - }, - getMaintainers, - &aflow.LLMAgent{ - Name: "description-generator", - Model: aflow.BestExpensiveModel, - Reply: "PatchDescription", - Temperature: 1, - Instruction: descriptionInstruction, - Prompt: descriptionPrompt, - Tools: commonTools, - }, - ), - }, + createPatchingFlow("", 0), + ) + + aflow.Register[Inputs, Outputs]( + ai.WorkflowPatching, + "generate a kernel patch fixing a provided bug reproducer, with the summary feature", + createPatchingFlow("summary", 10), ) } |
