mirror of
https://github.com/openai/codex.git
synced 2026-11-05 20:10:33 +00:00
## Why Message roles and content classifications do not identify who supplied each context part. Source attribution needs to survive prompt assembly and history truncation, including messages that combine text from different producers. ## What changed - Add per-part `ContentItemMetadata` for user input, developer instructions, `AGENTS.md`, skills, harness context, command hooks, and tool context with optional callable namespaces. - Carry attribution alongside content and classifications through contextual fragments, extension prompts, hook output, and agent messages. Keep tool-provided context-window hints separate from harness text. - Preserve the source of retained text slices during compaction and attribute generated truncation notices to the harness. Default missing historical attribution to unknown. - Attribute host MCP calls using cached tool namespaces only when catalog revisions remain stable, without starting servers or refreshing catalogs for attribution. - Send the new metadata to Responses Lite and strip it from requests to endpoints that do not support it. ## Testing Extend compaction tests to cover mixed sources, missing or extra metadata entries, and discarded media. Update Responses Lite request assertions to verify endpoint-specific attribution handling. GitOrigin-RevId: b0ebc929b7c60f3ec49d1affbf897312d63edcc8
31 lines
1021 B
Rust
31 lines
1021 B
Rust
use std::time::Duration;
|
|
|
|
use futures::future::BoxFuture;
|
|
use serde_json::Map;
|
|
use serde_json::Value;
|
|
|
|
/// One MCP tool call requested by a configured hook handler.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct HookMcpCall {
|
|
pub server: String,
|
|
pub tool: String,
|
|
pub environment_id: Option<String>,
|
|
pub metadata: Option<Map<String, Value>>,
|
|
pub input: Map<String, Value>,
|
|
pub timeout: Duration,
|
|
}
|
|
|
|
/// Text returned by an MCP hook and the callable namespace that supplied it.
|
|
pub struct HookMcpOutput {
|
|
pub text: String,
|
|
pub source_tool_namespace: Option<String>,
|
|
}
|
|
|
|
/// Executes already-connected MCP tools on behalf of hooks without coupling this crate to core.
|
|
///
|
|
/// Implementations own server readiness, policy enforcement, timeout handling, and elicitation.
|
|
pub trait HookMcpExecutor: Send + Sync {
|
|
/// Returns text that is interpreted using ordinary command-hook output semantics.
|
|
fn execute(&self, call: HookMcpCall) -> BoxFuture<'_, anyhow::Result<HookMcpOutput>>;
|
|
}
|