Repository navigation
[NO-JIRA] Rolling memory on the state machine: fold older history at turn start (R12) - #30
Merged
Merged
Conversation
johnnymo87
force-pushed
the
r12-rolling-memory
branch
from
November 22, 2026 06:37
47316e6 to
e751c79
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…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
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
… state writes, slash-command turns * tests/rolling_memory.rs: every test uses a temp-dir SessionManager, and a process-wide Once sets GOOSE_PATH_ROOT and GOOSE_TELEMETRY_OFF before the first goose call, so telemetry's global SessionManager never opens the default DB. * A failed memory call is recorded to the usage ledger with the session's current usage unchanged (as on 1.54), instead of a RecordUsage effect that overwrote it. * Rolling state and the settings/set rollingMemory value are written per key with set_extension_value, so concurrent extension_data changes are not lost. * Turn start is "only user messages since the kickoff", so turns that a slash command starts (agent-only prompt appended before inference) fold too. X-Shepherd-Wake: #30
johnnymo87
force-pushed
the
r12-rolling-memory
branch
from
November 22, 2026 07:50
e751c79 to
929b2f2
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…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
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
… state writes, slash-command turns * tests/rolling_memory.rs: every test uses a temp-dir SessionManager, and a process-wide Once sets GOOSE_PATH_ROOT and GOOSE_TELEMETRY_OFF before the first goose call, so telemetry's global SessionManager never opens the default DB. * A failed memory call is recorded to the usage ledger with the session's current usage unchanged (as on 1.54), instead of a RecordUsage effect that overwrote it. * Rolling state and the settings/set rollingMemory value are written per key with set_extension_value, so concurrent extension_data changes are not lost. * Turn start is "only user messages since the kickoff", so turns that a slash command starts (agent-only prompt appended before inference) fold too. X-Shepherd-Wake: #30
johnnymo87
force-pushed
the
r12-rolling-memory
branch
from
November 22, 2026 08:56
929b2f2 to
50aa183
Compare
…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
… state writes, slash-command turns * tests/rolling_memory.rs: every test uses a temp-dir SessionManager, and a process-wide Once sets GOOSE_PATH_ROOT and GOOSE_TELEMETRY_OFF before the first goose call, so telemetry's global SessionManager never opens the default DB. * A failed memory call is recorded to the usage ledger with the session's current usage unchanged (as on 1.54), instead of a RecordUsage effect that overwrote it. * Rolling state and the settings/set rollingMemory value are written per key with set_extension_value, so concurrent extension_data changes are not lost. * Turn start is "only user messages since the kickoff", so turns that a slash command starts (agent-only prompt appended before inference) fold too. X-Shepherd-Wake: #30
johnnymo87
force-pushed
the
r12-rolling-memory
branch
from
November 22, 2026 10:57
50aa183 to
6e8f785
Compare
johnnymo87
added a commit
that referenced
this pull request
Nov 22, 2026
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ports rolling memory onto the v1.60.2 state machine (R12, workstation-6w7i.26.4.3). When a session goes over its budget, the older history is folded into a first-person memory at turn start. stall-watch coordinators turn it on through
settings/set rollingMemory.Stacked on #25 (R8). This PR's first two commits are #25's. I'll rebase onto
patched/v1.60.2once #25 merges. Per the merge order, this merges after R11.context_mgmt/rolling.rs, and thecompaction_rolling.mdtemplate, byte-identical, since its wording was validated by experiment.RollingMemoryOperation: a fork-only file, registered before CompactionOperation.CompactConversationeffect. That effect saves the history, records the memory call once as compaction usage, and emitsHistoryReplaced./compactstill work.settings/set rollingMemory:{budgetTokens, tailTokens}turns it on andnullturns it off. It is validated (tail >= 1000, budget >= 10000, tail < budget; errors startinvalid rollingMemory:) and stored per key inextension_dataasrolling_memory.v0, which stall-watch reads back.GOOSE_TOOL_DEFERRAL=lookupthe tools are over-counted.Tests: 44 unit tests, 8 integration tests (
tests/rolling_memory.rs) and rollingMemory cases inacp_session_settings_test. All are in the patched-ci exact-test list. The integration tests use a temp-dir session store and switch telemetry off for the whole process, so they never open the default goose data dir.References