Skip to content
OrbFrontendPublic

About

Dynamic LLM RP Frontend

Resources

Contributing

Stars

31 stars

Watchers

1 watching

Forks

Latest commit

 

History

1,576 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Orb - Dynamic RP Frontend

CodeQL

Orb

Problem Statement

LLM Roleplaying and Creative Writing have a low floor and a high ceiling. Common problems: passiveness and directionlessness, slop (overused, cliche word choices), various types of repetition (degradation as context grows), writing style inertia.

Solution Overview

A Director sits between the user and the model. It intercepts each user message, runs a short analytical pass to "read the room," then dynamically assembles prompt directives that shape the Writer model's writing before the actual roleplay generation happens.

A jev-style Judge quickly and logically settles the next reply's outcome. It can drive and support Director and Writer.

An Editor audits the LLM's response then surgically fixes it.

We essentially break the RP task into smaller, more focused tasks before the final response is generated.

Notable Features

  1. Director: Grounding the story + actively steering the writing style = better output
  2. Judge: Deterministically and reliably settling outcomes for cheap
  3. Customizability: Customizable prompt injection that's automatically used by Director model
  4. Anti-slop: Get rid of overused words, phrases, and patterns often seen in LLM outputs
  5. Anti-repetition: Detect various types of repetition from outputs and surgically fix them
  6. Recast & Rewrite: User-defined modifications or full rewrites after the Writer draft has been written
  7. Length Guard: Actively or passively protect from length degradation as context grows
  8. Super-regenerate: Normal regens may give samey outputs, ask for a different take (mileage varies)
  9. Magic Rewrite: Rewrite the target message in a user-defined direction
  10. Compress History: Summarize chat context and move it to a new conversation
  11. Mobile-compatibility: UI for mobile devices
  12. TTS: Easy Text-to-speech with a high quality built-in voice cloner
  13. Library Tools: Internet card downloader, auto-tagger, dupe finder, tailored card-generator that reads your chats
  14. AI Feedback: Give suggestions and commentary on what to do next, solving writer's block
  15. Text Completion: Advanced harness optimizations when an endpoint supports raw text completion
  16. Assisted Document Mode: A version of Mikupad where you don't need to worry about special tokens
  17. Image Generation: One-click image-gen workflow that's compatible with ComfyUI and several Cloud Providers, support reference images so you don't generate a different character every time
  18. Dynamic Lorebooks: Lorebook entries can be managed by agents, either write or read
  19. Local ML Integration: Prose humanizer and various classifiers that run entirely in CPU

Architecture

Three-Pass Design

The system uses a three-pass architecture, with the agent and writer optionally being the same or different models:

  1. Director Pass - Tool-calling phase where the LLM selects moods and plot direction
  2. Writer Pass - Story generation phase where the LLM writes the actual roleplay response
  3. Editor Pass - A ReAct loop - Self-audit for slop and length optimization phase. This is surgical, errors will be programmatically detected, the model only needs to write replacement for targeted sentences

Single and Dual Model Modes

In most local setups, the user doesn't have enough resource to load more than one model at a time. Single-Model Mode addresses this by using the same model for both writing and agentic tasks. KV cache is respected by design so prompt reprocessing is avoided.

For the best experience, use Dual-Model Mode. Some harnesses are dropped in this mode so the models should perform better.

KV Cache Reuse Strategy

For optimal KV cache reuse, the following will remain consistent across passes:

1. System Prompt

  • The system prompt (character card, instructions, etc.) is identical across all passes
  • Includes character description, scenario, example dialogue, and additional instructions

2. Tool Schemas

  • The same tool definitions must be sent in each LLM call for kv cache reuse
  • Inconsistent tool schemas break KV cache alignment

3. Chat History

  • The conversation history (previous messages) is identical across all passes
  • Maintains exact same message content, attachments, and ordering

4. Agent Instructions and Injected Prompts

  • These are dynamic and go in the tail, they change across passes and turns
  • They will receive the highest attention from the LLM

For a visual walkthrough of the cache mechanism across all three passes and the reasoning-mode fork, open kv-cache-animation in a browser. The full write-up is in docs/architecture/kv-cache.md.

Design Principles

  1. Prioritize small models - if a feature fails half of the time on Gemma-4-26B4A, it probably doesn't belong here
  2. Only use agentic functionalities when absolutely needed - we will not have useless tools like dice_roll
  3. Algorithm-first - if something can be done with an algorithm, don't use LLMs. Avoid making LLMs eyeball for errors
  4. Keep agentic scope small to reduce hallucination, avoid giving agents too much freedom of choice

By the numbers

Orb against two optimized TauriTavern 2.3.0 agent setups doing the exact same direct, write, audit and repair job on Gemma 4 26B-A4B (RTX 3090), thinking off, 120 turns each from 2k- to 32k-token histories:

Orb TauriTavern handoff TauriTavern single
Median reply time, 2k → 32k history 9.9 → 12.6 s 24.3 → 35.1 s 12.8 → 20.3 s
Model calls per turn 4 16 11
Native failures 0/120 13/120 15/120
Turns meeting the task 115/120 101/120 95/120

Orb's own passes switched off and on, on Gemma 4 and DeepSeek V4.1 Flash:

Pass Measure Off On
Director Gemma replies driven on open-ended turns 18% 37%
Director DeepSeek replies driven on open-ended turns 30% 38%
Editor Flagged slop repaired 0% 97%
Editor Gemma held-out slop hits, a list the Editor never sees 66 52

Method, raw data and limits: scripts/bench.

Drawbacks

  1. Speed: Multiple passes will obviously have a longer time to final response
  2. Cost: Negligible cost increase, which comes naturally with multiple passes, somewhat alleviated by KV cache reuse strategy

You're basically trading speed and money for steerability and quality.

Requirements

  1. A model with solid tool/function calling capabilities (recommended: Gemma 4)
  2. Anthropic, Gemini, or OpenAI-compatible LLM inference backend API
  3. Python 3.11+

Wiki

Full documentation is at https://orbfrontend.github.io/Orb/

Contributing & Discussions

Check this out before opening a PR: https://github.com/OrbFrontend/Orb/blob/main/CONTRIBUTING.md

Ideas, help requests, and questions go here: https://github.com/OrbFrontend/Orb/discussions

About

Dynamic LLM RP Frontend

Resources

Contributing

Stars

31 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages