mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #233] [CLOSED] feat: Oracle agent — web search with lorebook persistence #4520
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4520
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/233
Author: @Beherit79
Created: 4/25/2026
Status: ❌ Closed
Base:
main← Head:feat/oracle-agent📝 Commits (3)
9990c33feat: Oracle agent — web search with lorebook persistence1dc35a0Merge branch 'main' into feat/oracle-agent31cd40cfix(oracle): improve memory recall — LLM-produced concise keys + always-on injection📊 Changes
22 files changed (+2042 additions, -12 deletions)
View changed files
📝
CHANGELOG.md(+6 -0)📝
README.md(+2 -1)📝
docs/CONFIGURATION.md(+20 -0)➕
docs/ORACLE.md(+440 -0)📝
packages/client/src/components/panels/ConnectionsPanel.tsx(+4 -0)➕
packages/client/src/components/panels/settings/OracleConfigCard.tsx(+390 -0)➕
packages/client/src/hooks/use-oracle.ts(+37 -0)📝
packages/server/src/routes/generate.routes.ts(+345 -6)📝
packages/server/src/routes/generate/lorebook-keeper-utils.ts(+18 -4)📝
packages/server/src/routes/index.ts(+2 -0)➕
packages/server/src/routes/oracle.routes.ts(+83 -0)📝
packages/server/src/services/agents/agent-executor.ts(+29 -1)➕
packages/server/src/services/agents/oracle.ts(+338 -0)➕
packages/server/src/services/agents/web-search/config.ts(+53 -0)➕
packages/server/src/services/agents/web-search/tavily-provider.ts(+81 -0)➕
packages/server/src/services/agents/web-search/web-search-provider-factory.ts(+22 -0)➕
packages/server/src/services/agents/web-search/web-search-provider.ts(+15 -0)📝
packages/server/src/services/conversation/character-commands.ts(+36 -0)📝
packages/shared/src/constants/agent-prompts.ts(+34 -0)📝
packages/shared/src/index.ts(+1 -0)...and 2 more files
📄 Description
Why this change
Closes #232
Characters in Marinara are currently stuck with whatever was written in their lore/card. If a user wants to roleplay around something current, e.g a real-world event, recent news, an actual schedule, there is currently no clean way to get that information into the character's context. The existing Knowledge Retrieval agent only reads from the local lorebook.
This PR adds Oracle, an opt-in pre-generation agent triggered by
<search>topic</search>in a user message.For the MVP, Oracle fetches web results through Tavily, summarises them with a strict anti-hallucination prompt, injects the summary into the current turn, and can optionally persist a post-reply takeaway as a lorebook entry tagged
web-research.The persistence step intentionally saves what the character actually committed to, what they picked, preferred, dismissed, or remembered, instead of saving raw web results. That keeps future turns useful for RP without filling the lorebook with URLs, provider snippets, or stale search output.
What changed
Server
services/agents/oracle.tsfor the Oracle flow: search → summarise → takeaway extraction.services/agents/web-search/, with Tavily as the first implementation./api/oracle/{config,test}routes.cryptoutil.generate.routes.ts:<search>triggers from the user messageenableAgentsgate when Oracle is explicitly user-triggeredagent-executor.tsso agents can explicitly providesettings.maxTokens.lorebook-keeper-utils.tswith asource?: { agentId, description }parameter so non-LBK agents like Oracle can attribute auto-created lorebook entries correctly.Shared
types/oracle.tsfor the Zod config schema, masked-key constant, and lorebook tag constant.types/agent.ts:BUILT_IN_AGENTSDEFAULT_AGENT_TOOLSweb_searchinBUILT_IN_TOOLSconstants/agent-prompts.ts.Client
OracleConfigCard.tsxin the Connections panel.useOracleReact Query hook for config get/save/test.Docs
docs/ORACLE.mdcovering the end-to-end flow, design decisions, failure modes, and known limits.docs/CONFIGURATION.mdwith an Oracle section under Agent-Specific Configuration.README.mdto mention Oracle in the AI Agent System paragraph and Documentation table.CHANGELOG.mdunder[Unreleased] / Added.Validation
pnpm checkManual verification notes
ok: truewith a non-zero result count.<search>European rugby match this weekend</search>.[oracle] Detected 1 <search> trigger(s)[oracle] Search returned 6 result(s)[oracle] Summariser result — success=trueNO_MEMORY (skipped)when the character only acknowledged the info without making a choice.autoPersist: true, a valid takeaway creates or reuses a lorebook entry taggedweb-research, visible in the lorebook panel.<search>tags pass through as plain text. No API call is made and no Oracle log line is emitted.<search>blocks are ignored without errors.[oracle] Search failedand the character still replies normally without injected findings.Docs and release impact
This is a feature PR, not a release PR. I did not touch version-bearing files. The changelog entry is under
[Unreleased]for maintainers to include in the next release.UI evidence
Oracle agent entry
Settings → Connections → Oracle config card
Masked key and Test button visible.
Chat with
<search>trigger and in-character replyNo, it is not biased lol.
Lorebook entries (Uncategorized)
Lorebook entry details
Different test run from the previous screenshot.
Retrieval
Status
This PR is intended as a concrete proposal for Oracle rather than a final “this is the only shape” implementation.
The code is ready for review and manual testing passes, but I am open to changing the trigger syntax, persistence behavior, config surface, or cutting scope if maintainers prefer a smaller first version.
The issue and this PR description were written with LLM assistance. The feature itself comes from my own use case, and the implementation was manually tested in CONVO.
Summary by CodeRabbit
New Features
<search>topic</search>tags in messagesDocumentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.