@melaya/runner 1.0.90 → 1.0.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistantHost.py +17 -6
- package/package.json +1 -1
package/dist/assistantHost.py
CHANGED
|
@@ -292,12 +292,19 @@ def _register_stream_hooks(agent) -> None:
|
|
|
292
292
|
except Exception:
|
|
293
293
|
return
|
|
294
294
|
|
|
295
|
-
|
|
295
|
+
# agentscope hook calling convention (see agent/_agent_meta.py):
|
|
296
|
+
# pre-hook(self, normalized_kwargs_dict)
|
|
297
|
+
# post-hook(self, normalized_kwargs_dict, output)
|
|
298
|
+
# normalized_kwargs_dict is dict(bound.arguments) keyed by the wrapped
|
|
299
|
+
# method's PARAMETER NAMES. So print(self, msg, last) → {"msg":…, "last":…}
|
|
300
|
+
# and _acting(self, tool_call) → {"tool_call":…} (SINGULAR). `*_rest` absorbs
|
|
301
|
+
# the post-hook's trailing `output` arg so ONE shape works for both.
|
|
302
|
+
def _pre_print_hook(_self, kw, *_rest) -> None:
|
|
296
303
|
try:
|
|
297
304
|
tid = _stream.get("turnId")
|
|
298
|
-
if not tid:
|
|
305
|
+
if not tid or not isinstance(kw, dict):
|
|
299
306
|
return
|
|
300
|
-
msg =
|
|
307
|
+
msg = kw.get("msg") or kw.get("message")
|
|
301
308
|
if msg is None:
|
|
302
309
|
return
|
|
303
310
|
mid = str(getattr(msg, "id", "") or id(msg))
|
|
@@ -311,12 +318,16 @@ def _register_stream_hooks(agent) -> None:
|
|
|
311
318
|
except Exception:
|
|
312
319
|
pass
|
|
313
320
|
|
|
314
|
-
def _post_acting_hook(
|
|
321
|
+
def _post_acting_hook(_self, kw, *_rest) -> None:
|
|
315
322
|
try:
|
|
316
323
|
tid = _stream.get("turnId")
|
|
317
|
-
if not tid:
|
|
324
|
+
if not tid or not isinstance(kw, dict):
|
|
318
325
|
return
|
|
319
|
-
|
|
326
|
+
tcs = kw.get("tool_calls")
|
|
327
|
+
if tcs is None:
|
|
328
|
+
tc = kw.get("tool_call") # this agentscope: one tool_call per _acting
|
|
329
|
+
tcs = [tc] if tc is not None else []
|
|
330
|
+
for tc in tcs:
|
|
320
331
|
name = tc.get("name", "") if isinstance(tc, dict) else getattr(tc, "name", "")
|
|
321
332
|
if name:
|
|
322
333
|
_emit(tid, "tool", name=str(name))
|