From e16b988300c8bba1bc7ebddbec56e1ad65345362 Mon Sep 17 00:00:00 2001 From: Yulong Zhang Date: Wed, 28 Jan 2026 20:53:52 +0000 Subject: 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. --- .../testdata/TestSummaryWindow.trajectory.json | 234 +++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 pkg/aflow/testdata/TestSummaryWindow.trajectory.json (limited to 'pkg/aflow/testdata/TestSummaryWindow.trajectory.json') diff --git a/pkg/aflow/testdata/TestSummaryWindow.trajectory.json b/pkg/aflow/testdata/TestSummaryWindow.trajectory.json new file mode 100644 index 000000000..bd87b214f --- /dev/null +++ b/pkg/aflow/testdata/TestSummaryWindow.trajectory.json @@ -0,0 +1,234 @@ +[ + { + "Seq": 0, + "Nesting": 0, + "Type": "flow", + "Name": "test", + "Started": "0001-01-01T00:00:01Z" + }, + { + "Seq": 1, + "Nesting": 1, + "Type": "agent", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:02Z", + "Instruction": "Instructions\nPrefer calling several tools at the same time to save round-trips.\n", + "Prompt": "Initial Prompt" + }, + { + "Seq": 2, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:03Z" + }, + { + "Seq": 2, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:03Z", + "Finished": "0001-01-01T00:00:04Z" + }, + { + "Seq": 3, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:05Z" + }, + { + "Seq": 3, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:05Z", + "Finished": "0001-01-01T00:00:06Z", + "Results": { + "ResFoo": 123 + } + }, + { + "Seq": 4, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:07Z" + }, + { + "Seq": 4, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:07Z", + "Finished": "0001-01-01T00:00:08Z" + }, + { + "Seq": 5, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:09Z" + }, + { + "Seq": 5, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:09Z", + "Finished": "0001-01-01T00:00:10Z", + "Results": { + "ResFoo": 123 + } + }, + { + "Seq": 6, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:11Z" + }, + { + "Seq": 6, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:11Z", + "Finished": "0001-01-01T00:00:12Z" + }, + { + "Seq": 7, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:13Z" + }, + { + "Seq": 7, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:13Z", + "Finished": "0001-01-01T00:00:14Z", + "Results": { + "ResFoo": 123 + } + }, + { + "Seq": 8, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:15Z" + }, + { + "Seq": 8, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:15Z", + "Finished": "0001-01-01T00:00:16Z" + }, + { + "Seq": 9, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:17Z" + }, + { + "Seq": 9, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:17Z", + "Finished": "0001-01-01T00:00:18Z", + "Results": { + "ResFoo": 123 + } + }, + { + "Seq": 10, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:19Z" + }, + { + "Seq": 10, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:19Z", + "Finished": "0001-01-01T00:00:20Z" + }, + { + "Seq": 11, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:21Z" + }, + { + "Seq": 11, + "Nesting": 2, + "Type": "tool", + "Name": "tick", + "Started": "0001-01-01T00:00:21Z", + "Finished": "0001-01-01T00:00:22Z", + "Results": { + "ResFoo": 123 + } + }, + { + "Seq": 12, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:23Z" + }, + { + "Seq": 12, + "Nesting": 2, + "Type": "llm", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:23Z", + "Finished": "0001-01-01T00:00:24Z" + }, + { + "Seq": 1, + "Nesting": 1, + "Type": "agent", + "Name": "summary_agent", + "Model": "model", + "Started": "0001-01-01T00:00:02Z", + "Finished": "0001-01-01T00:00:25Z", + "Instruction": "Instructions\nPrefer calling several tools at the same time to save round-trips.\n", + "Prompt": "Initial Prompt", + "Reply": "Done" + }, + { + "Seq": 0, + "Nesting": 0, + "Type": "flow", + "Name": "test", + "Started": "0001-01-01T00:00:01Z", + "Finished": "0001-01-01T00:00:26Z", + "Results": { + "Reply": "Done" + } + } +] \ No newline at end of file -- cgit mrf-deployment