mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
## Why Identical instructions and tool descriptions can appear in multiple model catalog records. Each decode or clone previously allocated its own copy of that text. ## What changed Use `CodexCachedStr` for catalog instructions, messages, and tool overrides. It stores short strings inline and interns longer strings so independent decodes and clones can share storage. Resolved incremental tool messages also reuse cached text from overrides and bundled defaults. JSON and generated TypeScript still represent these values as strings. ## Testing Add tests for shared storage across catalog fields, independent decodes, clones, and incremental tool defaults. Cover plain JSON string round trips and borrowed access to short inline UTF-8 strings. GitOrigin-RevId: 6f53b4e19f01f6ed52a8fd364279b924cf794be2
66 lines
3.1 KiB
Rust
66 lines
3.1 KiB
Rust
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use ts_rs::TS;
|
|
|
|
use super::ReasoningEffort;
|
|
use codex_utils_cached_str::CodexCachedStr;
|
|
|
|
/// Legacy classifier modes retained for configuration and model-catalog compatibility.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, TS, JsonSchema)]
|
|
#[serde(rename_all = "snake_case")]
|
|
#[ts(rename_all = "snake_case")]
|
|
pub enum AsyncClassifierMode {
|
|
Snapshot,
|
|
#[default]
|
|
Conversation,
|
|
}
|
|
|
|
/// Optional model-owned defaults for Guardian v2 classification experiments.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
|
pub struct GuardianV2ModelConfig {
|
|
/// Deprecated and ignored; asynchronous classification always uses conversations.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub async_classifier_mode: Option<AsyncClassifierMode>,
|
|
/// Reset retained async history when the next request exceeds this token estimate.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub async_classifier_conversation_token_limit: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub classifier_instructions: Option<CodexCachedStr>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub review_threshold_basis_points: Option<u16>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_tool_call_lag: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub reasoning_effort: Option<ReasoningEffort>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub transcript: Option<GuardianV2TranscriptModelConfig>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_action_tokens: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_classifier_instruction_tokens: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub reuse_parent_compaction: Option<bool>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_parent_compaction_tokens: Option<usize>,
|
|
}
|
|
|
|
/// Optional model-owned defaults for selecting and bounding Guardian v2 history.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
|
pub struct GuardianV2TranscriptModelConfig {
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub sources: Option<Vec<CodexCachedStr>>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub include_images: Option<bool>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_message_entry_tokens: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_tool_entry_tokens: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_message_transcript_tokens: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_tool_transcript_tokens: Option<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub max_recent_non_user_entries: Option<usize>,
|
|
}
|