Add metrics for extension-rendered skill catalogs (#35597)

## What changed

- Add an optional `ExtensionMetrics` capability to thread, turn-input, and world-state contributors, backed by session telemetry in the host.
- Record skill counts, omissions, and truncated description characters for extension-rendered catalogs, tagged by the catalog surface.
- Preserve host session attribution on extension metrics, including the effective model for each turn, and prevent extension tags from overriding host metadata.
- Avoid duplicate host-catalog samples by recording world-state metrics only when the section is published or changes.

## Testing

- Cover metric values and surface tags, session metadata preservation, turn-level model changes, and host world-state publication behavior.

GitOrigin-RevId: 9059e521943a8f81df25a38b03692eddbc1d990d
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-07-27 11:04:02 +00:00
1 parent 3d519bf63a
commit d6ea5991e7
23 files changed
+625 -8

No files matched your search

@@ -10,6 +10,7 @@ use codex_tools::ToolCall;
use codex_tools::ToolExecutor;
use crate::ExtensionData;
use crate::ExtensionMetrics;
mod context;
mod mcp;
@@ -205,10 +206,12 @@ pub trait TurnLifecycleContributor: Send + Sync {
/// host-specific dependencies belong on the extension value installed by the
/// host, not in this input.
pub trait TurnInputContributor: Send + Sync {
/// Returns additional contextual fragments for one submitted turn.
/// Returns additional contextual fragments for one submitted turn. The optional metrics
/// capability is bound to the effective model for that turn.
fn contribute<'a>(
&'a self,
input: TurnInputContext,
extension_metrics: Option<Arc<dyn ExtensionMetrics>>,
session_store: &'a ExtensionData,
thread_store: &'a ExtensionData,
turn_store: &'a ExtensionData,