Skip to content

Commit f5db8f0

Browse files
mios-devclaude
andcommitted
emits sanitized (no model names) + launch position args + polish dampen
Operator 2026-05-18 chat exposed four bugs; this commit pairs with the prior mios-windows launch fix to close all of them. 1. EMITS: status line was still showing OLD English narrative + model names ("MiOS-Agent: refining via qwen2.5-coder:7b (CPU)...") because the GLOBAL SWEEP commit edited the on-disk pipe file but never re-ran mios-owui-install-pipe -- OWUI loads pipes from function.content in webui.db, not from disk per-request. Two-step fix: * Sanitized the emit strings further: dropped model-name interpolation entirely ("🎨 polish" not "🎨 polish ← X (CPU)"). Model identity lives in valves; the status line stays universal (operator directive 2026-05-18: "Sanitize the emitters to not show models but emit something natively (no hard-coding)"). * Ran /usr/libexec/mios/mios-owui-install-pipe -- DB now carries the new content. Verified: all 5 old English markers gone, all 6 new symbol-form markers present. 2. LAUNCH POSITION ARGS: agent had no way to launch+place precisely (operator-flagged: "MiOS-Agent(s) MUST also KNOW window launch params/args to be able to launch and move precisely!!!"). mios-windows launch now reads three env-driven knobs the agent can set BEFORE the call: MIOS_LAUNCH_POSITION left|right|top|bottom|center|none MIOS_LAUNCH_SIZE <W>x<H> (e.g. 1280x720) MIOS_LAUNCH_PLACE <X>,<Y> (absolute top-left) The placement block is computed in the inline Python that builds the Start-Process command; PowerShell snippet substitutes the right $x/$y/$w/$h before MoveWindow. Default stays "center" for backwards compat. 3. POLISH FALSE-POSITIVE: polish KNOWN_AGENT_ERROR_RE matched a PowerShell-in-bash signature from an early exploratory call in the same turn, then rewrote the FINAL successful launch as "Agent attempted PowerShell in bash by mistake". The operator saw a misleading failure for what was actually a working launch (compounded by the invisible-window bug fixed in the prior commit). Tightened the polish prompt: KNOWN AGENT ERRORS rewrites only fire when the raw output does NOT also contain a confirmed-success signal (tool_result success:true, pid:<N>, presented_to_operator:true, "wrote <path>"). Polish the SUCCESS, not the earlier exploration error. 4. SOUL.md hard rule 3a (NEW): "Launch position + args" -- documents the three env knobs with examples + the verify-then-stop rule ("ALWAYS verify with mios-window-active --present <title> ONCE. If presented_to_operator: true -- STOP. Don't retry."). Quotes the 19-tool-call retry-after-success incident as the case study. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1fa2ae5 commit f5db8f0

3 files changed

Lines changed: 117 additions & 12 deletions

File tree

