Skip to content

Add agent-owned Dreams memory policy - #37

Merged
trotsky1997 merged 2 commits into
mainfrom
agent/codex-wsl-gpt5-5/1451b6d8
Jun 2, 2026
Merged

Add agent-owned Dreams memory policy#37
trotsky1997 merged 2 commits into
mainfrom
agent/codex-wsl-gpt5-5/1451b6d8

Conversation

@trotsky1997

Copy link
Copy Markdown
Owner

Summary

  • Add the first local agent-owned Dreams memory synthesis layer as pure policy/state in memory_entry.rs.
  • Add DreamScheduler, explicit ShouldDreamDecision / DreamSkipReason, dream input selection with active/short filtering and the 100-session cap, DreamJob / DreamStatus, and adoption through the existing decide_use gate.
  • Add [memory] min_sessions_between_dreams with default 10, regenerate schema, update example config, archive the OpenSpec change, and document the generated-state/source-evidence boundary.

Handoff Notes

  • This PR intentionally does not call the live Anthropic Dreams API. It adds the local policy/state seam for a later client integration.
  • Dream output is modeled as generated memory state. Original sessions and the input memory store remain source evidence.

Validation

  • cargo fmt --check
  • cargo test --test memory_entry
  • cargo test --test memory_system
  • cargo test config::tests::memory_defaults_disabled_and_parses_aliases
  • cargo test
  • openspec validate add-agent-owned-dreams-memory --strict
  • openspec validate --specs --strict

Co-authored-by: multica-agent <github@multica.ai>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @trotsky1997, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@trotsky1997

Copy link
Copy Markdown
Owner Author

Other Top Model review requested via Multica WS-164, assigned to claude-wsl-opus. Review focus: agent-owned Dreams policy/state seam, skip reasons, input filtering/cap, decide_use adoption gate, config default/schema, and no-live-API boundary.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 767be9751d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/memory_entry.rs Outdated
Comment on lines +253 to +257
pub fn update(&mut self, status: DreamStatus, output_store_id: Option<impl Into<String>>) {
self.status = status;
if let Some(output_store_id) = output_store_id {
self.output_store_id = Some(output_store_id.into());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear stale dream output when updates omit it

If a job is updated with an output while it is still running and a later completion update omits the output store, this branch leaves the previous output_store_id in place; adopt_output will then adopt that stale/partial store even though the completed update had no output. This contradicts the documented gate that completed jobs without an output store must not become active, so update should clear or replace the stored output when output_store_id is None for the new state.

Useful? React with 👍 / 👎.

Comment thread src/memory_entry.rs
Comment on lines +194 to +197
if sessions_since_last_dream < self.policy.min_sessions_between_dreams {
return ShouldDreamDecision::Skip(DreamSkipReason::NotEnoughSessions);
}
ShouldDreamDecision::Dream

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor disabled generation before scheduling dreams

When a user or thread disables generate_memories, should_dream can still return Dream once the session count threshold is met, even though starting a dream creates a new generated memory store. This means the same policy knob that suppresses ordinary memory generation is bypassed for Dreams; the scheduler should skip when generation is disabled before allowing the agent to start synthesis.

Useful? React with 👍 / 👎.

Comment thread src/memory_entry.rs
Comment on lines +211 to +214
.filter(|candidate| {
!candidate.is_active
&& candidate.session_duration >= self.policy.min_session_duration
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude external-context sessions from dream inputs

When [memory] disable_on_external_context = true, a candidate that has has_external_context set still passes this filter and can be sent into a dream as long as it is inactive and long enough. Ordinary memory generation suppresses exactly that case via decide_generation, so Dreams can persist external-context material that the memory policy was configured to avoid; include the same external-context check when selecting inputs.

Useful? React with 👍 / 👎.

@trotsky1997

Copy link
Copy Markdown
Owner Author

Reviewed PR #37 at commit 767be9751dc92baa7ce12be7c397d02476378e75.

Verdict: request changes before merge. The pure Dreams policy/state direction is right, and focused validation is green, but there are material policy/state bugs to fix:

  1. DreamJob::update preserves a prior output_store_id when a later update passes None. A job can be Running with Some("partial-output"), then update to Completed with no output, and adopt_output will adopt the stale store. That violates the completed-output gate.

  2. DreamScheduler::should_dream ignores generate_memories = false. Starting a Dream creates generated memory state, so the same policy knob that suppresses ordinary memory generation should prevent dream scheduling too.

  3. select_dream_inputs ignores disable_on_external_context / has_external_context. With external-context suppression enabled, those sessions are skipped for ordinary memory generation but can still be included in a Dream input batch.

Validation I ran locally from the PR snapshot:

  • cargo fmt --check
  • cargo test --test memory_entry (12 passed)
  • cargo test --test memory_system (7 passed)
  • cargo test config::tests::memory_defaults_disabled_and_parses_aliases (1 passed, 252 filtered)
  • openspec validate --specs --strict (5 passed)
  • cargo run --bin gen-schema > /tmp/ra-pr37-schema.generated and compared with the committed schema: byte-identical

CI is also green. Sourcery did not provide a usable review due to rate limiting; the GitHub Codex inline review flagged the same three issues above.

@trotsky1997
trotsky1997 force-pushed the agent/codex-wsl-gpt5-5/1451b6d8 branch from 87e1761 to 61884a9 Compare June 2, 2026 08:13
@trotsky1997
trotsky1997 merged commit ef809ab into main Jun 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant