Wikantik Agent Context Guide: Session Briefings, MCP Grounding, and Autonomous Escalation

Wikantik delivers grounding context to AI agents through an architectural model known as RAG-as-a-Service. Rather than forcing caller frameworks to implement custom chunkers, vector searchers, graph traversers, and deduplicators, Wikantik performs server-side assembly, ranking, de-duplication, and version-pinned citation generation.

Crucially, Wikantik never synthesizes answers—it returns raw, citation-bearing context bundles and structured briefings, leaving reasoning and code generation to the agent model.


1. The Two Moments of Agent Context Delivery

Context injection is partitioned into two distinct operational moments:

+-------------------------------------------------------------------------------+
|                       WIKANTIK DUAL-MOMENT CONTEXT ARCHITECTURE               |
+-------------------------------------------------------------------------------+
| MOMENT A: Session Start (Proactive Standing Context)                         |
| - Fires ONCE when a session or fresh context window starts                    |
| - Ingests repo-level pinned pages, domain clusters, and initial user prompt   |
| - Transports: `GET /api/briefing?format=md` (Hooks) or `get_briefing` (MCP)  |
|                                                                               |
| MOMENT C: Mid-Session Directed Pulls (Reactive Grounding)                     |
| - Fires whenever the agent encounters follow-up questions during work         |
| - Primary tool: `assemble_bundle(query, mode="hybrid")`                       |
| - Evaluates `coverage.confidence` signal ('strong', 'partial', 'weak')       |
| - Triggers autonomous traversal up the 4-tier MCP Escalation Ladder           |
+-------------------------------------------------------------------------------+

2. Moment A: Session-Start Briefing Setup

A Context Briefing front-loads the architectural rules, runbooks, and design decisions of the repository before the agent writes a single line of code.

The Server-Side Assembly Algorithm

When GET /api/briefing or get_briefing is called, Wikantik fills the token budget (200 \le \text{budget} \le 24,000, default 6,000) in strict priority order:

  1. Prompt-Refined Sections: Runs the user's prompt through BundleAssemblyService, extracting hybrid BM25 + dense sections scoped to the requested clusters.
  2. Pinned Pages (pins): Ingests full bodies of load-bearing pages (e.g., ArchitectureRules, CodingStandards) in the exact order specified.
  3. Cluster Member Pages (clusters): Ingests cluster hub pages and recently modified member pages while budget permits.
  4. Pointer Degradation Footer: If the token budget is reached, remaining pages are rendered as a lightweight index of titles, summaries, and fetch instructions.

Option 1: Deterministic Hook Setup for Google Antigravity (Preferred)

The hook executes outside the agent before the initial model call, fetches the briefing via REST, and injects it into additionalContext.

1. Copy the Briefing Hook Script

Copy clients/antigravity/antigravity-briefing-hook.sh into your repository:

mkdir -p clients/antigravity
cp /path/to/jspwiki/clients/antigravity/antigravity-briefing-hook.sh clients/antigravity/
chmod +x clients/antigravity/antigravity-briefing-hook.sh

2. Register the PreInvocation Hook in .agents/hooks.json

Create or update <project_root>/.agents/hooks.json:

{
  "wikantik-briefing": {
    "PreInvocation": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "./clients/antigravity/antigravity-briefing-hook.sh",
            "timeout": 15
          }
        ]
      }
    ]
  }
}

3. Configure Environment Variables

Set the following environment variables in your workspace or shell profile:

export WIKANTIK_BASE_URL="https://wiki.yourdomain.com"
export WIKANTIK_BRIEFING_PINS="ArchitectureRules,CodingConventions"
export WIKANTIK_BRIEFING_CLUSTERS="backend-services,auth-subsystem"
export WIKANTIK_BRIEFING_BUDGET=6000
# Optional: export WIKANTIK_BASIC_AUTH="user:password"

State-Gating Mechanism: Because PreInvocation fires on every turn, the hook self-gates using a state file in ${XDG_CACHE_HOME:-$HOME/.cache}/wikantik-briefing/ keyed by transcriptPath. It injects context exactly once per session and exits 0 with {} on subsequent turns.


Option 2: Rules-Snippet Fallback for Antigravity & Claude Code

If client hooks are disabled, configure standing instructions in AGENTS.md (for Antigravity) or CLAUDE.md (for Claude Code):

## Wikantik Context Grounding
At the START of every new session or task, BEFORE executing any work, call the `get_briefing` tool on the `wikantik-knowledge` MCP server with:
- `pins`: ["ArchitectureRules", "DatabaseConventions"]
- `clusters`: ["core-services"]
- `prompt`: the user's first prompt, verbatim

Treat the returned markdown as authoritative standing context for the session.

3. Moment C: Mid-Session Directed Pulls & The Escalation Ladder

When an agent needs context mid-session, it must follow the Autonomous Escalation Protocol:

Autonomous Escalation Ladder:
[ Step 1: assemble_bundle(query, mode="hybrid") ]
                       |
        +--------------+--------------+
        |                             |
[ confidence == "strong" ]     [ confidence == "partial" | "weak" | "unknown" ]
        |                             |
        v                             v
[ Cite sections & proceed ]    [ Step 2: retrieve_context(query) ]
                               (Discovers relevant page slugs)
                                      |
                                      v
                               [ Step 3: read_pages(slugs=[...]) ]
                               (Fetches full page bodies, max 20)
                                      |
                                      v (If entities / relationships)
                               [ Step 4: traverse / query_nodes ]
                               (Knowledge Graph entity exploration)
                                      |
                                      v (If count / aggregation query)
                               [ Step 5: sparql_query ]
                               (Ontology-level RDF queries)
                                      |
                                      v (All steps exhausted?)
                               [ Fallback: Ask User for Clarification ]

Interpreting the Bundle Coverage Signal

Every assemble_bundle call returns a coverage telemetry block:


4. The 21 Knowledge MCP Tools (/knowledge-mcp)

The read-only Knowledge MCP server (/knowledge-mcp) provides 21 specialized tools organized into five functional categories:

+-------------------------------------------------------------------------------+
|                       KNOWLEDGE MCP TOOL SURFACE TAXONOMY                     |
+-------------------------------------------------------------------------------+
| 1. Answer Grounding & Briefings                                               |
|    - `assemble_bundle`: Primary hybrid search returning citation-bearing text |
|    - `get_briefing`: Budgeted session-start briefing markdown payload        |
|                                                                               |
| 2. Context & Content Retrieval                                                |
|    - `retrieve_context`: Page and section discovery candidates                |
|    - `read_pages`: Batched markdown read for up to 20 pages                   |
|    - `get_page`: Single page lookup by name                                   |
|    - `list_pages`: Browse corpus with pagination                              |
|    - `list_metadata_values`: Inspect distinct frontmatter values              |
|                                                                               |
| 3. Structural Spine Navigation                                                |
|    - `list_clusters`: List high-level topic domains and their hub pages       |
|    - `list_tags`: Inspect categorized taxonomy tags                           |
|    - `list_pages_by_filter`: Multi-criteria filter (cluster, tag, status)     |
|    - `get_page_by_id`: Resolve permanent canonical ULID identifiers           |
|                                                                               |
| 4. Knowledge Graph (LLM-Extracted Entities & Mentions)                        |
|    - `discover_schema`: List available entity types and relationship predicates|
|    - `query_nodes`: Filter nodes by type and properties                      |
|    - `get_node`: Fetch full entity profile and incident edges                 |
|    - `traverse`: Multi-hop graph traversal across relationship edges          |
|    - `search_knowledge`: Full-text search across entity names/properties      |
|    - `find_similar`: Node-level vector similarity search                      |
|                                                                               |
| 5. Projections, Ontology & Citations                                          |
|    - `get_page_for_agent`: Tailored page projection with tool/page hints      |
|    - `get_ontology`: Inspect RDF ontology class and property hierarchy        |
|    - `sparql_query`: Execute read-only SPARQL queries (ideal for counts)      |
|    - `list_stale_citations`: Detect broken/drifted `cite://` groundings       |
+-------------------------------------------------------------------------------+

5. Citation Discipline: Preserving Verifiable Grounding

When grounding agent reasoning in Wikantik, agents must adhere to strict citation rules:

  1. Always cite slug @ version: Use the version-pinned citation handle returned by the tool (e.g., AuthenticationArchitecture @ 4).
  2. Never claim ungrounded facts: If the wiki lacks an answer after exhausting the escalation ladder, explicitly state that the documentation does not cover the topic.
  3. Re-retrieve on topic shifts: Do not extrapolate past session memory when the conversation moves into a new domain—call assemble_bundle with the new topic query.

References

  1. Apache JSPWiki / Wikantik Team. (2026). ADR-0001: RAG Returns Context Bundle, Not Synthesized Answer. Wikantik Documentation.
  2. Apache JSPWiki / Wikantik Team. (2026). ADR-0002: Knowledge Graph is First-Class Knowledge Base. Wikantik Documentation.
  3. Anthropic. (2024). Model Context Protocol (MCP) Specification. Anthropic Documentation.
  4. Google. (2026). Google Antigravity CLI and Agent Hooks Specification. Google Cloud Community.