mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add per-item retention policies for injected history (#61344)
## What changed Allow `thread/inject_items` to accept wrapped items with `retention: "default"` or `retention: "always"`, while preserving support for raw response items. Persist explicit policies separately from legacy client-authored metadata. Carry explicitly retained items through local and remote compaction, context-window changes, and child-agent creation, subject to retention budgets. Preserve history order and keep retained tool exchanges together; require matching calls and outputs to be adjacent in the injection request and both marked `always`. Update Quinn dependencies and record exceptions for additional Hickory DNSSEC advisories where DNSSEC is disabled. ## Testing Update injection tests for explicit retention metadata and extend the compaction scenario to cover a retained tool exchange across repeated compaction and restart. GitOrigin-RevId: 1195a4ed62dc162a62e58bc2ad733262fbabea27
This commit is contained in:
@@ -766,7 +766,7 @@ fn recorded_call(call: &ToolCall) -> (ExecutedToolCall, usize) {
|
||||
(ExecutedToolCall::new(name, arguments), original_bytes)
|
||||
}
|
||||
|
||||
fn input_call_id(item: &ResponseItem) -> Option<&str> {
|
||||
pub(crate) fn input_call_id(item: &ResponseItem) -> Option<&str> {
|
||||
match item {
|
||||
ResponseItem::FunctionCall { call_id, .. }
|
||||
| ResponseItem::CustomToolCall { call_id, .. } => Some(call_id),
|
||||
@@ -776,7 +776,7 @@ fn input_call_id(item: &ResponseItem) -> Option<&str> {
|
||||
}
|
||||
}
|
||||
|
||||
fn output_call_id(item: &ResponseItem) -> Option<&str> {
|
||||
pub(crate) fn output_call_id(item: &ResponseItem) -> Option<&str> {
|
||||
match item {
|
||||
ResponseItem::FunctionCallOutput { call_id, .. }
|
||||
| ResponseItem::ToolSearchOutput { call_id, .. } => call_id.as_deref(),
|
||||
@@ -784,3 +784,23 @@ fn output_call_id(item: &ResponseItem) -> Option<&str> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_matching_tool_output(call: &ResponseItem, output: &ResponseItem) -> bool {
|
||||
let Some(call_id) = input_call_id(call) else {
|
||||
return false;
|
||||
};
|
||||
output_call_id(output) == Some(call_id)
|
||||
&& matches!(
|
||||
(call, output),
|
||||
(
|
||||
ResponseItem::FunctionCall { .. } | ResponseItem::LocalShellCall { .. },
|
||||
ResponseItem::FunctionCallOutput { .. }
|
||||
) | (
|
||||
ResponseItem::CustomToolCall { .. },
|
||||
ResponseItem::CustomToolCallOutput { .. }
|
||||
) | (
|
||||
ResponseItem::ToolSearchCall { .. },
|
||||
ResponseItem::ToolSearchOutput { .. }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ use codex_utils_output_truncation::TruncationPolicy;
|
||||
use codex_utils_output_truncation::formatted_truncate_text;
|
||||
use codex_utils_output_truncation::truncate_text;
|
||||
pub(crate) use executed_tool_calls::ExecutedToolCalls;
|
||||
pub(crate) use executed_tool_calls::input_call_id;
|
||||
pub(crate) use executed_tool_calls::is_matching_tool_output;
|
||||
pub(crate) use executed_tool_calls::output_call_id;
|
||||
pub use multi_agent_tool::MULTI_AGENT_V2_NAMESPACE_DESCRIPTION;
|
||||
pub use router::ToolRouter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user