You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e6e9dee
Browse filesBrowse the repository at this point in the historyBrowse files
[NO-JIRA] Rolling memory on the state machine: fold older history at turn start (R12)
Ports rolling memory from the v1.54 legacy loop to the 1.60 state machine
pipeline as RollingMemoryOperation.
Design summary:
- Operation timing: Runs at turn start when `messages_since_kickoff` has
length 1 (the kickoff user prompt).
- Estimation context: `prepare_system_and_tools` approximates the inference
system prompt using PromptManager with session recipe instructions and
project instructions, along with tools resolved via
`services.current_session_snapshot`. This closely approximates the actual
inference request for token counting.
- Once-per-turn guard: Combination of durable message metadata operation
note (`rolling_memory.folded = true`) applied via `SetMessageOperationNote`
on the kickoff message, plus an in-memory `folded_turns` set on
`RollingMemoryOperation` that records evaluated kickoff IDs across all paths
(fold, not needed, under budget, error) to prevent duplicate runs across
state machine steps or loops in the same turn.
- Compaction gating: Proactive auto-compaction (`ops_compaction.rs`) and tool
pair summarization (`ops_tool_pair_compaction.rs`) are skipped when rolling
memory is active (`rolling::is_on(session)`).
- Session settings & ACP: Added `rollingMemory` (budgetTokens, tailTokens)
to `SetSessionSettingsRequest` in `goose-sdk-types`, `acp-schema.json`, and
ACP server handlers.
Behaviour changed from v1.54:
- Integrated as a state machine `Operation` returning `GooseEffect`s rather
than controlling the agent loop directly.
- `rolling::execute_fold` no longer directly saves compacted conversations
or records metrics; instead, the operation emits `GooseEffect::CompactConversation`
with usage and `SetMessageOperationNote`, preventing double-counting.
- `session_manager.rs` remains untouched upstream; test inspection of the
usage ledger connects directly to the sqlite database via `open_test_db()`.
Tests:
- 44 unit tests in `context_mgmt::rolling` and `prompt_template`
- 8 integration tests in `tests/rolling_memory.rs`
- 6 tests in `tests/acp_session_settings_test.rs`
- 9 tests in `goose-sdk-types`
- All tests verified and listed in `.github/workflows/patched-test.yml`
X-Shepherd-Wake: #30
Copy file name to clipboardExpand all lines: crates/goose/acp-schema.json
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -832,12 +832,23 @@
832
832
"type": "null"
833
833
}
834
834
]
835
+
},
836
+
"rollingMemory": {
837
+
"anyOf": [
838
+
{
839
+
"$ref": "#/$defs/RollingMemoryDto"
840
+
},
841
+
{
842
+
"type": "null"
843
+
}
844
+
],
845
+
"description": "Rolling memory for this session. Absent: unchanged. null: off."
835
846
}
836
847
},
837
848
"required": [
838
849
"sessionId"
839
850
],
840
-
"description": "Pin a session's prompt-cache TTLand recipe, persisted on the session row.\n\nThe recipe is stored on the session and read every turn: its `title`,\n`instructions` and `response` take effect. Its `settings`, `extensions`,\n`prompt` and `parameters` are ignored, `retry` and `sub_recipes` are\ndropped, and the session keeps its model.",
851
+
"description": "Pin a session's prompt-cache TTL, recipe and rolling memory, persisted on the session row.\n\nThe recipe is stored on the session and read every turn: its `title`,\n`instructions` and `response` take effect. Its `settings`, `extensions`,\n`prompt` and `parameters` are ignored, `retry` and `sub_recipes` are\ndropped, and the session keeps its model.",
Copy file name to clipboardExpand all lines: crates/goose/src/acp/server/session_settings.rs
+26-1Lines changed: 26 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
// Modified by Jonathan Mohrbacher, 2026: _goose/unstable/session/settings/set pins a session's cache TTLand recipe; session/prompt _meta.goose.maxTurns bounds the run.
1
+
// Modified by Jonathan Mohrbacher, 2026: _goose/unstable/session/settings/set pins a session's cache TTL, recipe and rolling memory; session/prompt _meta.goose.maxTurns bounds the run.
Copy file name to clipboardExpand all lines: crates/goose/src/agents/state_machine/ops_compaction.rs
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
// Modified by Jonathan Mohrbacher, 2026: compaction failure messages are recognisable as turn errors.
1
+
// Modified by Jonathan Mohrbacher, 2026: compaction failure messages are recognisable as turn errors; skip proactive auto-compaction when rolling memory is on for the session.
2
2
//! Compacts conversation history when it is too large for the configured context window.
3
3
4
4
use std::sync::Arc;
@@ -193,16 +193,21 @@ impl Operation<Session, GooseEffect> for CompactionOperation {
193
193
if context_errors > MAX_CONTEXT_ERROR_COMPACTIONS{
0 commit comments