mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve complete actions in Guardian approval reviews (#44569)
## Why Truncating action arguments can leave approval reviewers evaluating incomplete actions. Large actions need complete review input and explicit handling when they exceed the review budget. ## What changed - Remove action truncation and the fixed synchronous action byte limit. Admit complete actions against the whole-request budget, splitting long text losslessly into bounded transport parts and accounting for their framing. - Route actions exceeding the asynchronous action budget to synchronous review. Prevent cached scores from covering oversized calls, including expanded approval arguments, while allowing later small actions to recover score reuse. - Request user approval when optional review exhausts its local input budget. Keep required review and compaction service failures closed to approval, and retire exhausted review sessions. ## Testing Add coverage for complete large-action delivery, optional user fallback, required-review denial, subsequent review recovery, async overflow through MCP approval routing, and lossless text splitting with budget accounting. GitOrigin-RevId: 08f06e68a94b2f779480dd6b6cf5bc30b241f6dd
This commit is contained in:
1 parent
3319d9b296
commit
9c4879f3a5
33 files changed
+841
-547
No files matched your search
@@ -2,10 +2,12 @@
|
||||
//! Profiles retain the host-selected transcript slice; composition owns
|
||||
//! framing, message boundaries and section placement, without retaining history.
|
||||
//! Each content item keeps its selection policy until transport conversion.
|
||||
//! Long text splits losslessly only after admission, preserving whole-entry selection.
|
||||
|
||||
use codex_context_fragments::ContextualUserFragment;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::protocol::TruncationPolicy;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
|
||||
use crate::ActionPresentation;
|
||||
@@ -272,10 +274,13 @@ impl ComposedContext {
|
||||
};
|
||||
for item in content {
|
||||
inputs.push(match item.content {
|
||||
ContentItem::InputText { text } => UserInput::Text {
|
||||
text,
|
||||
text_elements: Vec::new(),
|
||||
},
|
||||
ContentItem::InputText { text } => {
|
||||
inputs.extend(bounded_text_parts(&text).map(|part| UserInput::Text {
|
||||
text: part.to_owned(),
|
||||
text_elements: Vec::new(),
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
ContentItem::InputImage { image_url, detail } => {
|
||||
UserInput::Image { image_url, detail }
|
||||
}
|
||||
@@ -297,7 +302,18 @@ impl ComposedContext {
|
||||
for section in self.sections {
|
||||
match section.delivery {
|
||||
SectionDelivery::UserContent(content) => {
|
||||
user_content.extend(content.into_iter().map(|item| item.content))
|
||||
for item in content {
|
||||
match item.content {
|
||||
ContentItem::InputText { text } => {
|
||||
user_content.extend(bounded_text_parts(&text).map(|part| {
|
||||
ContentItem::InputText {
|
||||
text: part.to_owned(),
|
||||
}
|
||||
}));
|
||||
}
|
||||
content => user_content.push(content),
|
||||
}
|
||||
}
|
||||
}
|
||||
SectionDelivery::Message(message) => {
|
||||
if !user_content.is_empty() {
|
||||
@@ -314,6 +330,20 @@ impl ComposedContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Bounds individual text parts without changing source text or entry identity.
|
||||
/// Budget estimates include the extra wire framing before transport conversion.
|
||||
pub(super) fn bounded_text_parts(text: &str) -> impl Iterator<Item = &str> {
|
||||
let mut remaining = Some(text);
|
||||
std::iter::from_fn(move || {
|
||||
let text = remaining.take()?;
|
||||
let end = text.floor_char_boundary(TruncationPolicy::Tokens(9_000).byte_budget());
|
||||
if end < text.len() {
|
||||
remaining = Some(&text[end..]);
|
||||
}
|
||||
Some(&text[..end])
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn user_message(content: Vec<ContentItem>) -> ResponseItem {
|
||||
ResponseItem::Message {
|
||||
id: None,
|
||||
|
||||
Reference in new issue
Block a user