Record active plugin inventory in turn analytics (#46323)

## What changed

Add `active_plugin_ids_at_turn_start` to turn analytics, combining active host plugins with selected plugin packages. Prefer remote plugin IDs when present and otherwise use validated package IDs. Sort and deduplicate the inventory.

Report `null` for unknown inventories, invalid IDs, IDs longer than 128 bytes, or inventories exceeding 512 distinct IDs; preserve `[]` for an observed empty inventory. Keep the first received inventory even when later resolved configuration updates arrive.

## Testing

Add coverage for ID selection and validation, deduplication, size limits, serialization, and preservation of the first inventory. Extend app-server tests to check inventories after plugin reconciliation and with selected plugins, including turns without explicit plugin mentions.

GitOrigin-RevId: 8a0de912e2570a902cd05bfc918dc8e6ff8b8527
This commit is contained in:
marksteinbrick-oai authored and copyberry committed 2026-09-17 23:47:06 +00:00
1 parent 1f631def3f
commit a1efb59c4a
12 files changed
+368 -15

No files matched your search

+1 -1
View File
@@ -1194,6 +1194,7 @@ async fn track_turn_resolved_config_analytics(
turn_id: turn_context.sub_id.clone(),
thread_id: sess.thread_id.to_string(),
turn_metadata: turn_context.turn_metadata_state.clone(),
active_plugin_ids_at_turn_start: turn_context.active_plugin_ids_for_telemetry(),
num_input_images: input
.iter()
.filter_map(|item| match item {
@@ -1675,7 +1676,6 @@ pub(crate) async fn prepare_tool_recommendations(
.services
.plugins_manager
.plugins_for_config(&turn_context.config.plugins_config_input())
.instrument(trace_span!("built_tools.load_plugins"))
.await
.without_plugins(&turn_context.disabled_plugin_ids);
let tool_suggest_is_enabled = tool_suggest_enabled(turn_context);