Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: reduce duplicate include_str!() calls (#8914)

Michael Bolin59d693755017
diff --git a/codex-rs/core/src/models_manager/model_info.rs b/codex-rs/core/src/models_manager/model_info.rs
index 6e46b93586..5feeb6e12a 100644
--- a/codex-rs/core/src/models_manager/model_info.rs
+++ b/codex-rs/core/src/models_manager/model_info.rs
@@ -12,7 +12,7 @@ use crate::config::Config;
use crate::truncate::approx_bytes_for_tokens;
use tracing::warn;
-const BASE_INSTRUCTIONS: &str = include_str!("../../prompt.md");
+pub const BASE_INSTRUCTIONS: &str = include_str!("../../prompt.md");
const BASE_INSTRUCTIONS_WITH_APPLY_PATCH: &str =
include_str!("../../prompt_with_apply_patch_instructions.md");
diff --git a/codex-rs/core/tests/suite/prompt_caching.rs b/codex-rs/core/tests/suite/prompt_caching.rs
index da0d011208..9622332cad 100644
--- a/codex-rs/core/tests/suite/prompt_caching.rs
+++ b/codex-rs/core/tests/suite/prompt_caching.rs
@@ -1,6 +1,8 @@
#![allow(clippy::unwrap_used)]
+use codex_apply_patch::APPLY_PATCH_TOOL_INSTRUCTIONS;
use codex_core::features::Feature;
+use codex_core::models_manager::model_info::BASE_INSTRUCTIONS;
use codex_core::protocol::AskForApproval;
use codex_core::protocol::ENVIRONMENT_CONTEXT_OPEN_TAG;
use codex_core::protocol::EventMsg;
@@ -130,11 +132,7 @@ async fn prompt_tools_are_consistent_across_requests() -> anyhow::Result<()> {
let expected_instructions = if expected_tools_names.contains(&"apply_patch") {
base_instructions
} else {
- [
- base_instructions,
- include_str!("../../../apply-patch/apply_patch_tool_instructions.md").to_string(),
- ]
- .join("\n")
+ [base_instructions, APPLY_PATCH_TOOL_INSTRUCTIONS.to_string()].join("\n")
};
assert_eq!(
@@ -192,11 +190,7 @@ async fn codex_mini_latest_tools() -> anyhow::Result<()> {
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TaskComplete(_))).await;
- let expected_instructions = [
- include_str!("../../prompt.md"),
- include_str!("../../../apply-patch/apply_patch_tool_instructions.md"),
- ]
- .join("\n");
+ let expected_instructions = [BASE_INSTRUCTIONS, APPLY_PATCH_TOOL_INSTRUCTIONS].join("\n");
let body0 = req1.single_request().body_json();
let instructions0 = body0["instructions"]