Commit 353291b
phase-2 multi-agent: Critic Agent reflexion loop over compose draft
Continues the migration plan from
usr/share/mios/docs/multi-agent-architecture.md (phase 1 was
structured Compose handoff from Hermes session JSON; phase 2 adds
the actor + critic reflexion loop).
Architecture:
refine -> hermes -> compose (draft)
-> critic (reviews draft vs structured
tool history; verdict JSON)
-> [if revise] recompose with critic
feedback fed back
-> ship
Critic Agent (NEW):
* CRITIC_ENABLED valve (default True). When ON and the pipe loaded
structured tool history from the Hermes session, the critic
passes the {user_ask, structured_history, compose_draft} to a
small model (qwen3:1.7b on iGPU per operator's "iGPU = micro-LLM
only" directive). Output: JSON {verdict: approve|revise, issues:
[...]}.
* Checks for: false success claims (claim "launched X" when the
tool_result for that call had success=false), fabricated steps
(claim a step completed when no tool_call for it exists), wrong
tool attribution, missing critical info that IS in the history,
fabricated specifics (paths/ids/numbers not anywhere in any
tool_result).
* Format=json mode (Ollama structured output) so the parse step
is robust.
* Fail-open: any HTTP/timeout/parse error returns {} -> draft
ships unchanged. The critic NEVER blocks the response.
Reflexion loop:
* CRITIC_MAX_ITERATIONS valve (default 1, bounded).
* If critic verdict=revise, _recompose_with_critic_feedback re-runs
compose with the issues list appended to the system prompt: "Your
previous draft had these issues -- FIX each one in the revised
answer". Compose sees the previous draft + the structured history
+ the specific issues -> writes a corrected answer.
* Re-strip fence + reasoning leaks on the revised text.
* CRITIC_MAX_ITERATIONS=0 means "audit-only" (run critic, never
revise) -- useful for telemetry without behaviour change.
Status emits (sanitized per the earlier global sweep; no English
narrative, no model names):
🧑⚖️ critic -- review started
🧑⚖️ ✓ critic approve -- draft passes ground truth
🧑⚖️ ✎ critic: <N> issue(s) → revise -- compose re-runs
🧑⚖️ ⚠ critic err → ship draft -- failure mode (rare)
Why this matters (vs. the regex tower it replaces):
* _KNOWN_AGENT_ERROR_RE was guessing from text whether the agent
had really failed; the critic READS the structured success
field directly. No false positives on real successes.
* "NEVER report 'launched' unless tool_result success:true" ban
list in the polish prompt was relying on the model to remember
a rule; the critic enforces it externally.
* The pattern is OpenAI-API-compliant (standard Chat Completions
structured-output + tool_use messages -- works against any
OpenAI-compatible backend, not just local Ollama).
* Day-0 from clone: all valves, methods, and prompts ship in
/usr/share/mios/owui/pipes/mios_agent_pipe.py (image-immutable).
First chat with this pipe triggers Ollama to load qwen3:1.7b
(1.4 GB; lands on iGPU when wsl2-amd.yaml CDI spec is present
per the earlier iGPU passthrough commit).
Operator-requested cache wipe (--all) also done as the prelude:
* 0 chats / messages / memories
* Preserved: 1 admin user, 2 models (with params + meta.knowledge
bindings), 2 tools (with full specs), 3 functions, the MiOS
Documentation knowledge collection (33 files including the
multi-agent research doc).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6707ed8 commit 353291b
1 file changed
Lines changed: 201 additions & 0 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
202 | 228 | | |
203 | 229 | | |
204 | 230 | | |
| |||
1017 | 1043 | | |
1018 | 1044 | | |
1019 | 1045 | | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
1020 | 1072 | | |
1021 | 1073 | | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
1022 | 1223 | | |
1023 | 1224 | | |
1024 | 1225 | | |
| |||
0 commit comments