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
68 lines
3.0 KiB
Rust
68 lines
3.0 KiB
Rust
//! Sparse model-catalog wording for generic, selected, and recommended plugins.
|
|
|
|
use codex_utils_cached_str::CodexCachedStr;
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use ts_rs::TS;
|
|
|
|
/// Sparse plugin wording families, independent of runtime availability and authorization.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
|
pub struct PluginMessages {
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub generic: Option<GenericPluginMessages>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub selected: Option<SelectedPluginMessages>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub recommendations: Option<PluginRecommendationMessages>,
|
|
}
|
|
|
|
/// Literal generic plugin wording. Missing, null, blank, or invalid values use bundled text.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
|
pub struct GenericPluginMessages {
|
|
/// Literal text, up to 500 UTF-8 bytes.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub intro: Option<CodexCachedStr>,
|
|
/// Up to 2,000 UTF-8 bytes.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub usage_instructions: Option<CodexCachedStr>,
|
|
}
|
|
|
|
/// Selected-plugin wording. Fact-bearing fields require exactly one documented placeholder.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
|
pub struct SelectedPluginMessages {
|
|
/// Up to 500 UTF-8 bytes. Selected intro requires `{{ plugin_name }}`.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub intro: Option<CodexCachedStr>,
|
|
/// Up to 500 UTF-8 bytes.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub search_tools: Option<CodexCachedStr>,
|
|
/// Up to 500 UTF-8 bytes; requires `{{ skill_namespace }}`.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub skill_namespace: Option<CodexCachedStr>,
|
|
/// Up to 500 UTF-8 bytes; requires `{{ apps }}`.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub apps: Option<CodexCachedStr>,
|
|
/// Up to 500 UTF-8 bytes; requires `{{ mcp_servers }}`.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub mcp_servers: Option<CodexCachedStr>,
|
|
/// Up to 500 UTF-8 bytes.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub closing: Option<CodexCachedStr>,
|
|
/// Nonblank omission notice, up to 500 UTF-8 bytes, including any desired separator.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub omitted: Option<CodexCachedStr>,
|
|
}
|
|
|
|
/// Literal recommendation introduction; plugin identities remain supplied by the harness.
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq, Eq, TS, JsonSchema)]
|
|
pub struct PluginRecommendationMessages {
|
|
/// Literal text, up to 500 UTF-8 bytes.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub intro: Option<CodexCachedStr>,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "plugins_tests.rs"]
|
|
mod tests;
|