Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Client headers (#2487)

Gabriel Pealeaae56a1b0bb
diff --git a/codex-rs/core/src/config.rs b/codex-rs/core/src/config.rs
index e0ff411f15..90c5ba4a60 100644
--- a/codex-rs/core/src/config.rs
+++ b/codex-rs/core/src/config.rs
@@ -13,6 +13,7 @@ use crate::model_provider_info::built_in_model_providers;
use crate::openai_model_info::get_model_info;
use crate::protocol::AskForApproval;
use crate::protocol::SandboxPolicy;
+use crate::spawn::CODEX_ORIGINATOR_ENV_VAR;
use codex_login::AuthMode;
use codex_protocol::config_types::ReasoningEffort;
use codex_protocol::config_types::ReasoningSummary;
@@ -625,6 +626,10 @@ impl Config {
let include_apply_patch_tool_val =
include_apply_patch_tool.unwrap_or(model_family.uses_apply_patch_tool);
+ let originator = std::env::var(CODEX_ORIGINATOR_ENV_VAR)
+ .ok()
+ .or(cfg.internal_originator);
+
let config = Self {
model,
model_family,
@@ -678,7 +683,7 @@ impl Config {
experimental_resume,
include_plan_tool: include_plan_tool.unwrap_or(false),
include_apply_patch_tool: include_apply_patch_tool_val,
- internal_originator: cfg.internal_originator,
+ internal_originator: originator,
preferred_auth_method: cfg.preferred_auth_method.unwrap_or(AuthMode::ChatGPT),
};
Ok(config)
diff --git a/codex-rs/core/src/spawn.rs b/codex-rs/core/src/spawn.rs
index 1c82df3180..d93e28ef63 100644
--- a/codex-rs/core/src/spawn.rs
+++ b/codex-rs/core/src/spawn.rs
@@ -22,6 +22,9 @@ pub const CODEX_SANDBOX_NETWORK_DISABLED_ENV_VAR: &str = "CODEX_SANDBOX_NETWORK_
/// accommodate sandboxing configuration and other sandboxing mechanisms.
pub const CODEX_SANDBOX_ENV_VAR: &str = "CODEX_SANDBOX";
+/// Set this to change the originator sent with all network requests.
+pub const CODEX_ORIGINATOR_ENV_VAR: &str = "CODEX_ORIGINATOR";
+
#[derive(Debug, Clone, Copy)]
pub enum StdioPolicy {
RedirectForShellTool,