Skip to content

Fold agent core memory into the session system prompt#1112

Merged
tlongwell-block merged 1 commit into
mainfrom
eva/core-in-system-prompt-min
Jun 18, 2026
Merged

Fold agent core memory into the session system prompt#1112
tlongwell-block merged 1 commit into
mainfrom
eva/core-in-system-prompt-min

Conversation

@tlongwell-block

Copy link
Copy Markdown
Collaborator

Replaces the over-built #1087 with the minimal version Tyler asked for: move core memory into the system-prompt string the harness already builds, and let existing routing place it.

What changed

  • with_core(framed, core) — small helper that appends the fetched core section onto the framed system prompt. Core already carries its own [Agent Memory — core] header from engram_fetch::build_core_section, so it is joined with a blank line and never re-labeled.
  • Core fetch moved ahead of session creation. It previously ran right after session/new, which was too late for modern agents to receive core in the system role. The per-channel core_sections cache and its invalidation are unchanged; the fetch gate changed from is_new_session to the equivalent pre-match !sessions.contains_key(cid).
  • Modern agents (protocol_version >= 2): core rides the system role via combined_system_prompt at session/new.
  • Legacy agents (protocol_version < 2): format_prompt now renders core in the user message only for legacy agents — modern agents already receive it via the system role and would otherwise double-render it.

What this deliberately does NOT do

No core_sections refactor, no tri-state result type, no _meta migration, no fallback-prompt policy. Failure still injects nothing; confirmed-empty still renders the existing onboarding nudge.

Testing

  • cargo test -p buzz-acp: 338 pass (+5 — four with_core truth-table arms, one guardrail that modern agents omit core from the user message), clippy clean.
  • cargo build --workspace green.
  • buzz-agent is untouched and references none of the changed internals.

Core memory was rendered as a standalone [Agent Memory — core] section in
the per-turn user message for every agent. Move it into the system-prompt
string the harness already builds so existing routing places it correctly:
the system role at session/new for modern agents (protocol_version >= 2),
the [System] user-message section for legacy agents.

To put core on the wire at session/new, the core fetch is relocated ahead
of session creation; the per-channel core_sections cache and its
invalidation are unchanged. A new with_core() helper appends the fetched
section (which carries its own [Agent Memory — core] header) onto the
framed system prompt. format_prompt now only renders core in the user
message for legacy agents, since modern agents already receive it via the
system role and would otherwise double-render it.

Co-authored-by: Tyler Longwell <tlongwell@squareup.com>
Signed-off-by: Tyler Longwell <tlongwell@squareup.com>
@tlongwell-block tlongwell-block merged commit 6335447 into main Jun 18, 2026
29 checks passed
@tlongwell-block tlongwell-block deleted the eva/core-in-system-prompt-min branch June 18, 2026 14:05
tlongwell-block pushed a commit that referenced this pull request Jun 18, 2026
…te-response

* origin/main: (194 commits)
  Fold agent core memory into the session system prompt (#1112)
  feat(cli): add patches and issues commands for NIP-34 git collaboration (#1073)
  fix(desktop): stop random timeline message loss + page reconnect replay (#1105)
  Update README.md
  fix(desktop): keep thread replies from scrolling channel (#1109)
  fix(buzz-acp): accept siblings under allowlist author gate (#1108)
  feat(deploy): add production Helm chart for Buzz (#990)
  fix(desktop): keep MembersSidebar input usable while an add is in flight (#1106)
  chore(release): release version 0.3.25 (#1102)
  fix(desktop): stop dimming deferred message lists (#1104)
  Smooth channel loading: single-surface timeline state machine (#1099)
  feat: surface base + persona system prompts in observer feed (#1103)
  ci: move reminder e2e to a dedicated backend-integration job (#1098)
  fix: give agent-observer sub a replay-capable limit (#1100)
  fix: make managed-agent spawn and teardown portable to Windows (#1097)
  fix(desktop): constrain message timeline width with min-w-0 (#1092)
  feat(desktop): reminders notifications, snooze, overlay, and inbox view mode (#1093)
  feat(prompt): add memory hygiene and hoist universal engineering discipline to base prompt (#1085)
  fix(desktop): correct thread-unread badge flicker, stale clear, phantom count, mention gate, and nested count (#1080)
  Fix mention chip alignment (#1094)
  ...

# Conflicts:
#	crates/buzz-cli/src/commands/workflows.rs
tlongwell-block pushed a commit that referenced this pull request Jun 18, 2026
…te-response

* origin/main: (194 commits)
  Fold agent core memory into the session system prompt (#1112)
  feat(cli): add patches and issues commands for NIP-34 git collaboration (#1073)
  fix(desktop): stop random timeline message loss + page reconnect replay (#1105)
  Update README.md
  fix(desktop): keep thread replies from scrolling channel (#1109)
  fix(buzz-acp): accept siblings under allowlist author gate (#1108)
  feat(deploy): add production Helm chart for Buzz (#990)
  fix(desktop): keep MembersSidebar input usable while an add is in flight (#1106)
  chore(release): release version 0.3.25 (#1102)
  fix(desktop): stop dimming deferred message lists (#1104)
  Smooth channel loading: single-surface timeline state machine (#1099)
  feat: surface base + persona system prompts in observer feed (#1103)
  ci: move reminder e2e to a dedicated backend-integration job (#1098)
  fix: give agent-observer sub a replay-capable limit (#1100)
  fix: make managed-agent spawn and teardown portable to Windows (#1097)
  fix(desktop): constrain message timeline width with min-w-0 (#1092)
  feat(desktop): reminders notifications, snooze, overlay, and inbox view mode (#1093)
  feat(prompt): add memory hygiene and hoist universal engineering discipline to base prompt (#1085)
  fix(desktop): correct thread-unread badge flicker, stale clear, phantom count, mention gate, and nested count (#1080)
  Fix mention chip alignment (#1094)
  ...

Co-authored-by: Tyler Longwell <tlongwell@squareup.com>
Signed-off-by: Tyler Longwell <tlongwell@squareup.com>

# Conflicts:
#	crates/buzz-cli/src/commands/workflows.rs
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