mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
feedback
This commit is contained in:
@@ -357,7 +357,7 @@ fn process_user_text_item(
|
||||
if let Some(offloaded) = offloader.write_user_message(text) {
|
||||
vec![ContentItem::InputText {
|
||||
text: format!(
|
||||
"User input was too large for the remaining context window and was saved to {}.",
|
||||
"User input was too large for the remaining context window and was saved to {}. Use read_file to load it.",
|
||||
offloaded.display()
|
||||
),
|
||||
}]
|
||||
|
||||
@@ -122,7 +122,7 @@ fn stores_oversized_user_message_in_user_message_dir() {
|
||||
let path = placeholder
|
||||
.split("saved to ")
|
||||
.nth(1)
|
||||
.and_then(|tail| tail.split(" (").next())
|
||||
.and_then(|tail| tail.split(". Use").next())
|
||||
.expect("capture temp path");
|
||||
let path = PathBuf::from(path);
|
||||
|
||||
@@ -208,7 +208,7 @@ fn offloads_each_user_input_item_independently() {
|
||||
let path = placeholder
|
||||
.split("saved to ")
|
||||
.nth(1)
|
||||
.and_then(|tail| tail.strip_suffix('.'))
|
||||
.and_then(|tail| tail.split(". Use").next())
|
||||
.expect("capture temp path");
|
||||
let path = PathBuf::from(path);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
mod user_instructions;
|
||||
|
||||
pub(crate) use user_instructions::SkillInstructions;
|
||||
pub use user_instructions::USER_INSTRUCTIONS_OPEN_TAG_LEGACY;
|
||||
pub use user_instructions::USER_INSTRUCTIONS_OPEN_TAG;
|
||||
pub use user_instructions::USER_INSTRUCTIONS_PREFIX;
|
||||
pub(crate) use user_instructions::UserInstructions;
|
||||
|
||||
@@ -4,9 +4,9 @@ use serde::Serialize;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
|
||||
pub const USER_INSTRUCTIONS_OPEN_TAG_LEGACY: &str = "<user_instructions>";
|
||||
pub const USER_INSTRUCTIONS_PREFIX: &str = "# AGENTS.md instructions for ";
|
||||
pub const SKILL_INSTRUCTIONS_PREFIX: &str = "<skill";
|
||||
pub use codex_protocol::instruction_markers::SKILL_INSTRUCTIONS_PREFIX;
|
||||
pub use codex_protocol::instruction_markers::USER_INSTRUCTIONS_OPEN_TAG;
|
||||
pub use codex_protocol::instruction_markers::USER_INSTRUCTIONS_PREFIX;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename = "user_instructions", rename_all = "snake_case")]
|
||||
@@ -19,7 +19,7 @@ impl UserInstructions {
|
||||
pub fn is_user_instructions(message: &[ContentItem]) -> bool {
|
||||
if let [ContentItem::InputText { text }] = message {
|
||||
text.starts_with(USER_INSTRUCTIONS_PREFIX)
|
||||
|| text.starts_with(USER_INSTRUCTIONS_OPEN_TAG_LEGACY)
|
||||
|| text.starts_with(USER_INSTRUCTIONS_OPEN_TAG)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use std::time::Duration;
|
||||
|
||||
pub use codex_protocol::instruction_markers::USER_SHELL_COMMAND_CLOSE;
|
||||
pub use codex_protocol::instruction_markers::USER_SHELL_COMMAND_OPEN;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
|
||||
@@ -7,9 +9,6 @@ use crate::codex::TurnContext;
|
||||
use crate::exec::ExecToolCallOutput;
|
||||
use crate::tools::format_exec_output_str;
|
||||
|
||||
pub const USER_SHELL_COMMAND_OPEN: &str = "<user_shell_command>";
|
||||
pub const USER_SHELL_COMMAND_CLOSE: &str = "</user_shell_command>";
|
||||
|
||||
pub fn is_user_shell_command_text(text: &str) -> bool {
|
||||
let trimmed = text.trim_start();
|
||||
let lowered = trimmed.to_ascii_lowercase();
|
||||
|
||||
@@ -280,7 +280,7 @@ async fn oversized_user_message_is_written_to_user_message_dir() -> Result<()> {
|
||||
let path = replaced
|
||||
.split("saved to ")
|
||||
.nth(1)
|
||||
.and_then(|tail| tail.strip_suffix('.'))
|
||||
.and_then(|tail| tail.split(". Use").next())
|
||||
.context("extract saved path")?;
|
||||
|
||||
let saved = fs::read_to_string(path).context("read saved user message")?;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
pub const USER_INSTRUCTIONS_PREFIX: &str = "# AGENTS.md instructions for ";
|
||||
pub const USER_INSTRUCTIONS_OPEN_TAG: &str = "<user_instructions>";
|
||||
pub const USER_INSTRUCTIONS_CLOSE_TAG: &str = "</user_instructions>";
|
||||
pub const ENVIRONMENT_CONTEXT_OPEN_TAG: &str = "<environment_context>";
|
||||
pub const ENVIRONMENT_CONTEXT_CLOSE_TAG: &str = "</environment_context>";
|
||||
pub const COLLABORATION_MODE_OPEN_TAG: &str = "<collaboration_mode>";
|
||||
pub const COLLABORATION_MODE_CLOSE_TAG: &str = "</collaboration_mode>";
|
||||
pub const SKILL_INSTRUCTIONS_PREFIX: &str = "<skill";
|
||||
pub const USER_SHELL_COMMAND_OPEN: &str = "<user_shell_command>";
|
||||
pub const USER_SHELL_COMMAND_CLOSE: &str = "</user_shell_command>";
|
||||
pub const IMAGE_OPEN_TAG: &str = "<image>";
|
||||
pub const IMAGE_CLOSE_TAG: &str = "</image>";
|
||||
pub const LOCAL_IMAGE_OPEN_TAG_PREFIX: &str = "<image name=";
|
||||
pub const LOCAL_IMAGE_OPEN_TAG_SUFFIX: &str = ">";
|
||||
@@ -6,6 +6,7 @@ pub use thread_id::ThreadId;
|
||||
pub mod approvals;
|
||||
pub mod config_types;
|
||||
pub mod custom_prompts;
|
||||
pub mod instruction_markers;
|
||||
pub mod items;
|
||||
pub mod message_history;
|
||||
pub mod models;
|
||||
|
||||
@@ -12,9 +12,13 @@ use ts_rs::TS;
|
||||
|
||||
use crate::config_types::CollaborationMode;
|
||||
use crate::config_types::SandboxMode;
|
||||
use crate::instruction_markers::COLLABORATION_MODE_CLOSE_TAG;
|
||||
use crate::instruction_markers::COLLABORATION_MODE_OPEN_TAG;
|
||||
use crate::instruction_markers::IMAGE_CLOSE_TAG;
|
||||
use crate::instruction_markers::IMAGE_OPEN_TAG;
|
||||
use crate::instruction_markers::LOCAL_IMAGE_OPEN_TAG_PREFIX;
|
||||
use crate::instruction_markers::LOCAL_IMAGE_OPEN_TAG_SUFFIX;
|
||||
use crate::protocol::AskForApproval;
|
||||
use crate::protocol::COLLABORATION_MODE_CLOSE_TAG;
|
||||
use crate::protocol::COLLABORATION_MODE_OPEN_TAG;
|
||||
use crate::protocol::NetworkAccess;
|
||||
use crate::protocol::SandboxPolicy;
|
||||
use crate::protocol::WritableRoot;
|
||||
@@ -71,11 +75,11 @@ pub enum ContentItem {
|
||||
OutputText { text: String },
|
||||
}
|
||||
|
||||
const ENVIRONMENT_CONTEXT_PREFIX: &str = "<environment_context>";
|
||||
const USER_INSTRUCTIONS_OPEN_TAG_LEGACY: &str = "<user_instructions>";
|
||||
const USER_INSTRUCTIONS_PREFIX: &str = "# AGENTS.md instructions for ";
|
||||
const SKILL_INSTRUCTIONS_PREFIX: &str = "<skill";
|
||||
const USER_SHELL_COMMAND_OPEN: &str = "<user_shell_command>";
|
||||
use crate::instruction_markers::ENVIRONMENT_CONTEXT_OPEN_TAG;
|
||||
use crate::instruction_markers::SKILL_INSTRUCTIONS_PREFIX;
|
||||
use crate::instruction_markers::USER_INSTRUCTIONS_OPEN_TAG;
|
||||
use crate::instruction_markers::USER_INSTRUCTIONS_PREFIX;
|
||||
use crate::instruction_markers::USER_SHELL_COMMAND_OPEN;
|
||||
|
||||
impl ContentItem {
|
||||
pub fn is_user_message_text(&self) -> bool {
|
||||
@@ -97,14 +101,14 @@ impl ContentItem {
|
||||
|
||||
let trimmed = text.trim_start();
|
||||
if trimmed.starts_with(USER_INSTRUCTIONS_PREFIX)
|
||||
|| trimmed.starts_with(USER_INSTRUCTIONS_OPEN_TAG_LEGACY)
|
||||
|| trimmed.starts_with(USER_INSTRUCTIONS_OPEN_TAG)
|
||||
|| trimmed.starts_with(SKILL_INSTRUCTIONS_PREFIX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let lowered = trimmed.to_ascii_lowercase();
|
||||
if lowered.starts_with(ENVIRONMENT_CONTEXT_PREFIX)
|
||||
if lowered.starts_with(ENVIRONMENT_CONTEXT_OPEN_TAG)
|
||||
|| lowered.starts_with(USER_SHELL_COMMAND_OPEN)
|
||||
{
|
||||
return false;
|
||||
@@ -406,10 +410,6 @@ fn local_image_error_placeholder(
|
||||
|
||||
pub const VIEW_IMAGE_TOOL_NAME: &str = "view_image";
|
||||
|
||||
const IMAGE_OPEN_TAG: &str = "<image>";
|
||||
const IMAGE_CLOSE_TAG: &str = "</image>";
|
||||
const LOCAL_IMAGE_OPEN_TAG_PREFIX: &str = "<image name=";
|
||||
const LOCAL_IMAGE_OPEN_TAG_SUFFIX: &str = ">";
|
||||
const LOCAL_IMAGE_CLOSE_TAG: &str = IMAGE_CLOSE_TAG;
|
||||
|
||||
pub fn image_open_tag_text() -> String {
|
||||
|
||||
@@ -16,6 +16,12 @@ use crate::approvals::ElicitationRequestEvent;
|
||||
use crate::config_types::CollaborationMode;
|
||||
use crate::config_types::ReasoningSummary as ReasoningSummaryConfig;
|
||||
use crate::custom_prompts::CustomPrompt;
|
||||
pub use crate::instruction_markers::COLLABORATION_MODE_CLOSE_TAG;
|
||||
pub use crate::instruction_markers::COLLABORATION_MODE_OPEN_TAG;
|
||||
pub use crate::instruction_markers::ENVIRONMENT_CONTEXT_CLOSE_TAG;
|
||||
pub use crate::instruction_markers::ENVIRONMENT_CONTEXT_OPEN_TAG;
|
||||
pub use crate::instruction_markers::USER_INSTRUCTIONS_CLOSE_TAG;
|
||||
pub use crate::instruction_markers::USER_INSTRUCTIONS_OPEN_TAG;
|
||||
use crate::items::TurnItem;
|
||||
use crate::message_history::HistoryEntry;
|
||||
use crate::models::ContentItem;
|
||||
@@ -45,14 +51,6 @@ pub use crate::approvals::ElicitationAction;
|
||||
pub use crate::approvals::ExecApprovalRequestEvent;
|
||||
pub use crate::approvals::ExecPolicyAmendment;
|
||||
|
||||
/// Open/close tags for special user-input blocks. Used across crates to avoid
|
||||
/// duplicated hardcoded strings.
|
||||
pub const USER_INSTRUCTIONS_OPEN_TAG: &str = "<user_instructions>";
|
||||
pub const USER_INSTRUCTIONS_CLOSE_TAG: &str = "</user_instructions>";
|
||||
pub const ENVIRONMENT_CONTEXT_OPEN_TAG: &str = "<environment_context>";
|
||||
pub const ENVIRONMENT_CONTEXT_CLOSE_TAG: &str = "</environment_context>";
|
||||
pub const COLLABORATION_MODE_OPEN_TAG: &str = "<collaboration_mode>";
|
||||
pub const COLLABORATION_MODE_CLOSE_TAG: &str = "</collaboration_mode>";
|
||||
pub const USER_MESSAGE_BEGIN: &str = "## My request for Codex:";
|
||||
|
||||
/// Submission Queue Entry - requests from user
|
||||
|
||||
Reference in New Issue
Block a user