Commit 4631a4f
auto-sync SOUL.md on hermes restart + tighter loop caps (max_turns=20)
Two recurring pain points from the last few operator chats:
1. SOUL.md propagation. Every code change to
/usr/share/mios/ai/hermes-soul.md required a manual touch +
systemctl restart on every host because the firstboot seed-
logic only runs at boot. Worse: `cp` preserves mtime by default,
so the firstboot-style content-diff check said "no change" and
the new prose never reached the agent (operator-flagged earlier
today -- WSLg rule didn't take effect after the deploy).
Fix: new `mios-hermes-soul-sync` shim does ONLY the SOUL re-seed:
* Compares source body (BEFORE marker) byte-by-byte with the
matching prefix of target -- mtime-independent
* cp + chown + chmod on diff
* Preserves any `### MIOS-RUNTIME-CONTEXT-BEGIN` block firstboot
appended (Discord defaults, etc.)
* Exit 0 on noop OR sync; safe as an ExecStartPre
* 1 = source missing, 2 = ownership failure (rare)
Wired via a hermes-agent.service drop-in
(etc/systemd/system/hermes-agent.service.d/50-soul-sync.conf)
so every `systemctl restart hermes-agent.service` re-seeds.
Verified live: restart logged "[mios-hermes-soul-sync] body
current (23195 bytes) -- noop".
2. Tool-loop guardrails were too loose. Recent chats had agent
running 19-24 tool calls before giving up. Two layers fixed:
a. New `agent.max_turns: 20` config (was using upstream default
90). This caps the OPERATOR-facing turn at 20 iterations.
delegate_task children still get their own 90-turn budget.
Most operator asks resolve in 1-3 calls; 20 is generous for
the multi-step ones.
b. tool_loop_guardrails thresholds tightened:
warn_after: exact 2 -> 1, same_tool 3 -> 2, no_progress 2 -> 1
hard_stop_after: exact 5 -> 3, same_tool 8 -> 4, no_progress 5 -> 3
Original incident class: agent called web_extract 4 times in
a row against searxng (which can only search, not extract)
before giving up. New thresholds stop after 2 same-tool
failures (warn) / 4 (hard stop). Idempotent no-progress
(browser_navigate without CDP) cuts off at 3 calls.
Both changes mirrored in mios-hermes-firstboot so fresh image
builds get them out of the box. Live config patched in-place via
yaml.safe_dump; old config saved to config.yaml.bak-caps.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f47cc6b commit 4631a4f
3 files changed
Lines changed: 158 additions & 8 deletions
File tree
- etc/systemd/system/hermes-agent.service.d
- usr/libexec/mios
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
820 | | - | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
821 | 830 | | |
822 | 831 | | |
823 | 832 | | |
824 | 833 | | |
825 | | - | |
826 | | - | |
827 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
828 | 837 | | |
829 | | - | |
830 | | - | |
831 | | - | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
832 | 841 | | |
833 | 842 | | |
834 | 843 | | |
| |||
853 | 862 | | |
854 | 863 | | |
855 | 864 | | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
856 | 872 | | |
857 | 873 | | |
858 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
0 commit comments