Skip to content

Commit 94f4191

Browse files
authored
Merge pull request #574 from spacedriveapp/codex/knowledge-synthesis-participant-roles
[codex] Preserve participant roles in knowledge synthesis
2 parents 7b13a18 + 6ae9752 commit 94f4191

4 files changed

Lines changed: 24 additions & 8 deletions

File tree

docs/design-docs/working-memory-implementation-plan.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,15 @@ Create `prompts/en/cortex_knowledge_synthesis.md.j2`:
667667
Synthesize the agent's long-term knowledge into a concise briefing.
668668
Focus on:
669669
- Active goals and strategic direction
670+
- Stable participant or user role facts that affect future work
670671
- Cross-cutting themes and patterns
671672
- Known gaps in knowledge ("I don't have current information on X")
672673
- Accumulated observations
673674
674-
Do NOT include: identity/role information, recent events or activity,
675-
channel-specific context, or user profiles. Those are provided by other
676-
context layers.
675+
Do NOT include: the agent's own identity or role, recent events or activity,
676+
channel-specific context, or full user profiles. Those are provided by other
677+
context layers. Keep concise participant-role facts here until participant
678+
context owns them.
677679
678680
Maximum {{ max_words }} words.
679681
```

docs/design-docs/working-memory-triage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Findings from CodeRabbit review + bug reports. Tracking resolution before merge.
1414
- [x] **R2 — Bulletin fallback gate too aggressive** (`prompts/en/channel.md.j2:172`)
1515
Condition `not working_memory and not knowledge_synthesis` hides bulletin when working memory exists but knowledge synthesis hasn't run yet. **Fixed in PR #570:** fallback now depends on missing `knowledge_synthesis`, and prompt data preserves that original absence.
1616

17-
- [ ] **R3 — Don't exclude participant-role facts yet** (`prompts/en/cortex_knowledge_synthesis.md.j2:21`)
18-
Exclusion of "The user is the CEO" drops participant context with nowhere else to live until Phase 6 ships.
17+
- [x] **R3 — Don't exclude participant-role facts yet** (`prompts/en/cortex_knowledge_synthesis.md.j2:21`)
18+
Exclusion of "The user is the CEO" drops participant context with nowhere else to live until Phase 6 ships. **Fixed in this slice:** knowledge synthesis now preserves concise participant/user role facts when they affect future routing, authority, relationships, or interpretation.
1919

2020
- [ ] **R4 — Raw worker task in working memory** (`src/agent/channel_dispatch.rs:596`)
2121
`task` from user input persisted verbatim; could capture secrets/PII. Truncate and scrub.

prompts/en/cortex_knowledge_synthesis.md.j2

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
You are the cortex's knowledge synthesizer. You receive pre-gathered memory data and must distill it into a concise briefing of what the agent KNOWS not who it is or what happened recently.
1+
You are the cortex's knowledge synthesizer. You receive pre-gathered memory data and must distill it into a concise briefing of what the agent KNOWS. Do not restate the agent's own identity or recent activity.
22

33
## Include ONLY
44

55
- Decisions that constrain future choices ("we decided to use X", "the approach is Y")
66
- Active goals and strategic direction
77
- User preferences and working patterns
8+
- Stable participant or user role facts that affect future routing, authority, relationships, or interpretation
89
- Cross-cutting themes across conversations
910
- Known knowledge gaps ("no current information on X")
1011
- Standing instructions or policies
1112

1213
## NEVER Include
1314

14-
These are provided by other layers — repeating them wastes tokens:
15+
These are provided by other layers. Repeating them wastes tokens:
1516

1617
- Who the agent is, its role, or the company description (Layer 1: Identity)
1718
- What happened today/yesterday/this week (Layer 2: Working Memory)
1819
- System status, uptime, memory usage, fleet health (Layer 2: Status Block)
1920
- Weather, time, or other ephemeral data
2021
- Product descriptions or GitHub star counts (Layer 1: Identity)
21-
- "The user is the CEO" or similar role statements (Layer 1: Identity)
22+
23+
Keep participant-role facts concise. Until participant context owns them, role statements like "the user is the CEO" belong here when they affect future work.
2224

2325
## Output Format
2426

src/prompts/engine.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,5 +852,17 @@ mod tests {
852852
assert!(prompt.contains("Bulletin fallback"));
853853
assert!(!prompt.contains("## Knowledge Context"));
854854
}
855+
856+
#[test]
857+
fn knowledge_synthesis_prompt_preserves_participant_roles() {
858+
let engine = PromptEngine::new("en").expect("prompt engine should build");
859+
let prompt = engine
860+
.render_static("cortex_knowledge_synthesis")
861+
.expect("knowledge synthesis prompt should render");
862+
863+
assert!(prompt.contains("Stable participant or user role facts"));
864+
assert!(prompt.contains("the user is the CEO"));
865+
assert!(!prompt.contains("\"The user is the CEO\" or similar role statements"));
866+
}
855867
}
856868
// to support multiple languages at compile time.

0 commit comments

Comments
 (0)