usr/libexec/mios/mios-windows

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,62 @@ if extra_args:
503503
arglist = ", ".join(shlex.quote(a) for a in extra_args)
504504
start = (f"$p = Start-Process -FilePath {shlex.quote(target)} "
505505
f"-ArgumentList {arglist} -PassThru")
506+
# Operator directive 2026-05-18: "MiOS-Agent(s) MUST also KNOW
507+
# window launch params/args to be able to launch and move
508+
# precisely!!!". Three env-driven knobs the caller can set BEFORE
509+
# invoking mios-windows launch:
510+
# MIOS_LAUNCH_POSITION left|right|top|bottom|center|none
511+
# (default: center; "none" leaves WHERE the
512+
# OS placed the window)
513+
# MIOS_LAUNCH_SIZE <W>x<H> (e.g. 1280x720; default: keep
514+
# the size Start-Process gave the window)
515+
# MIOS_LAUNCH_PLACE <X>,<Y> (absolute top-left, takes
516+
# precedence over MIOS_LAUNCH_POSITION)
517+
import os
518+
position = os.environ.get("MIOS_LAUNCH_POSITION", "center").lower()
519+
size_env = os.environ.get("MIOS_LAUNCH_SIZE", "")
520+
place_env = os.environ.get("MIOS_LAUNCH_PLACE", "")
521+
# Compute the placement PowerShell snippet from those knobs.
522+
place_block = (
523+
"$x = $r.L; $y = $r.T; $w = $r.R - $r.L; $h = $r.B - $r.T; "
524+
"$s = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea; "
525+
)
526+
# Size override (parse "WxH"); applied before position so position
527+
# uses the NEW geometry.
528+
if "x" in size_env.lower():
529+
try:
530+
sw, sh = size_env.lower().split("x", 1)
531+
sw = int(sw.strip()); sh = int(sh.strip())
532+
place_block += f"$w = {sw}; $h = {sh}; "
533+
except (ValueError, TypeError):
534+
pass
535+
# Absolute placement override.
536+
if "," in place_env:
537+
try:
538+
px, py = place_env.split(",", 1)
539+
px = int(px.strip()); py = int(py.strip())
540+
place_block += f"$x = {px}; $y = {py}; "
541+
position = "_explicit"
542+
except (ValueError, TypeError):
543+
pass
544+
# Otherwise apply named position relative to PrimaryScreen WorkingArea.
545+
if position == "center":
546+
place_block += (
547+
"$x = $s.X + [int](($s.Width - $w) / 2); "
548+
"$y = $s.Y + [int](($s.Height - $h) / 2); ")
549+
elif position == "left":
550+
place_block += "$x = $s.X; $y = $s.Y; $w = [int]($s.Width / 2); $h = $s.Height; "
551+
elif position == "right":
552+
place_block += ("$w = [int]($s.Width / 2); $h = $s.Height; "
553+
"$x = $s.X + [int]($s.Width / 2); $y = $s.Y; ")
554+
elif position == "top":
555+
place_block += "$x = $s.X; $y = $s.Y; $w = $s.Width; $h = [int]($s.Height / 2); "
556+
elif position == "bottom":
557+
place_block += ("$w = $s.Width; $h = [int]($s.Height / 2); "
558+
"$x = $s.X; $y = $s.Y + [int]($s.Height / 2); ")
559+
elif position in ("none", "_explicit"):
560+
pass # keep existing $x/$y (no reposition for "none";
561+
# explicit values already in place for "_explicit")
506562
center = (
507563
"; for ($i = 0; $i -lt 50; $i++) { "
508564
" $p = Get-Process -Id $p.Id -ErrorAction SilentlyContinue; "
@@ -519,10 +575,7 @@ center = (
519575
"'@ -ErrorAction SilentlyContinue; "
520576
"$r = New-Object MX.W32D+RECT; "
521577
"[MX.W32D]::GetWindowRect($p.MainWindowHandle, [ref]$r) | Out-Null; "
522-
"$w = $r.R - $r.L; $h = $r.B - $r.T; "
523-
"$s = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea; "
524-
"$x = $s.X + [int](($s.Width - $w) / 2); "
525-
"$y = $s.Y + [int](($s.Height - $h) / 2); "
578+
+ place_block +
526579
"[MX.W32D]::MoveWindow($p.MainWindowHandle, $x, $y, $w, $h, $true) | Out-Null; "
527580
"[MX.W32D]::SetForegroundWindow($p.MainWindowHandle) | Out-Null "
528581
"}"

usr/share/mios/ai/hermes-soul.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@ never from training data.
3737
error. Anything with `$_.` / `Get-*` / `-like` / `-match` / `@'…'@`
3838
MUST be `terminal: mios-windows ps "<powershell>"`.
3939

40+
3a. **Launch position + args** — the launcher reads three env vars
41+
you can set BEFORE the call to control window placement
42+
precisely (operator directive 2026-05-18: "MUST also KNOW
43+
window launch params/args to be able to launch and move
44+
precisely"):
45+
46+
```
47+
MIOS_LAUNCH_POSITION=left|right|top|bottom|center|none
48+
MIOS_LAUNCH_SIZE=<W>x<H> (e.g. 1280x720)
49+
MIOS_LAUNCH_PLACE=<X>,<Y> (absolute top-left)
50+
```
51+
52+
Example — launch Notepad on the LEFT half of the primary screen:
53+
```
54+
terminal: MIOS_LAUNCH_POSITION=left mios-find "notepad" | bash
55+
```
56+
57+
Pass extra positional args after the bare launcher target:
58+
```
59+
terminal: mios-windows launch notepad /path/to/file.txt
60+
```
61+
62+
After launch, ALWAYS verify with `mios-window-active --present
63+
"<title>"` ONCE. If `presented_to_operator: true` -- STOP. Don't
64+
retry. Operator-flagged 2026-05-18: agent claimed Notepad
65+
launched then ran 19 more tool calls re-attempting the same
66+
success.
67+
4068
3. **"Launch / open / start / run `<X>`" — Windows launch path.**
4169
FIRST call `everything_search(query="<X>")` (native tool, NTFS
4270
index, sub-100ms). It returns the actual `.url`/`.lnk`/`.exe`

usr/share/mios/owui/pipes/mios_agent_pipe.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,26 @@ async def _tail_watcher(
607607
"\n"
608608
"## KNOWN AGENT ERRORS in RAW OUTPUT -- recognize + rewrite cleanly\n"
609609
"\n"
610-
"If RAW OUTPUT contains any of these signatures, DO NOT echo the\n"
611-
"raw error verbatim -- the operator already saw it once. Instead\n"
612-
"emit a single line explaining what the agent did wrong + what\n"
613-
"the operator should try next:\n"
610+
"IMPORTANT: only apply the rewrites below when the raw output\n"
611+
"does NOT also contain a confirmed-success signal -- specifically\n"
612+
"a tool_result with `success: true`, a `pid: <N>` in broker\n"
613+
"output, a `presented_to_operator: true` from mios-window-active,\n"
614+
"or a `wrote <path>` line from a file/CDI helper. If the agent\n"
615+
"errored during exploration but ultimately succeeded, polish\n"
616+
"the SUCCESS not the error -- operator-flagged 2026-05-18:\n"
617+
"polish rewrote a successful Notepad launch (pid 499978) into\n"
618+
"'Agent attempted PowerShell in bash by mistake' because an\n"
619+
"earlier exploratory bash call in the same turn errored. The\n"
620+
"operator saw a misleading failure message for what was\n"
621+
"actually a working launch (the broker had a separate\n"
622+
"invisible-window bug fixed in mios-windows; the polish\n"
623+
"false-positive compounded it).\n"
624+
"\n"
625+
"If RAW OUTPUT contains any of these signatures AND no\n"
626+
"confirmed-success signal, DO NOT echo the raw error verbatim --\n"
627+
"the operator already saw it once. Instead emit a single line\n"
628+
"explaining what the agent did wrong + what the operator\n"
629+
"should try next:\n"
614630
"\n"
615631
" * `/var/lib/mios/hermes.<Word>` or `/var/lib/mios/hermes.<Prop>`\n"
616632
" in any line that mentions 'not recognized' / 'cmdlet' / 'cannot\n"
@@ -747,7 +763,11 @@ async def _polish_via_cpu(
747763
await self._emit(emitter, "✓ clean → skip polish")
748764
return raw_output
749765

750-
await self._emit(emitter, f"🎨 polish ← {self.valves.POLISH_MODEL} (CPU)")
766+
# Emit form: pure symbol, no model name. Operator directive
767+
# 2026-05-18: "Sanitize the emitters to not show models but
768+
# emit something natively (no hard-coding)". Model identity
769+
# lives in valves; status line stays universal.
770+
await self._emit(emitter, "🎨 polish")
751771

752772
body = {
753773
"model": self.valves.POLISH_MODEL,
@@ -875,7 +895,8 @@ async def _refine_via_cpu(
875895
return user_text
876896

877897
model = self.valves.REFINE_MODEL
878-
await self._emit(emitter, f"🧠 refine ← {model} (CPU)")
898+
# Sanitized emit (no model name); see polish emit comment above.
899+
await self._emit(emitter, "🧠 refine")
879900
payload = {
880901
"model": model,
881902
"messages": [
@@ -912,7 +933,7 @@ async def _refine_via_cpu(
912933
await self._emit(emitter, "⚠️ refine=∅ → original")
913934
return user_text
914935
await self._emit(emitter,
915-
f"✓ refine {len(user_text)}c → {len(refined)}c (CPU)")
936+
f"✓ refine {len(user_text)}c → {len(refined)}c")
916937
return refined
917938
except asyncio.TimeoutError:
918939
await self._emit(emitter,
@@ -1057,8 +1078,11 @@ async def pipe(
10571078
}
10581079

10591080
if is_task_gen:
1081+
# Sanitized: no model name in the emit; task_kind is the
1082+
# OWUI-defined identifier (title_generation, etc.) and
1083+
# stays cross-locale.
10601084
await self._emit(__event_emitter__,
1061-
f"⚙️ task-gen ({task_kind}) → CPU {self.valves.REFINE_MODEL}")
1085+
f"⚙️ task-gen ({task_kind})")
10621086
async for chunk in self._raw_passthrough(body, __event_emitter__):
10631087
yield chunk
10641088
return

0 commit comments

Comments
 (0)