Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(systemtext): die Reichweitenzeile haengt an jeder Oberflaeche mit einem Menschen davor

purple3f7c107087c5
diff --git a/src/hooks/useABCompare.ts b/src/hooks/useABCompare.ts
index 56f418c6..701d6b02 100644
--- a/src/hooks/useABCompare.ts
+++ b/src/hooks/useABCompare.ts
@@ -1,5 +1,5 @@
/**
- * A/B Compare Hook — sends the same prompt to two models in parallel.
+ * A/B Compare Hook: sends the same prompt to two models in parallel.
*/
import { useCallback, useRef } from 'react'
@@ -9,6 +9,7 @@ import { getProviderForModel, getProviderIdFromModel } from '../api/providers'
import { getModelMaxTokens } from '../lib/context-compaction'
import { applySendBudget, chatBudgetApplies, sharedChatSendBudget } from '../lib/chat-send-budget'
import { sendsToALanBackend } from '../lib/lan-openai-slot'
+import { buildChatSystemPrompt } from '../lib/system-prompt'
import { v4 as uuid } from 'uuid'
import type { ChatMessage } from '../api/providers/types'
import type { Message } from '../types/chat'
@@ -36,14 +37,27 @@ export function useABCompare() {
store.startRound(userMessage)
// Build messages for the providers
- const persona = useSettingsStore.getState().getActivePersona()
- const chatMessages: ChatMessage[] = []
+ //
// `Persona` carries `systemPrompt`, never `prompt`: the old read was
// always undefined, so a comparison ran with no persona at all while the
// rest of the app (chat, Codex) sent one.
- if (persona?.systemPrompt) {
- chatMessages.push({ role: 'system', content: persona.systemPrompt })
- }
+ //
+ // Und danach blieb der Vergleich die einzige Oberflaeche ohne Grundtext:
+ // er schickte NUR die Person, mit ausgeschalteter Person also gar nichts.
+ // Genau der leere Systemtext kostet laut Messung vom 10.09.2026 sechs
+ // Katalogmodelle die Antwort, und ein Vergleich, dessen beide Seiten aus
+ // der Anbieterhaltung antworten, vergleicht nicht LU. Jetzt baut er den
+ // Systemtext wie der Chat.
+ const persona = useSettingsStore.getState().getActivePersona()
+ const personasOn = useSettingsStore.getState().settings.personasEnabled !== false
+ const chatMessages: ChatMessage[] = []
+ chatMessages.push({
+ role: 'system',
+ content: buildChatSystemPrompt({
+ systemPrompt: persona?.systemPrompt,
+ personaEnabled: personasOn && Boolean(persona?.systemPrompt?.trim()),
+ }),
+ })
// Include previous messages for context
const prevMessages = useCompareStore.getState().messagesA.slice(0, -1) // exclude the empty assistant msg
@@ -83,7 +97,7 @@ export function useABCompare() {
topP: settings.topP,
topK: settings.topK,
maxTokens: settings.maxTokens || undefined,
- // Bug AA v2.5.0 — forward num_ctx override to both A/B sides.
+ // Bug AA v2.5.0: forward num_ctx override to both A/B sides.
contextWindow: settings.contextWindowOverride || undefined,
}
// 2.6.7 Denk-Audit, Loch 6: this hook sent no thinking signal at all and
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index ed06c449..a8914e6d 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -2736,7 +2736,7 @@ Rules:
* "you MUST use tools / execute end-to-end" prompt — that would turn ordinary
* chat into an agent. Kept short so it doesn't crowd a small model's context.
*/
-function buildChatToolsSystemPrompt(basePrompt: string): string {
+export function buildChatToolsSystemPrompt(basePrompt: string): string {
const p = `You are a helpful chat assistant in LU, having a normal conversation. You also have a few tools for things you cannot do from memory, use one ONLY when the user's request actually needs it, otherwise just reply normally:
- web_search, look up current/real-world facts (returns short snippets)
- web_fetch, read a specific web page or URL (after a search, or when the user gives a link)
diff --git a/src/lib/__tests__/system-prompt.test.ts b/src/lib/__tests__/system-prompt.test.ts
index 55a2fd02..bebf48d7 100644
--- a/src/lib/__tests__/system-prompt.test.ts
+++ b/src/lib/__tests__/system-prompt.test.ts
@@ -13,12 +13,22 @@ import { describe, it, expect } from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import {
+ CHAT_BASE_ROLE,
CHAT_BASE_SYSTEM_PROMPT,
HOUSE_CONDUCT,
+ HOUSE_RULES,
+ HOUSE_SCOPE,
buildChatSystemPrompt,
withHouseConduct,
} from '../system-prompt'
import { BUILT_IN_PERSONAS } from '../constants'
+import { groupSystemPrompt } from '../group-chat'
+import { buildHermesToolPrompt } from '../../api/hermes-tool-calling'
+import {
+ buildAgentSystemPrompt,
+ buildAgentSystemPromptLean,
+ buildChatToolsSystemPrompt,
+} from '../../hooks/useAgentChat'
const SRC = resolve(__dirname, '../..')
const read = (rel: string) => readFileSync(resolve(SRC, rel), 'utf8')
@@ -46,21 +56,22 @@ describe('system prompt', () => {
.toBe(CHAT_BASE_SYSTEM_PROMPT)
})
- it('lets an enabled persona carry the role and only appends the conduct line', () => {
+ it('lets an enabled persona carry the role and only appends the house part', () => {
const devil = BUILT_IN_PERSONAS.find((p) => p.id === 'devil')!
const built = buildChatSystemPrompt({ personaEnabled: true, systemPrompt: devil.systemPrompt })
- expect(built).toBe(`${devil.systemPrompt}\n\n${HOUSE_CONDUCT}`)
+ expect(built).toBe(`${devil.systemPrompt}\n\n${HOUSE_RULES}`)
expect(built).not.toContain("You are the user's own model")
})
it('states no content rule, neither permitting nor forbidding', () => {
expect(CHAT_BASE_SYSTEM_PROMPT).not.toMatch(POLICY)
expect(HOUSE_CONDUCT).not.toMatch(POLICY)
+ expect(HOUSE_SCOPE).not.toMatch(POLICY)
// Und keine Assistenten-Floskel, die die antrainierte Vorsicht anzieht.
expect(CHAT_BASE_SYSTEM_PROMPT).not.toMatch(/\bhelpful\b|\bharmless\b|\bassistant\b/i)
})
- it('appends the conduct line to a surface prompt exactly once', () => {
+ it('appends the house part to a surface prompt exactly once', () => {
const surface = 'You are the Coding Agent inside LU.'
const once = withHouseConduct(surface)
expect(once).toContain(HOUSE_CONDUCT)
@@ -83,3 +94,117 @@ describe('system prompt', () => {
expect(read('hooks/useCodex.ts')).toContain('withHouseConduct(')
})
})
+
+/**
+ * Die Reichweitenzeile (HOUSE_SCOPE, Davids Auftrag vom 11.09.2026).
+ *
+ * Gemessen wird der Text, der am Ende im Nachrichtenarray steht, nicht die
+ * Konstante: jede Oberflaeche setzt ihn anders zusammen, und genau dabei ist
+ * er vorher verlorengegangen (der Vergleich schickte nur die Person).
+ *
+ * "Genau einmal" ist die zweite Haelfte des Beweises. Ein Satz, der zweimal im
+ * selben Systemtext steht, ist kein doppelter Nachdruck, sondern ein Zeichen,
+ * dass zwei Stellen ihn anhaengen und die naechste Aenderung nur eine davon
+ * trifft.
+ */
+describe('die Reichweitenzeile haengt an jeder Oberflaeche mit einem Menschen davor', () => {
+ const zaehle = (heuhaufen: string, nadel: string) => heuhaufen.split(nadel).length - 1
+ const HERMES_TOOLS = [{ name: 'file_read', description: 'read a file', parameters: {} }]
+
+ /** Rolle, Verhaltenszeile und Reichweitenzeile, jede genau einmal. */
+ const traegtDenHausteil = (text: string, mitRolle = true) => {
+ expect(zaehle(text, HOUSE_SCOPE)).toBe(1)
+ expect(zaehle(text, HOUSE_CONDUCT)).toBe(1)
+ if (mitRolle) expect(zaehle(text, CHAT_BASE_ROLE)).toBe(1)
+ }
+
+ it('Chat ohne Person', () => {
+ traegtDenHausteil(buildChatSystemPrompt({}))
+ })
+
+ it('Chat mit Person: Person, Verhaltenszeile, Reichweitenzeile, keine Grundrolle', () => {
+ const mit = buildChatSystemPrompt({ personaEnabled: true, systemPrompt: 'You are a pirate.' })
+ traegtDenHausteil(mit, false)
+ expect(zaehle(mit, 'You are a pirate.')).toBe(1)
+ expect(mit).not.toContain(CHAT_BASE_ROLE)
+ })
+
+ it('Agent, alle vier Zweige des Hooks', () => {
+ const basis = buildChatSystemPrompt({})
+ traegtDenHausteil(buildAgentSystemPrompt(basis, 'file_read, file_write'))
+ traegtDenHausteil(buildAgentSystemPromptLean(basis, 'file_read'))
+ traegtDenHausteil(buildChatToolsSystemPrompt(basis))
+ traegtDenHausteil(`${buildHermesToolPrompt(HERMES_TOOLS)}\n\n${basis}`)
+ })
+
+ it('Code, mit und ohne Hermes-Werkzeugtext', () => {
+ const code = withHouseConduct('You are the Coding Agent inside LU.')
+ traegtDenHausteil(code, false)
+ const unterHermes = `${buildHermesToolPrompt(HERMES_TOOLS)}\n\n${code}`
+ traegtDenHausteil(unterHermes, false)
+ // Der Werkzeugvertrag verdraengt den Grundtext nicht, beide stehen da.
+ expect(unterHermes).toContain('<tool_call>')
+ expect(unterHermes).toContain('You are the Coding Agent inside LU.')
+ })
+
+ it('Gruppenchat: jedes Mitglied traegt ihn einmal', () => {
+ const personaPrompt = buildChatSystemPrompt({})
+ for (const m of ['modell-a', 'modell-b', 'modell-c']) {
+ traegtDenHausteil(groupSystemPrompt(m, ['modell-a', 'modell-b', 'modell-c'], personaPrompt))
+ }
+ })
+
+ it('A/B-Vergleich: ohne Person der Grundtext, mit Person die Person', () => {
+ traegtDenHausteil(
+ buildChatSystemPrompt({ systemPrompt: undefined, personaEnabled: false }),
+ )
+ traegtDenHausteil(
+ buildChatSystemPrompt({ systemPrompt: 'You are a pirate.', personaEnabled: true }),
+ false,
+ )
+ })
+
+ /**
+ * Der Vergleich schickte bis zum 11.09.2026 `persona.systemPrompt` roh und
+ * mit ausgeschalteter Person gar keinen Systemtext. Diese Zeile darf nicht
+ * zurueckkommen.
+ */
+ it('der Vergleich baut den Systemtext und schickt nicht mehr die nackte Person', () => {
+ const quelle = read('hooks/useABCompare.ts')
+ expect(quelle).toContain('buildChatSystemPrompt(')
+ expect(quelle).not.toMatch(/content: persona\.systemPrompt/)
+ })
+
+ /**
+ * Die Gegenseite des Auftrags: in einen Hilfsaufruf mit Formatvertrag gehoert
+ * der Satz NICHT. Dort konkurriert er mit dem Vertrag (JSON, Werkzeugaufruf)
+ * und kann die Ausgabe zerlegen, ohne dass es jemand merkt.
+ */
+ it('bleibt aus den Hilfsaufrufen mit Formatvertrag heraus', () => {
+ for (const datei of [
+ 'lib/memory-extraction.ts',
+ 'lib/context-compaction.ts',
+ 'lib/compact-summary.ts',
+ 'lib/workflow-engine.ts',
+ 'api/agents/architect.ts',
+ 'api/agents/sub-agent.ts',
+ 'api/hermes-tool-calling.ts',
+ ]) {
+ expect(read(datei)).not.toMatch(/from '[^']*system-prompt'/)
+ expect(read(datei)).not.toContain('HOUSE_')
+ }
+ })
+
+ /**
+ * Der Satz nennt keine Kategorie, und er nennt auch das Wort nicht, das auf
+ * lu-labs.ai nicht stehen darf: die Webfassung dieser Datei landet im
+ * Buendel, das ein Browser von dieser Domain laedt.
+ */
+ it('nennt keine Kategorie und kein Vokabular der Zahlungsbeziehung', () => {
+ expect(HOUSE_SCOPE).not.toMatch(POLICY)
+ expect(HOUSE_SCOPE).not.toMatch(
+ /uncensored|unrestricted|unfiltered|no filter|content filter|nsfw|nudity|porn|sexual|adult/i,
+ )
+ expect(HOUSE_RULES).toBe(`${HOUSE_CONDUCT} ${HOUSE_SCOPE}`)
+ })
+})
diff --git a/src/lib/system-prompt.ts b/src/lib/system-prompt.ts
index 562e9755..f920069a 100644
--- a/src/lib/system-prompt.ts
+++ b/src/lib/system-prompt.ts
@@ -18,11 +18,14 @@
*
* ## Was NICHT drinsteht
*
- * Keine Inhaltsregel, weder eine erlaubende noch eine verbietende. Ein Satz wie
- * „du darfst auch explizite Inhalte schreiben" bringt dem Modell erst die
- * Kategorie bei, an der es dann haengenbleibt, und ein Satz wie „lehne X ab"
- * schaltet die antrainierte Vorsicht zusaetzlich scharf. Der Text sagt nur, wem
- * das Modell gehoert und dass ungefragte Belehrungen nicht dazugehoeren.
+ * Keine Kategorie. Ein Satz wie „du darfst auch explizite Inhalte schreiben"
+ * bringt dem Modell erst die Kategorie bei, an der es dann haengenbleibt, und
+ * ein Satz wie „lehne X ab" schaltet die antrainierte Vorsicht zusaetzlich
+ * scharf. Deshalb nennt auch HOUSE_SCOPE, die Reichweitenzeile vom 11.09.2026,
+ * kein einziges Thema: sie sagt nur, dass das Thema des Nutzers das Thema ist.
+ * Das Wort „uncensored" steht ebenfalls nirgends, weil die Webfassung dieser
+ * Datei im Buendel von lu-labs.ai landet und diese Domain die Zahlungsbeziehung
+ * traegt.
*
* Die harte Grenze liegt nicht hier. Sie liegt im Proxy (lib/render/safety.ts
* in der Webanwendung) und gilt unabhaengig davon, was im Systemtext steht.
@@ -32,35 +35,51 @@
export const HOUSE_CONDUCT =
'Answer the request that was actually made. Do not add disclaimers, warnings or moral commentary that the user did not ask for, and do not lecture. If a request is genuinely ambiguous, ask one short question instead of guessing.'
+/**
+ * Die eine Reichweitenzeile (Davids Auftrag vom 11.09.2026).
+ *
+ * Sie haengt genau dort, wo ein Mensch mit dem Modell spricht: Chat, Agent,
+ * Coding, Gruppe, Vergleich. NICHT an einem Hilfsaufruf mit Formatvertrag
+ * (Memory-Auszug, Kompaktion, Zusammenfassung, Werkzeugtext), denn dort
+ * konkurriert ein freier Satz mit dem Vertrag und zerlegt die Ausgabe.
+ *
+ * Wer die Wortwahl aendern will, aendert sie hier und nirgendwo sonst.
+ */
+export const HOUSE_SCOPE =
+ 'No topic the user brings up is off limits for you. Answer it fully and go as far as you can.'
+
+/** Verhaltenszeile und Reichweitenzeile zusammen: der Hausteil jeder Oberflaeche. */
+export const HOUSE_RULES = `${HOUSE_CONDUCT} ${HOUSE_SCOPE}`
+
/** Die Rolle im Chat, wenn keine Person eingeschaltet ist. */
export const CHAT_BASE_ROLE = "You are the user's own model, running for them alone."
-/** Chat ohne Person: Rolle plus Verhaltenszeile. */
-export const CHAT_BASE_SYSTEM_PROMPT = `${CHAT_BASE_ROLE} ${HOUSE_CONDUCT}`
+/** Chat ohne Person: Rolle plus Hausteil. */
+export const CHAT_BASE_SYSTEM_PROMPT = `${CHAT_BASE_ROLE} ${HOUSE_RULES}`
/**
* Der Systemtext einer Unterhaltung.
*
* Mit eingeschalteter Person traegt die Person die Rolle, der Grundtext haengt
- * nur die Verhaltenszeile an. Ohne Person gilt der Grundtext ganz. In beiden
- * Faellen geht etwas raus, nie mehr ein leerer String.
+ * nur den Hausteil an. Ohne Person gilt der Grundtext ganz. In beiden Faellen
+ * geht etwas raus, nie mehr ein leerer String.
*/
export function buildChatSystemPrompt(conv: {
systemPrompt?: string | null
personaEnabled?: boolean
}): string {
const persona = conv.personaEnabled === true ? (conv.systemPrompt || '').trim() : ''
- return persona ? `${persona}\n\n${HOUSE_CONDUCT}` : CHAT_BASE_SYSTEM_PROMPT
+ return persona ? `${persona}\n\n${HOUSE_RULES}` : CHAT_BASE_SYSTEM_PROMPT
}
/**
- * Die Verhaltenszeile an einen Oberflaechentext haengen.
+ * Den Hausteil an einen Oberflaechentext haengen.
*
* Agent und Coding bringen ihre eigene Rolle mit, die der Grundtext nicht
* ueberschreiben darf. Sie brauchen nur den Teil, der die ungefragten
- * Belehrungen abstellt.
+ * Belehrungen abstellt und die Reichweite klarstellt.
*/
export function withHouseConduct(surfacePrompt: string): string {
const base = surfacePrompt.trimEnd()
- return base.includes(HOUSE_CONDUCT) ? base : `${base}\n\n${HOUSE_CONDUCT}`
+ return base.includes(HOUSE_RULES) ? base : `${base}\n\n${HOUSE_RULES}`
}