Commit 6707ed8
phase-1 native multi-agent: structured Compose handoff from Hermes session
Operator directives 2026-05-18 stacked into one architectural shift:
* "this all seems HARDCODED!!! HOW WOULD THIS MULTI_AGENTIC_REASONING
WORK NATIVELY!??? RESEARCH!"
* "make sure this is ALL ALSO OpenAI API COMPLIANT and COMPLETELY
FUnctional on a Bootc Bootable OCI MiOS image"
* "kanban too!!"
* "and shared global scratpad(s) in mutable locations"
* "OWUI Knowledge/Memory enabled and compression/artifacting"
Research findings (full doc at usr/share/mios/docs/multi-agent-
architecture.md, also auto-registered into the MiOS Documentation
RAG collection at deploy time so the agent itself can cite it):
The 2026 multi-agent best practice is structured tool_call /
tool_result handoff (Anthropic tool_use, AWS Strands, Agno
reasoning agents, LangGraph supervisor pattern, CrewAI critic-
actor loop). The current MiOS pipe was the opposite: it consumed
Hermes's SSE TEXT stream and re-prompted polish with the same
text blob. Polish then had to GUESS what happened, hence the
regex tower (think/details/fence strip + KNOWN_AGENT_ERROR_RE +
"NEVER report 'launched' unless..." ban lists).
Phase 1 (this commit) -- structured Compose:
* Pipe.HERMES_SESSIONS_DIR = /var/lib/mios/hermes/sessions/
(shared mutable scratch, image-immutable shim path).
* _load_session_tool_history finds the freshest session JSON whose
mtime > the dispatch moment, returns the OpenAI-format messages
slice (user + every message after).
* _render_tool_history_for_compose pairs assistant tool_calls with
their matching role:tool results by tool_call_id, parses the
MiOS-verb `success` JSON field, renders a compact event list:
[{role, tool_call_id, tool, arguments, success, result_preview},
...]
* _polish_via_cpu takes a new `dispatch_ts` arg; when set, loads
the structured history and APPENDS it to the polish system
prompt under a "## STRUCTURED TOOL HISTORY" heading marked
authoritative for success/fail reasoning. Compose model is told
to cite events by tool name + success state, and to say
explicitly when a planned step did NOT run rather than
fabricating.
* Pipe stamps _dispatch_ts = time.time() right before "🧠 →
hermes" and threads it through to the polish call. The
text-blob path stays as fallback when no session JSON is
loadable (older sessions, race conditions, etc.) so the chain
degrades gracefully.
OpenAI compliance: kept the tool_call + role:tool message shape
Hermes already records (standard Chat Completions tool_use schema).
Any OpenAI-API-compatible model (Claude, GPT-*, local Ollama) can
consume the structured input identically.
Bootc / Day-0:
* /usr/share/mios/owui/pipes/mios_agent_pipe.py: image-immutable
* /var/lib/mios/hermes/sessions/: created by mios-hermes-
firstboot at first boot (already)
* /usr/share/mios/docs/multi-agent-architecture.md: image-
immutable; registered into the MiOS Documentation OWUI
knowledge collection at deploy time via mios-knowledge-add
--replace
* No /etc/ writes required for the new path.
Acknowledged in the compose system prompt: kanban_* events
reflect task state, memory_save / memory_search reflect durable
context, skill_view / skill_manage reflect agent self-iteration,
knowledge_search hits reflect OWUI RAG corpus -- all surface as
events in the structured history with the same {tool, success,
result_preview} shape.
Phase 2-4 plan (in the research doc):
2. Explicit Critic Agent (iGPU micro-LLM qwen3:1.7b) reviews
answer vs. structured tool history; bounded reflexion loop.
3. Refine emits JSON {intent, plan, success_criteria} not the
INTENT/TOOLS/DELEGATE/PLAN label prose.
4. Drop regex post-processors -- Compose reasons over structure,
not text. _KNOWN_AGENT_ERROR_RE / _DETAILS_BLOCK_RE / polish
ban lists become unnecessary.
Live verification: research doc auto-registered into the MiOS
Documentation collection (id=8c721cc0...), attached to both
mios-agent + mios_agent.mios-agent model rows. Pipe re-installed
into OWUI db; OWUI restarted.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 848d50a commit 6707ed8
2 files changed
Lines changed: 345 additions & 14 deletions
File tree
| 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 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
0 commit comments