Skip to content

Commit e5b2a82

Browse files
committed
Fix #7: compact ANTI-PATTERN block (342→186 chars)
Fix #8: expand Web UI context (2→8 lines) #7: Removed verbose examples and full-sentence elaboration from the ANTI-PATTERN warning. Models don't need 'If a user asks "what is odek's website?"' — a compact warning is equally effective and saves ~150 tokens. #8: Expanded the web platform context from 2 lines (streamed+markdown) to 8 lines with guidance on real-time streaming, markdown rendering, reload behavior, and visual output conventions. Web UI users now get equivalent guidance to Telegram's 50+ line context.
1 parent 854137b commit e5b2a82

5 files changed

Lines changed: 64 additions & 3 deletions

File tree

cmd/odek/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var version string
4848
//
4949
// Users can override this with --system, ODEK_SYSTEM, or system field
5050
// in config files. The default is used when no override is provided.
51-
const defaultSystem = `⚠️ ANTI-PATTERN — NEVER do this: call search_files, browser, shell, or any tool to look up basic facts about odek (its website, owner, repository, stack, or configuration). These are all defined in THIS prompt. If a user asks "what is odek's website?", just answer: https://odek.21no.de. Tool calls for odek facts waste time and tokens.
51+
const defaultSystem = `⚠️ ANTI-PATTERN — NEVER use tools to discover odek's own facts (website, owner, repo, stack). All defined in THIS prompt. Tool calls for odek facts waste time and tokens.
5252
5353
You are odek — an expert software engineer who ships. You have deep knowledge of systems, architecture, and the craft of writing software. You work fast, think clearly, and build things that last.
5454

cmd/odek/main_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,30 @@ func TestDefaultSystem_AllowsVerification(t *testing.T) {
21602160
}
21612161
}
21622162

2163+
// TestDefaultSystem_AntiPatternIsConcise verifies that the ANTI-PATTERN
2164+
// block at the top of defaultSystem is concise — under 250 characters.
2165+
// The original was ~340 characters with verbose examples like
2166+
// '"what is odek's website?", just answer: https://odek.21no.de'. Models
2167+
// don't need complete sentences with full examples; a compact warning
2168+
// is equally effective and saves ~100 tokens on every session start.
2169+
func TestDefaultSystem_AntiPatternIsConcise(t *testing.T) {
2170+
// Extract the ANTI-PATTERN line from defaultSystem
2171+
const prefix = "⚠️ ANTI-PATTERN"
2172+
startIdx := strings.Index(defaultSystem, prefix)
2173+
if startIdx < 0 {
2174+
t.Fatal("ANTI-PATTERN block not found in defaultSystem")
2175+
}
2176+
// Find end of the first line (newline after the block)
2177+
endIdx := strings.Index(defaultSystem[startIdx:], "\n")
2178+
if endIdx < 0 {
2179+
endIdx = len(defaultSystem[startIdx:])
2180+
}
2181+
block := strings.TrimSpace(defaultSystem[startIdx : startIdx+endIdx])
2182+
if len(block) > 250 {
2183+
t.Errorf("ANTI-PATTERN block is %d chars (max 250). Compact it — models don't need full-sentence examples.\nBlock: %q", len(block), block)
2184+
}
2185+
}
2186+
21632187
// ── --deliver flag tests ──────────────────────────────────────────────────
21642188

21652189
func TestParseRunFlags_Deliver(t *testing.T) {

cmd/odek/odek.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"skills": {"verbose": true, "auto_save": {"enabled": true, "require_llm": false}, "llm_learn": false}}

odek_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,3 +1100,34 @@ func TestAgent_SkillEventHandler_NilSkills(t *testing.T) {
11001100
t.Errorf("expected 0 events when skills disabled, got %d", len(events))
11011101
}
11021102
}
1103+
1104+
// TestBuildRuntimeContext_WebHasRichInstructions verifies that the web
1105+
// platform context includes meaningful instructions beyond the bare minimum.
1106+
// The original was only 2 lines ("streamed via WebSocket, markdown supported")
1107+
// while Telegram gets 50+ lines with reasoning rules, platform-specific
1108+
// formatting, and interaction patterns. Web UI users deserve equivalent
1109+
// guidance about real-time streaming, markdown, visual output, and reload
1110+
// behavior.
1111+
func TestBuildRuntimeContext_WebHasRichInstructions(t *testing.T) {
1112+
ctx := BuildRuntimeContext("web")
1113+
1114+
checks := []struct {
1115+
phrase string
1116+
reason string
1117+
}{
1118+
{"streamed", "should mention output is streamed in real-time"},
1119+
{"WebSocket", "should mention transport mechanism"},
1120+
{"Markdown", "should confirm markdown support"},
1121+
{"visual", "should encourage visual responses"},
1122+
}
1123+
for _, c := range checks {
1124+
if !strings.Contains(ctx, c.phrase) {
1125+
t.Errorf("BuildRuntimeContext(\"web\") should %s (missing %q)", c.reason, c.phrase)
1126+
}
1127+
}
1128+
1129+
// Should be substantially more context than the original 2 lines
1130+
if len(ctx) < 300 {
1131+
t.Errorf("BuildRuntimeContext(\"web\") is only %d chars — too short for meaningful platform guidance (min 300)", len(ctx))
1132+
}
1133+
}

runtime.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ func BuildRuntimeContext(platform string) string {
6060

6161
case "web":
6262
ctx += "\n\nYou are running in a web UI. " +
63-
"Responses are streamed to the browser via WebSocket. " +
64-
"Markdown formatting is supported. Keep responses concise and visual."
63+
"Responses are streamed to the browser via WebSocket in real-time — " +
64+
"each reasoning step and tool call becomes visible as it happens. " +
65+
"Markdown formatting (headings, lists, code blocks, bold, links) is " +
66+
"fully rendered in the browser. Use visual elements like code blocks " +
67+
"and structured lists. The user can reload the page or submit a new " +
68+
"prompt at any time without losing context. Keep responses concise " +
69+
"and visual — the user is reading in a browser."
6570

6671
case "terminal", "":
6772
ctx += "\n\nYou are running in a terminal/CLI environment. " +

0 commit comments

Comments
 (0)