[codex] Preserve participant roles in knowledge synthesis#574
[codex] Preserve participant roles in knowledge synthesis#574
Conversation
WalkthroughThe PR updates the knowledge synthesis prompt to explicitly preserve stable participant or user role facts (e.g., "the user is the CEO") while forbidding restatement of the agent's identity. Design documentation is updated to reflect this behavior change, and a new unit test validates the prompt output. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
9447a87 to
e20c5fb
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
docs/design-docs/working-memory-implementation-plan.md (1)
666-681: Doc drift: inline prompt snippet diverges from the actual template.The inline snippet here is a simplified, lossy paraphrase of
prompts/en/cortex_knowledge_synthesis.md.j2(missing theInclude ONLY/NEVER Includesection structure, the "Do not restate the agent's own identity or recent activity" sentence, and the "Until participant context owns them…" clarifier at the bottom). Since this document is the implementation plan being kept in lockstep with the prompt per R3, consider either trimming this block to a brief reference ("seeprompts/en/cortex_knowledge_synthesis.md.j2") or mirroring the actual template content to avoid future drift.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/design-docs/working-memory-implementation-plan.md` around lines 666 - 681, The inline prompt snippet in the "Synthesize the agent's long-term knowledge..." block diverges from the actual template prompts/en/cortex_knowledge_synthesis.md.j2 (it omits the "Include ONLY"/"NEVER Include" sections, the sentence forbidding restating the agent's identity/recent activity, and the final clarifier); update the snippet to exactly mirror prompts/en/cortex_knowledge_synthesis.md.j2 or replace the block with a single-line reference pointing to that template (e.g., "See prompts/en/cortex_knowledge_synthesis.md.j2") so the implementation plan stays in lockstep and avoids doc drift, ensuring the {{ max_words }} placeholder remains intact.prompts/en/cortex_knowledge_synthesis.md.j2 (1)
13-23: Minor tension between "NEVER Include" block and the participant-role carve-out.The structure reads: "NEVER Include … Who the agent is, its role …" then after the bulleted exclusions a separate paragraph on line 23 re-permits participant/user role statements. That's logically consistent (agent role ≠ participant role), but a reader scanning the "NEVER Include" header may miss the carve-out, and the LLM may over-index on the prohibition. Consider either:
- Moving the line-23 clarifier into the
Include ONLYsection next to the existing participant-role bullet (line 8), or- Scoping the exclusion bullet explicitly, e.g. "Who the agent is, the agent's role…" to make it clear the prohibition is about the agent's own identity, not participants'.
📝 Suggested wording tweak
-- Who the agent is, its role, or the company description (Layer 1: Identity) +- Who the agent is, the agent's own role, or the company description (Layer 1: Identity)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@prompts/en/cortex_knowledge_synthesis.md.j2` around lines 13 - 23, The "NEVER Include" block is ambiguous about participant roles vs agent identity; update the template so readers and the LLM can't misinterpret it by either moving the existing participant-role clarifier (the sentence on line 23) into the "Include ONLY" section next to the participant-role bullet, or explicitly scope the exclusion bullet to the agent (change the bullet text to something like "Who the agent is, the agent's role, or the company description") so the prohibition clearly applies to the agent's identity and not participants.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/design-docs/working-memory-implementation-plan.md`:
- Around line 666-681: The inline prompt snippet in the "Synthesize the agent's
long-term knowledge..." block diverges from the actual template
prompts/en/cortex_knowledge_synthesis.md.j2 (it omits the "Include ONLY"/"NEVER
Include" sections, the sentence forbidding restating the agent's identity/recent
activity, and the final clarifier); update the snippet to exactly mirror
prompts/en/cortex_knowledge_synthesis.md.j2 or replace the block with a
single-line reference pointing to that template (e.g., "See
prompts/en/cortex_knowledge_synthesis.md.j2") so the implementation plan stays
in lockstep and avoids doc drift, ensuring the {{ max_words }} placeholder
remains intact.
In `@prompts/en/cortex_knowledge_synthesis.md.j2`:
- Around line 13-23: The "NEVER Include" block is ambiguous about participant
roles vs agent identity; update the template so readers and the LLM can't
misinterpret it by either moving the existing participant-role clarifier (the
sentence on line 23) into the "Include ONLY" section next to the
participant-role bullet, or explicitly scope the exclusion bullet to the agent
(change the bullet text to something like "Who the agent is, the agent's role,
or the company description") so the prohibition clearly applies to the agent's
identity and not participants.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 80245db4-2cbd-45e2-b244-f27a25300f72
📒 Files selected for processing (4)
docs/design-docs/working-memory-implementation-plan.mddocs/design-docs/working-memory-triage.mdprompts/en/cortex_knowledge_synthesis.md.j2src/prompts/engine.rs
jamiepine
left a comment
There was a problem hiding this comment.
LGTM. Good call keeping role facts here until participant context owns them.
Summary
Testing
cargo test -p spacebot prompts::engine::tests::knowledge_synthesis_prompt_preserves_participant_roles -- --test-threads=1cargo test -p spacebot prompts::engine::tests -- --test-threads=1cargo fmt --alljust preflightjust gate-prNotes
Note
AI-Generated Summary: This PR updates the cortex knowledge synthesis prompt to properly preserve stable participant role facts that influence future decision-making and context assembly. The change refines what gets stored in the agent's knowledge synthesis layer—excluding the agent's own identity and ephemeral data while retaining user role information like "the CEO" that provides behavioral context for future interactions. The implementation includes a targeted test verifying that participant roles are preserved while role explanations and full user profiles are appropriately excluded.
Written by Tembo for commit 9447a87. This will update automatically on new commits.