@melaya/runner 1.0.109 → 1.0.110
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 +21 -2
- package/dist/connection.js +9 -0
- package/package.json +1 -1
package/dist/assistantHost.py
CHANGED
|
@@ -142,7 +142,7 @@ _CANCELLED = object()
|
|
|
142
142
|
class _RedactingStdout:
|
|
143
143
|
"""Wrap stdout to strip long base64 runs before they reach the log.
|
|
144
144
|
|
|
145
|
-
agentscope prints every agent message verbatim (the `
|
|
145
|
+
agentscope prints every agent message verbatim (the `Assistant: {...}`
|
|
146
146
|
lines), which for phone_screenshot tool results embeds a full base64 JPEG —
|
|
147
147
|
tens of KB per turn that floods and explodes the runner logs. This filter is
|
|
148
148
|
line-buffered and only replaces base64-looking runs (>=200 chars), so the
|
|
@@ -407,7 +407,13 @@ def _build_agent():
|
|
|
407
407
|
)
|
|
408
408
|
|
|
409
409
|
agent = make_agent(
|
|
410
|
-
name
|
|
410
|
+
# This name IS the agent identity that agentscope stamps onto the traced
|
|
411
|
+
# `invoke_agent <name>` span + gen_ai.agent.name — which is EXACTLY the
|
|
412
|
+
# dimension the Overview "by agent" token breakdown groups on
|
|
413
|
+
# (agentStudio.ts:4173/4258). So naming it "Assistant" makes every
|
|
414
|
+
# runner-assistant turn roll up under an "Assistant" agent in the dashboard
|
|
415
|
+
# automatically, no dashboard code change.
|
|
416
|
+
name="Assistant",
|
|
411
417
|
sys_prompt=sys_prompt,
|
|
412
418
|
toolkit=toolkit,
|
|
413
419
|
model_name=model,
|
|
@@ -614,6 +620,19 @@ def _stdin_reader(q: "queue.Queue[str]") -> None:
|
|
|
614
620
|
|
|
615
621
|
def main() -> int:
|
|
616
622
|
_log(f"booting (provider={os.environ.get('MEL_ASSISTANT_PROVIDER')})")
|
|
623
|
+
# Wire OpenTelemetry → Melaya event relay so agentscope's @trace_llm actually
|
|
624
|
+
# exports token spans to agents.spans — the SAME thing pipelines get via
|
|
625
|
+
# events.setup_studio_forwarder(). Without this the trace gate stays off AND
|
|
626
|
+
# the exporter is disabled, so every claude_code/codex assistant turn recorded
|
|
627
|
+
# ZERO tokens (no Overview cost row, no per-turn token count). The exporter
|
|
628
|
+
# self-gates on MEL_BUILDER_URL + MEL_RUN_ID (both set by the runner spawn);
|
|
629
|
+
# idempotent + best-effort — a tracing failure NEVER blocks a turn.
|
|
630
|
+
try:
|
|
631
|
+
from shared.runtime.tracing_exporter import setup_melaya_tracing
|
|
632
|
+
setup_melaya_tracing()
|
|
633
|
+
_log("tracing wired (spans → agents.spans)")
|
|
634
|
+
except Exception:
|
|
635
|
+
_log("tracing setup unavailable (non-fatal)")
|
|
617
636
|
# Mirror the spawn-time assistant autonomy mode into MEL_HITL_MODE so the
|
|
618
637
|
# in-process phone tools (phone.py._cmd) see it from turn one.
|
|
619
638
|
_apply_hitl_mode(None)
|
package/dist/connection.js
CHANGED
|
@@ -1011,6 +1011,15 @@ export async function connect(opts) {
|
|
|
1011
1011
|
// consistent across surfaces. assistantHost mirrors MEL_ASSISTANT_HITL_MODE
|
|
1012
1012
|
// → MEL_HITL_MODE so phone.py stamps the mode on the command body.
|
|
1013
1013
|
MEL_RUN_ID: `assistant:${sid.split(":")[0]}`,
|
|
1014
|
+
// Span tracing → agents.spans. tracing_exporter.MelayaSpanExporter only
|
|
1015
|
+
// exports when BOTH MEL_RUN_ID and MEL_BUILDER_URL are present (it POSTs
|
|
1016
|
+
// batches through this same local relay the pipeline spawns use, lines
|
|
1017
|
+
// ~463/853). The assistant host was missing these two, so — even with
|
|
1018
|
+
// @trace_llm wired — every claude_code/codex assistant turn recorded ZERO
|
|
1019
|
+
// token spans. Spans land under conversation_id = MEL_RUN_ID
|
|
1020
|
+
// (`assistant:<userId>`); the server trigger resolves user_id from it.
|
|
1021
|
+
MEL_BUILDER_URL: `http://127.0.0.1:${relay.port}`,
|
|
1022
|
+
MEL_RELAY_NONCE: relay.nonce,
|
|
1014
1023
|
MEL_PIPELINE_NAME: "Melaya · Assistant",
|
|
1015
1024
|
// Luma browser bridge (same injection as pipeline runs, line ~431): lets
|
|
1016
1025
|
// shared/tools/luma.py route /event/register through Playwright and bypass
|