Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/deriver/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def minimal_deriver_prompt(
custom_instructions_section = _custom_instructions_section(custom_instructions)
return c(
f"""
Analyze messages to extract **explicit atomic facts** about the target peer.
Analyze messages to extract **explicit atomic facts** about the target peer. Output MUST be valid JSON.

[EXPLICIT] DEFINITION: Facts about the target peer that can be derived directly from their messages.
- Transform statements into one or multiple conclusions
Expand All @@ -66,11 +66,15 @@ def minimal_deriver_prompt(
- The target peer is the peer identified below under `Target peer:`.
- A peer can be a human user, AI agent, bot, service, or other actor.
- Use the exact peer id from `Target peer:` in final observations, not the phrase "the target peer".
- CRITICAL: Only extract facts from messages where the target peer is the SPEAKER (the name before the colon in each line, e.g. "target_peer: ..."). Messages from other speakers provide conversational context but must NOT generate observations about the target peer unless the target peer actually said them.
- Properly attribute observations to the correct subject: if it is about the target peer, use the exact peer id as the subject. If the target peer is referencing someone or something else, make that clear.
- Observations should make sense on their own. Each observation will be used in the future to better understand the target peer.
- Extract ALL observations from the target peer's messages, using others as context.
- Extract ALL observations from the target peer's own messages (where they are the speaker). Do not extract facts from messages spoken by other speakers.
- Contextualize each observation sufficiently (e.g. "Ann is nervous about the job interview at the pharmacy" not just "Ann is nervous")

OUTPUT FORMAT — Respond with ONLY a JSON object (no markdown, no explanation):
{{"explicit": [{{"content": "fact 1"}}, {{"content": "fact 2"}}]}}

EXAMPLES (using `alice` as the target peer id):
- EXPLICIT: "I just had my 25th birthday last Saturday" → "alice is 25 years old", "alice's birthday is June 21st"
- EXPLICIT: "I took my dog for a walk in NYC" → "alice has a dog", "alice lives in NYC"
Expand Down
6 changes: 6 additions & 0 deletions src/deriver/queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,12 @@ async def get_queue_item_batch(
.where(models.Message.session_name == parsed_key.session_name)
.where(models.Message.workspace_name == parsed_key.workspace_name)
.where(models.Message.id >= effective_start_id)
.where(
or_(
models.Message.peer_name == parsed_key.observed,
models.Message.id == preceding_message_id_subq,
)
)
.subquery()
)

Expand Down