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

@@ -0,0 +1,10 @@
use codex_protocol::models::ResponseItem;
/// Read-only conversation-history snapshot supplied by the extension host.
///
/// Implementations should retain the host's existing snapshot storage rather than
/// copying response payloads into an extension-owned collection.
pub trait ConversationHistorySnapshot: Send + Sync {
/// Returns the snapshot's response items in conversation order.
fn items(&self) -> Box<dyn Iterator<Item = &ResponseItem> + Send + '_>;
}
@@ -1,10 +1,12 @@
mod agent;
mod conversation_history;
mod events;
mod metrics;
mod response_items;
pub use agent::AgentSpawnFuture;
pub use agent::AgentSpawner;
pub use conversation_history::ConversationHistorySnapshot;
pub use events::ExtensionEventSink;
pub use events::ExtensionWarning;
pub use events::NoopExtensionEventSink;