Commit 45c6d28
authored
feat(hitl): add agent-driven human-in-the-loop via request_human_input (#51)
An agent can call request_human_input() to block synchronously on a
threading.Event until a human resolves its question, or raise TimeoutError
after a configured number of seconds -- there is no silent auto-approve on
timeout. inform_user() sends a non-blocking progress update to whoever is
watching the session.
- By default a request blocks indefinitely. A timeout is set per call (the
tool's own `timeout` argument) or as a manifest-wide default (a
`{kind: system, name: request_human_input, params: {timeout: N}}` entry
in spec.tools); the call's own value always wins.
- Non-interactive runs (lab/benchmark runs, and batch CLI runs) auto-resolve
instead of blocking, since there is no human present to answer; real
interactive sessions always block for a genuine response. The auto-resolve
decision defaults to "approve" and is configurable the same two ways as
the timeout (spec.tools params, or the MAS_HITL_AUTO_RESOLVE_DECISION env
var; the manifest value wins if both are set).
- HitlResolverRegistry is the side-channel between a blocked tool call and
whatever surfaces the request to a human (a Webex card, a CLI prompt,
etc.) and later resolves it back.
- Every delegated agent's own SessionController receives the same
trace/trace_timestamps/trace_engine/trace_summary/trace_color
configuration as the entry agent.
- mas-ctl's CLI trace and this HITL bridge are both ExchangePlugin
subscribers (subscribe_exchange/unsubscribe_exchange over a list of
subscribers): tool-call errors are always surfaced in RED and forwarded
to an external exchange_listener, regardless of --trace/--verbose.
- request_human_input/inform_user are now available to every agent
including delegates (needed so a delegated sub-agent can ask for human
input too); mock_llm.py's schema-driven tool-selection fallback (used by
MockModelAccess for offline/CI runs) is updated to skip these two system
tools when picking a "nothing else matched" default, so a mocked delegate
still exercises its own real tool instead of getting its call routed to
request_human_input and auto-resolved.
Regression tests cover: both exchange plugins staying subscribed exactly
once per session (with the bridge still forwarding events when
--trace/--verbose are off); the timeout/auto-resolve precedence rules
above; and mock_llm.py's system-tool-skipping fallback. Two golden-run
fixtures (extensions, lifecycle-control) are regenerated to reflect
request_human_input/inform_user now being present on every agent's tool
list. Full `task ci` (unit, controller, functional/golden-run/tutorial,
dry-run, chat smoke, HITL gate) passes clean.
Signed-off-by: Jordan Augé <augjorda@cisco.com>1 parent 94cee03 commit 45c6d28
51 files changed
Lines changed: 3571 additions & 1264 deletions
File tree
- ctl
- src/mas/ctl
- benchmark
- executor
- session
- tests
- docs/design
- lab/components/content/src/mas/lab/content/widgets
- library-skills/tests
- library-standard
- src/mas/library/standard
- tests
- runtime
- src/mas/runtime
- boundary
- hitl
- obs
- driver
- engine
- system_tools
- tests
- tests/fixtures/golden-runs
- extensions
- cache-backup/extensions/4a66b6993dac4d0ce66a
- traces
- cache-entry
- traces
- lifecycle-control
- cache-backup/lifecycle-control/4a66b6993dac4d0ce66a
- traces
- cache-entry
- traces
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
270 | 272 | | |
271 | 273 | | |
272 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
273 | 281 | | |
274 | 282 | | |
275 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
| |||
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
193 | 203 | | |
194 | 204 | | |
195 | 205 | | |
| |||
212 | 222 | | |
213 | 223 | | |
214 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
215 | 230 | | |
216 | 231 | | |
217 | 232 | | |
| |||
247 | 262 | | |
248 | 263 | | |
249 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
250 | 270 | | |
251 | 271 | | |
252 | 272 | | |
| |||
288 | 308 | | |
289 | 309 | | |
290 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
291 | 316 | | |
292 | 317 | | |
293 | 318 | | |
| |||
393 | 418 | | |
394 | 419 | | |
395 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
396 | 426 | | |
397 | 427 | | |
398 | 428 | | |
| |||
408 | 438 | | |
409 | 439 | | |
410 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
411 | 453 | | |
412 | 454 | | |
413 | 455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
68 | 79 | | |
69 | 80 | | |
70 | 81 | | |
| |||
115 | 126 | | |
116 | 127 | | |
117 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
118 | 134 | | |
119 | 135 | | |
120 | 136 | | |
| |||
136 | 152 | | |
137 | 153 | | |
138 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
139 | 160 | | |
140 | 161 | | |
141 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| 214 | + | |
| 215 | + | |
212 | 216 | | |
213 | 217 | | |
214 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| 25 | + | |
23 | 26 | | |
24 | | - | |
25 | 27 | | |
26 | 28 | | |
27 | 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 | + | |
28 | 72 | | |
29 | 73 | | |
30 | 74 | | |
| |||
63 | 107 | | |
64 | 108 | | |
65 | 109 | | |
| 110 | + | |
66 | 111 | | |
67 | 112 | | |
68 | 113 | | |
| |||
79 | 124 | | |
80 | 125 | | |
81 | 126 | | |
| 127 | + | |
| 128 | + | |
82 | 129 | | |
83 | 130 | | |
84 | 131 | | |
| |||
99 | 146 | | |
100 | 147 | | |
101 | 148 | | |
102 | | - | |
103 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
104 | 177 | | |
105 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
106 | 181 | | |
107 | 182 | | |
108 | 183 | | |
109 | 184 | | |
110 | 185 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
131 | 193 | | |
132 | 194 | | |
133 | 195 | | |
| |||
0 commit comments