<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ephemerawiki.space/index.php?action=history&amp;feed=atom&amp;title=Help%3AEphemera_Agent%2FSystem_Overview</id>
	<title>Help:Ephemera Agent/System Overview - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ephemerawiki.space/index.php?action=history&amp;feed=atom&amp;title=Help%3AEphemera_Agent%2FSystem_Overview"/>
	<link rel="alternate" type="text/html" href="https://ephemerawiki.space/index.php?title=Help:Ephemera_Agent/System_Overview&amp;action=history"/>
	<updated>2026-05-19T13:31:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://ephemerawiki.space/index.php?title=Help:Ephemera_Agent/System_Overview&amp;diff=3&amp;oldid=prev</id>
		<title>EphemeraAdmin: Import: Help:Ephemera Agent/System Overview</title>
		<link rel="alternate" type="text/html" href="https://ephemerawiki.space/index.php?title=Help:Ephemera_Agent/System_Overview&amp;diff=3&amp;oldid=prev"/>
		<updated>2026-04-01T04:29:27Z</updated>

		<summary type="html">&lt;p&gt;Import: Help:Ephemera Agent/System Overview&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:Ephemera Agent — System Overview}}&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Project Summary ==&lt;br /&gt;
&lt;br /&gt;
Encyclopedia Ephemera is a self-expanding, AI-assisted MediaWiki system for collaborative science-fiction worldbuilding. Set in the populated Solar System of the year 2300, it combines a structured wiki knowledge base with a browser-based LLM agent interface that can read, write, and reason about wiki content using natural language.&lt;br /&gt;
&lt;br /&gt;
The system is built around a core principle: &amp;#039;&amp;#039;&amp;#039;all agent behavior, content standards, and editorial policies are defined inside the wiki itself&amp;#039;&amp;#039;&amp;#039;, making the system self-documenting and self-configuring.&lt;br /&gt;
&lt;br /&gt;
This approach is referred to throughout the documentation as the &amp;#039;&amp;#039;&amp;#039;wiki-native configuration model&amp;#039;&amp;#039;&amp;#039;: core behavior lives in wiki pages, not hard-coded prompt files.&lt;br /&gt;
&lt;br /&gt;
The system integrates:&lt;br /&gt;
* A MediaWiki installation as the knowledge base and instruction store&lt;br /&gt;
* A browser-based LLM agent UI (Ephemera Agent) with multi-provider support&lt;br /&gt;
* A PHP context-assembly pipeline that gathers relevant wiki content before generation&lt;br /&gt;
* A structured &amp;lt;code&amp;gt;Instructions:&amp;lt;/code&amp;gt; namespace that defines agent behavior as wiki pages&lt;br /&gt;
* A &amp;lt;code&amp;gt;Sources:&amp;lt;/code&amp;gt; namespace for in-universe evidence documents with Talk page interpretation&lt;br /&gt;
* Native tool calling for all supported LLM providers (no JSON parsing fragility)&lt;br /&gt;
* Wikipedia API integration for real-world scientific and historical grounding&lt;br /&gt;
* Bulk import tools for JSON and MediaWiki XML dump formats&lt;br /&gt;
&lt;br /&gt;
== System Architecture ==&lt;br /&gt;
&lt;br /&gt;
=== High-Level Call Flow ===&lt;br /&gt;
&lt;br /&gt;
The system has two parallel request paths from the browser:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! Component !! Role&lt;br /&gt;
|-&lt;br /&gt;
| Browser → &amp;lt;code&amp;gt;proxy.php&amp;lt;/code&amp;gt; || Wiki API calls from the agent loop (read/write pages, search, tokens)&lt;br /&gt;
|-&lt;br /&gt;
| Browser → &amp;lt;code&amp;gt;llm-proxy.php&amp;lt;/code&amp;gt; || Direct LLM calls with no context assembly (simple queries, maintenance)&lt;br /&gt;
|-&lt;br /&gt;
| Browser → &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; || Context-aware generative tasks (article creation, editing, source generation)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;wiki_api.php&amp;lt;/code&amp;gt; || All wiki and Wikipedia content retrieval during context assembly&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;context.php&amp;lt;/code&amp;gt; || Context assembly pipeline (classify → gather → rank → trim)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;classify.php&amp;lt;/code&amp;gt; || Planner LLM call: task classification and entity extraction&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; → &amp;lt;code&amp;gt;llm-proxy.php&amp;lt;/code&amp;gt; || Generator LLM call with assembled context in system prompt&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Server-Side PHP Components ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! File !! Responsibility&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;proxy.php&amp;lt;/code&amp;gt; || CORS-aware MediaWiki API proxy. Forwards browser requests to the local wiki API, rewrites Set-Cookie headers for cross-origin session management, handles multipart file uploads for XML import.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;llm-proxy.php&amp;lt;/code&amp;gt; || Multi-provider LLM proxy with native tool calling. Translates a unified tool schema (OpenAI format) to each provider&amp;#039;s native format. Returns a normalised response envelope: &amp;lt;code&amp;gt;{text, tool_calls, stop_reason}&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;wiki_api.php&amp;lt;/code&amp;gt; || Pure MediaWiki API wrapper. Fetch pages, batch-fetch pages, get links, search, extract talk page sections, parse JSON blocks, estimate tokens, rank by frequency. Also contains Wikipedia API functions.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;context.php&amp;lt;/code&amp;gt; || Context assembly pipeline. Resolves the instruction dependency graph, performs 1-hop link expansion, retrieves sources and filtered talk pages, deduplicates, ranks by keyword overlap, trims to token budget.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;classify.php&amp;lt;/code&amp;gt; || Planner LLM call. Classifies task type, extracts named entities, detects source subtypes. Contains &amp;lt;code&amp;gt;is_obviously_query()&amp;lt;/code&amp;gt; fast pre-check for read-only tasks.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; || Main orchestrator. Runs: config load → pre-check → classify → build_context → assemble augmented system prompt → forward to generator via llm-proxy.php.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Native Tool Calling ===&lt;br /&gt;
&lt;br /&gt;
All LLM providers are called using their native tool/function calling APIs — not prompt-only JSON discipline. This eliminates the entire class of JSON parsing failures that plague prompt-based agent systems.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! Provider !! Tool Calling Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| Anthropic || &amp;lt;code&amp;gt;tool_use&amp;lt;/code&amp;gt; content blocks. Response extracted from &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; field (already a parsed object).&lt;br /&gt;
|-&lt;br /&gt;
| OpenAI || &amp;lt;code&amp;gt;tools&amp;lt;/code&amp;gt; array with function type. Arguments are a JSON string — one &amp;lt;code&amp;gt;JSON.parse&amp;lt;/code&amp;gt;, guaranteed valid.&lt;br /&gt;
|-&lt;br /&gt;
| Gemini || &amp;lt;code&amp;gt;functionDeclarations&amp;lt;/code&amp;gt; via native Gemini endpoint. Response from &amp;lt;code&amp;gt;functionCall.args&amp;lt;/code&amp;gt; (already parsed).&lt;br /&gt;
|-&lt;br /&gt;
| Custom || OpenAI-compatible format forwarded as-is to any endpoint that supports the OpenAI tool calling protocol.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
All providers return results through a normalised envelope so the JavaScript agent loop uses one code path regardless of which model is active.&lt;br /&gt;
&lt;br /&gt;
== Wiki Namespace Design ==&lt;br /&gt;
&lt;br /&gt;
The wiki is organised around four distinct content layers. Strict separation between layers is a core design principle.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width:100%&amp;quot;&lt;br /&gt;
! Namespace !! Purpose &amp;amp; Rules&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Instructions:&amp;lt;/code&amp;gt; || Out-of-universe. Machine-readable operational content. Defines agent behavior, page schemas, style guides, and workflows. Never shown to readers.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Sources:&amp;lt;/code&amp;gt; || In-universe. Primary evidence documents. Written from an in-world perspective. May be biased, incomplete, or contradictory — this is intentional.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Talk:&amp;lt;/code&amp;gt; (for Sources) || Interpretive layer. Contains reliability assessments, bias analysis, and editorial notes. Not canonical evidence. Filtered (never dumped whole) when included in context. Talk pages are interpretive and are never treated as primary evidence.&lt;br /&gt;
|-&lt;br /&gt;
| Main namespace || Reader-facing encyclopedia articles. Synthesized from Sources, guided by Instructions.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Help:&amp;lt;/code&amp;gt; || Human-readable documentation for the Ephemera Agent tool itself.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Separation of concerns&amp;#039;&amp;#039;&amp;#039; — Instructions ≠ Sources ≠ Encyclopedia ≠ Talk. Each layer has one job.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Evidence-based synthesis&amp;#039;&amp;#039;&amp;#039; — encyclopedia articles derive from sources, not from LLM imagination alone.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Wiki-native configuration&amp;#039;&amp;#039;&amp;#039; — agent behavior is defined in wiki pages, editable without code changes.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Modularity&amp;#039;&amp;#039;&amp;#039; — instruction pages are composable via dependency graphs.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Agent-first design&amp;#039;&amp;#039;&amp;#039; — the system is built for LLM interaction, not just human editing.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Interpretability&amp;#039;&amp;#039;&amp;#039; — bias and reliability are explicitly modeled, not assumed away.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Epistemic humility&amp;#039;&amp;#039;&amp;#039; — sources can be wrong, biased, or contradictory. That is not a bug.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Auditability&amp;#039;&amp;#039;&amp;#039; — every agent edit is watchlisted and metadata-stamped for review.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;No JSON fragility&amp;#039;&amp;#039;&amp;#039; — native tool calling APIs are used throughout.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Tiered inference&amp;#039;&amp;#039;&amp;#039; — cheap fast models for planning, expensive models for generation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Safe Usage Guidelines ==&lt;br /&gt;
&lt;br /&gt;
See [[Help:Ephemera Agent#Safe Usage Guidelines]] on the main help page.&lt;br /&gt;
&lt;br /&gt;
== Current Status ==&lt;br /&gt;
&lt;br /&gt;
=== Implemented and Working ===&lt;br /&gt;
&lt;br /&gt;
* Full agent loop with native tool calling (Anthropic, OpenAI, Gemini, Custom)&lt;br /&gt;
* Multi-tier model routing (planner / generator independently configured)&lt;br /&gt;
* Wiki browser with preview rendering, LCS diff, search, back navigation&lt;br /&gt;
* Red link autogeneration (click-to-generate and batch modes)&lt;br /&gt;
* Post-edit: watchlist, talk page metadata, auto-preview of edited page&lt;br /&gt;
* Bulk import: JSON (3 formats) and MediaWiki XML dump&lt;br /&gt;
* Credentials file loading (&amp;lt;code&amp;gt;ephemera-keys.json&amp;lt;/code&amp;gt;)&lt;br /&gt;
* Settings persistence via localStorage&lt;br /&gt;
* Mode indicator and context preview panel in UI&lt;br /&gt;
* Context assembly PHP pipeline (all four PHP files)&lt;br /&gt;
* Wikipedia API integration for real-world grounding&lt;br /&gt;
* &amp;lt;code&amp;gt;Instructions:Config&amp;lt;/code&amp;gt; wiki page for runtime configuration&lt;br /&gt;
&lt;br /&gt;
=== Pending Test ===&lt;br /&gt;
&lt;br /&gt;
* End-to-end context assembly (requires &amp;lt;code&amp;gt;Instructions:&amp;lt;/code&amp;gt; namespace to be populated)&lt;br /&gt;
* Planner model classification accuracy on real tasks&lt;br /&gt;
* XML import (requires &amp;lt;code&amp;gt;importupload&amp;lt;/code&amp;gt; permission)&lt;br /&gt;
* Red link autogen quality with full context pipeline&lt;br /&gt;
&lt;br /&gt;
=== Known Limitations ===&lt;br /&gt;
&lt;br /&gt;
* The LCS diff algorithm is O(m×n) — may pause on very large pages&lt;br /&gt;
* Preview rendering lacks the wiki&amp;#039;s full CSS — some templates render incorrectly&lt;br /&gt;
* Local LLM servers require a tunnel (ngrok) since &amp;lt;code&amp;gt;agent.php&amp;lt;/code&amp;gt; runs on the remote server&lt;br /&gt;
* Batch operations may hit the 20-iteration agent loop limit on very large tasks&lt;br /&gt;
&lt;br /&gt;
== Long-Term Vision ==&lt;br /&gt;
&lt;br /&gt;
Encyclopedia Ephemera is designed to evolve into a self-expanding, agent-driven knowledge system where content, behavior, and interpretation all live within the wiki itself:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Autonomous content growth&amp;#039;&amp;#039;&amp;#039; — red link detection and generation creates a self-completing wiki&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Consistency maintenance&amp;#039;&amp;#039;&amp;#039; — agents audit for contradictions, missing citations, and continuity errors&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Multi-perspective historiography&amp;#039;&amp;#039;&amp;#039; — the same event seen through multiple biased sources&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Scalable worldbuilding infrastructure&amp;#039;&amp;#039;&amp;#039; — the system grows with the fiction, not against it&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Self-improving instructions&amp;#039;&amp;#039;&amp;#039; — agents can propose and draft changes to their own instruction pages&lt;br /&gt;
&lt;br /&gt;
[[Category:Help]]&lt;br /&gt;
[[Category:EphemeraAgent]]&lt;/div&gt;</summary>
		<author><name>EphemeraAdmin</name></author>
	</entry>
</feed>