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

+8
View File
@@ -56,6 +56,7 @@ use codex_connectors::connector_runtime_context_key;
use codex_exec_server::Environment;
use codex_exec_server::EnvironmentManager;
use codex_execpolicy::prefix_rule_migration;
use codex_extension_api::ConversationHistorySnapshot;
use codex_extension_api::ExtensionDataInit;
use codex_extension_api::LoadedUserInstructions;
use codex_extension_api::PromptFragment;
@@ -3668,6 +3669,13 @@ impl Session {
state.clone_history()
}
pub(crate) async fn conversation_history_snapshot(
&self,
) -> Arc<dyn ConversationHistorySnapshot> {
let state = self.state.lock().await;
state.history.conversation_history_snapshot()
}
pub(crate) async fn current_window_id(&self) -> String {
let state = self.state.lock().await;
let thread_id = self.thread_id;