[GH-ISSUE #232] [Feature]: Oracle agent — let characters reference live web facts via <search> triggers #89

Closed
opened 2026-10-20 17:25:00 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Beherit79 on GitHub (Apr 25, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/232

What problem does this solve?

Right now, characters are effectively stuck at the point where their card/lore was written.
If a user wants to roleplay (or just CONVO - as i'm on it =^^=) around something current “what’s on at the cinema this weekend?”, “is there a rugby match this Sunday?”, “what are the latest patch notes for X?”, the character has no good way to answer. It either invents something plausible, or breaks immersion by saying it does not know.
The existing Knowledge Retrieval agent only searches the local lorebook, so there is currently no path for live information.

The workaround is to manually edit a lorebook entry every time the user wants the character to know something current. That works, but it is tedious and reverses the normal storytelling flow: you have to write the answer before asking the question.

Proposed solution

A new built-in Oracle agent, opt-in, that fires when the user types <search>topic</search> inside a chat message.

The flow is:

  1. Trigger extraction: server strips <search> tags from the user message before saving / before the main LLM
    sees it.
  2. Web fetch: Tavily search (MVP; provider abstraction so we could add Brave / Exa / SerpAPI later).
  3. Strict summary: Oracle summarizes the results with an anti-hallucination prompt: no first person, no character voice, no inferred facts
  4. Injection : the summary is wrapped in <web_search> and appended to the user message before the main generation,
    so the character answers from real material.
  5. Memory persistence (optional) : after the character replies, a second LLM pass distils what the character
    "committed to" such as choices, preferrenced or dismissed options and saves that as a lorebook entry tagged web-research. The
    takeaway is saved, not the raw web facts and urls, so the lorebook stays "relevant".

Configuration would lives under Settings → Connections → Oracle with options, ex:

  • provider,
  • encrypted API key,
  • max results (1–10),
  • summary token cap (100–2000),
  • timeout,
  • auto-persist toggle.

Alternatives considered

Slash command

/web_search query --save
This probably fits best with the existing slash-command system in packages/client/src/lib/slash-commands.ts, alongside /roll, /sys, /narrator, /scene, etc.

advantages:

  • it is discoverable through /help and autocomplete
  • flags like --save, --no-save, or --max=5 are cleaner than XML-style attributes
  • typos fail loudly, for example /web_serch, instead of leaking a malformed tag into the conversation

I still think the inline tag fits this specific use case better, because Oracle is not just a lookup utility. It is meant to augment a specific turn.

With a slash command, the flow tends to become:

User:  /web_search films this week  
System: [results displayed]  
User:  Which one do you want to see?  
Char:  ???  (No context)  

At that point, the results still need to get into the character’s context somehow. Either the app re-injects them into the next user message, generates some kind of filler response, or asks the user to copy-paste the findings.

So i prefered to "search" using the message that prompts the character to use it:

User:  Which one do you want to see? <search>films this week</search>  
    ↓ server strip + inline injection + main LLM call   
Char:  Masters of the Universe looks amazing, want to try the 8pm showing?  

That said, both can coexist. A later /web_search command could call the same executeOracle() backend for users who want a plain lookup outside an in-character message

Generic tool calling

Letting the model decide when to search would be more automatic, but I do not think it is the right MVP.

It makes behavior harder to debug: did the model search or not? It also makes every message a possible search candidate, which has cost and latency implications. It is also less reliable for small local models that may not follow tool schemas consistently.

Extending Knowledge Retrieval

KR currently read-only against the local lorebook. Adding web access there would mix two very different pipelines: local retrieval and live external search. They have different cost, latency, failure modes, and privacy expectations.

Manual lorebook entry

This is the current workaround. It works, but it does not scale and it breaks the flow of roleplay

Additional context

  • MVP scope: one query per turn, Tavily-only.
  • Non-goals for v1: streaming search results, multi-provider fan-out, scheduled background searches.
  • I already have an implementation ready in a draft PR, but I am happy to rework or drop the approach.
  • Documentation: docs/ORACLE.md covers the full flow + design decisions.
  • Currently only using it sparingly in CONVO
  • This issue and the related PR were written with LLM assistance, the design and implementation are based on my own use case and testing
  • Non breaking change
  • Implementation draft #233

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Beherit79 on GitHub (Apr 25, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/232 ## What problem does this solve? Right now, characters are effectively stuck at the point where their card/lore was written. If a user wants to roleplay (or just CONVO - as i'm on it =^^=) around something current “what’s on at the cinema this weekend?”, “is there a rugby match this Sunday?”, “what are the latest patch notes for X?”, the character has no good way to answer. It either invents something plausible, or breaks immersion by saying it does not know. The existing Knowledge Retrieval agent only searches the local lorebook, so there is currently no path for live information. The workaround is to manually edit a lorebook entry every time the user wants the character to know something current. That works, but it is tedious and reverses the normal storytelling flow: you have to write the answer before asking the question. ## Proposed solution A new built-in **Oracle** agent, opt-in, that fires when the user types `<search>topic</search>` inside a chat message. The flow is: 1. **Trigger extraction**: server strips `<search>` tags from the user message before saving / before the main LLM sees it. 2. **Web fetch**: Tavily search (MVP; provider abstraction so we could add Brave / Exa / SerpAPI later). 3. **Strict summary**: Oracle summarizes the results with an anti-hallucination prompt: no first person, no character voice, no inferred facts 4. **Injection** : the summary is wrapped in `<web_search>` and appended to the user message before the main generation, so the character answers from real material. 5. **Memory persistence (optional)** : after the character replies, a second LLM pass distils what the character "committed to" such as choices, preferrenced or dismissed options and saves that as a lorebook entry tagged `web-research`. The takeaway is saved, not the raw web facts and urls, so the lorebook stays "relevant". Configuration would lives under Settings → Connections → Oracle with options, ex: * provider, * encrypted API key, * max results (1–10), * summary token cap (100–2000), * timeout, * auto-persist toggle. ## Alternatives considered ### Slash command `/web_search query --save` This probably fits best with the existing slash-command system in packages/client/src/lib/slash-commands.ts, alongside /roll, /sys, /narrator, /scene, etc. advantages: * it is discoverable through /help and autocomplete * flags like --save, --no-save, or --max=5 are cleaner than XML-style attributes * typos fail loudly, for example /web_serch, instead of leaking a malformed tag into the conversation I still think the inline tag fits this specific use case better, because Oracle is not just a lookup utility. It is meant to augment a specific turn. With a slash command, the flow tends to become: User: /web_search films this week System: [results displayed] User: Which one do you want to see? Char: ??? (No context) At that point, the results still need to get into the character’s context somehow. Either the app re-injects them into the next user message, generates some kind of filler response, or asks the user to copy-paste the findings. So i prefered to "search" using the message that *prompts* the character to use it: User: Which one do you want to see? <search>films this week</search> ↓ server strip + inline injection + main LLM call Char: Masters of the Universe looks amazing, want to try the 8pm showing? That said, both can coexist. A later /web_search command could call the same executeOracle() backend for users who want a plain lookup outside an in-character message ### Generic tool calling Letting the model decide when to search would be more automatic, but I do not think it is the right MVP. It makes behavior harder to debug: did the model search or not? It also makes every message a possible search candidate, which has cost and latency implications. It is also less reliable for small local models that may not follow tool schemas consistently. ### Extending Knowledge Retrieval KR currently read-only against the local lorebook. Adding web access there would mix two very different pipelines: local retrieval and live external search. They have different cost, latency, failure modes, and privacy expectations. ### Manual lorebook entry This is the current workaround. It works, but it does not scale and it breaks the flow of roleplay ## Additional context * MVP scope: one query per turn, Tavily-only. * Non-goals for v1: streaming search results, multi-provider fan-out, scheduled background searches. * I already have an implementation ready in a draft PR, but I am happy to rework or drop the approach. * Documentation: `docs/ORACLE.md` covers the full flow + design decisions. * Currently only using it sparingly in CONVO * This issue and the related PR were written with LLM assistance, the design and implementation are based on my own use case and testing * Non breaking change * Implementation draft #233 ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:25:00 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Apr 28, 2026):

Waiting for PR.

<!-- gh-comment-id:4333955327 --> @SpicyMarinara commented on GitHub (Apr 28, 2026): Waiting for PR.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#89
No description provided.