Expose conversation history to tool lifecycle extensions (#38403)

## What changed

- Add a shared, read-only `ConversationHistorySnapshot` capability to the extension API.
- Include the snapshot in `ToolStartInput`, preserving conversation order while excluding contextual user messages.
- Avoid acquiring a history snapshot when no tool lifecycle contributors are registered.

## Testing

- Verify snapshots share existing response items, remain stable as history changes, and filter contextual user messages.
- Verify tool-start callbacks receive the history available for successive tool calls.

GitOrigin-RevId: 822cae33781dd876ea628f104be08d8a449a4900
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-08-13 16:43:23 +00:00
1 parent 6851fae57c
commit a70211249a
10 files changed
+252 -4

No files matched your search

@@ -1,8 +1,10 @@
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use codex_tools::ToolName;
use crate::ConversationHistorySnapshot;
use crate::ExtensionData;
/// Future returned by one tool-lifecycle callback.
@@ -57,6 +59,8 @@ pub struct ToolStartInput<'a> {
pub call_id: &'a str,
/// Tool name as routed by the host.
pub tool_name: &'a ToolName,
/// Shared read-only snapshot of the conversation when the tool started.
pub conversation_history: Arc<dyn ConversationHistorySnapshot>,
/// Source that issued the tool call.
pub source: ToolCallSource,
}