Runtime takes its telemetry sink at construction and exposes no way to change or read it afterwards. Its fields are private and it offers no accessors, so a host that wants to install a sink after building a runtime has to rebuild the runtime from the inputs it retained. That only works for manifest-based constructors, and it silently discards anything the original build derived.
agent-governance-toolkit works around this in AgentControl::with_telemetry, which keeps the manifest, dispatchers, and limits so it can call Runtime::with_telemetry_perf_and_limits again. Retaining the limits was not obvious: an earlier version rebuilt with Runtime::with_telemetry, which restores Limits::default() and quietly widened a budget the caller had tightened.
Two smaller pieces are missing alongside it:
TelemetrySink has no force_flush, so a host cannot drain buffered events before exit
TelemetryEvent has no to_json, so every consumer writes its own projection and they drift
The pre-extraction AGT engine had Runtime::set_telemetry and with_telemetry_sink, plus both of the above. AGT now carries reimplementations in core/src/telemetry_sinks.rs.
A setter on Runtime, or accessors sufficient to rebuild faithfully, would remove the workaround. force_flush and to_json are independent and smaller.
Verified against the published 0.4.0-alpha.1 sources.
Runtimetakes its telemetry sink at construction and exposes no way to change or read it afterwards. Its fields are private and it offers no accessors, so a host that wants to install a sink after building a runtime has to rebuild the runtime from the inputs it retained. That only works for manifest-based constructors, and it silently discards anything the original build derived.agent-governance-toolkit works around this in
AgentControl::with_telemetry, which keeps the manifest, dispatchers, and limits so it can callRuntime::with_telemetry_perf_and_limitsagain. Retaining the limits was not obvious: an earlier version rebuilt withRuntime::with_telemetry, which restoresLimits::default()and quietly widened a budget the caller had tightened.Two smaller pieces are missing alongside it:
TelemetrySinkhas noforce_flush, so a host cannot drain buffered events before exitTelemetryEventhas noto_json, so every consumer writes its own projection and they driftThe pre-extraction AGT engine had
Runtime::set_telemetryandwith_telemetry_sink, plus both of the above. AGT now carries reimplementations incore/src/telemetry_sinks.rs.A setter on
Runtime, or accessors sufficient to rebuild faithfully, would remove the workaround.force_flushandto_jsonare independent and smaller.Verified against the published 0.4.0-alpha.1 sources.