aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT
- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser, device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity, runtime agent instance, backend-client e openapi-models, workspace routing. - Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin remoti (catalogo, sync, share), cyber access program, daybreak, cloud config e requirements (config_server ora fail-closed), attestation, frozen cloud skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/ routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime. - Messaggi d'errore senza link a chatgpt.com. - Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed. - Test: cancellati solo quelli del codice rimosso; test di sicurezza (sandbox estensioni, permessi, redazione, auth storage, requirements) adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents). - Istruzioni di sistema invariate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -70,7 +70,6 @@ const AUTO_COMPACT_FALLBACK_PROMPT: &str = "Save the important state before roll
|
||||
fn model_token_budget_config() -> ModelTokenBudgetConfig {
|
||||
ModelTokenBudgetConfig {
|
||||
enabled: false,
|
||||
use_history_notes_extension: false,
|
||||
reminder_threshold_tokens: 6_144,
|
||||
reminder_message_template: "Model reminder: {n_remaining} tokens remain.".to_string(),
|
||||
guidance_message: "Use the model-owned context-window guidance.".to_string(),
|
||||
@@ -243,7 +242,6 @@ async fn token_budget_context_is_only_emitted_with_full_context() -> Result<()>
|
||||
}
|
||||
|
||||
#[test_case("features.token_budget.enabled = true"; "token_budget")]
|
||||
#[test_case("features.context_management.experimental_mode = true"; "experimental_mode")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn token_budget_guidance_precedes_standalone_context_window(
|
||||
activation: &'static str,
|
||||
@@ -265,11 +263,7 @@ async fn token_budget_guidance_precedes_standalone_context_window(
|
||||
.with_model_info_override("gpt-5.2", |model| {
|
||||
model.supports_experimental_context = true;
|
||||
})
|
||||
.with_auth(CodexAuth::from_external_chatgpt_tokens(
|
||||
"header.e30.signature",
|
||||
"account-123",
|
||||
Some("plus"),
|
||||
)?)
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_pre_build_hook(move |home| {
|
||||
std::fs::write(
|
||||
home.join("config.toml"),
|
||||
@@ -314,74 +308,13 @@ async fn token_budget_guidance_precedes_standalone_context_window(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case("OpenAI", "/backend-api/codex", None, true, true; "codex_backend")]
|
||||
#[test_case("OpenAI", "/backend-api/codex", None, false, false; "unsupported_model")]
|
||||
#[test_case("Custom", "/backend-api/codex", None, true, false; "custom_provider")]
|
||||
#[test_case("OpenAI", "/v1", None, true, false; "non_codex_endpoint")]
|
||||
#[test_case("OpenAI", "/backend-api/codex", Some("test-provider-token"), true, false; "provider_credentials")]
|
||||
#[test_case(false, false; "explicit_without_experimental_capability")]
|
||||
#[test_case(false, true; "explicit_with_experimental_capability")]
|
||||
#[test_case(true, false; "model_default_without_experimental_capability")]
|
||||
#[test_case(true, true; "model_default_with_experimental_capability")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn experimental_context_requires_capable_model_and_codex_backend(
|
||||
provider_name: &'static str,
|
||||
base_path: &'static str,
|
||||
bearer_token: Option<&'static str>,
|
||||
supports_context: bool,
|
||||
expected_enabled: bool,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let response = mount_sse_once(&server, sse_completed("resp-1")).await;
|
||||
let base_url = format!("{}{base_path}", server.uri());
|
||||
let test = test_codex()
|
||||
.with_model_info_override("gpt-5.2", move |model| {
|
||||
model.supports_experimental_context = supports_context;
|
||||
})
|
||||
.with_auth(CodexAuth::from_external_chatgpt_tokens(
|
||||
"header.e30.signature",
|
||||
"account-123",
|
||||
Some("plus"),
|
||||
)?)
|
||||
.with_config(move |config| {
|
||||
config.model_provider.name = provider_name.to_string();
|
||||
config.model_provider.base_url = Some(base_url);
|
||||
config.model_provider.experimental_bearer_token = bearer_token.map(Into::into);
|
||||
config.model_context_window = Some(CONFIGURED_CONTEXT_WINDOW);
|
||||
config
|
||||
.features
|
||||
.enable(Feature::ContextManagement)
|
||||
.expect("test config should allow experimental context");
|
||||
})
|
||||
.build_with_auto_env(&server)
|
||||
.await?;
|
||||
|
||||
test.submit_turn("inspect experimental context activation")
|
||||
.await?;
|
||||
|
||||
let request = response.single_request();
|
||||
assert_eq!(
|
||||
tool_names(&request)
|
||||
.iter()
|
||||
.any(|name| name == "new_context"),
|
||||
expected_enabled
|
||||
);
|
||||
assert_eq!(
|
||||
!token_budget_contexts(&request).is_empty(),
|
||||
expected_enabled
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(false, true, false; "explicit_history_notes_without_experimental_capability")]
|
||||
#[test_case(false, true, true; "explicit_history_notes_with_experimental_capability")]
|
||||
#[test_case(false, false, false; "explicit_standalone_token_budget")]
|
||||
#[test_case(true, true, false; "model_default_history_notes_without_experimental_capability")]
|
||||
#[test_case(true, true, true; "model_default_history_notes_with_experimental_capability")]
|
||||
#[test_case(true, false, false; "model_default_standalone_token_budget")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn token_budget_history_notes_can_be_enabled_without_experimental_context(
|
||||
async fn token_budget_can_be_enabled_without_experimental_context(
|
||||
use_model_defaults: bool,
|
||||
use_history_notes: bool,
|
||||
supports_context: bool,
|
||||
) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
@@ -389,18 +322,13 @@ async fn token_budget_history_notes_can_be_enabled_without_experimental_context(
|
||||
let server = start_mock_server().await;
|
||||
let backend_url = format!("{}/backend-api/codex", server.uri());
|
||||
let mut builder = test_codex()
|
||||
.with_auth(CodexAuth::from_external_chatgpt_tokens(
|
||||
"header.e30.signature",
|
||||
"account-123",
|
||||
Some("plus"),
|
||||
)?)
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_pre_build_hook(move |home| {
|
||||
let config = if use_model_defaults {
|
||||
"[features.context_management]\nexperimental_mode = false\n".to_string()
|
||||
} else {
|
||||
format!(
|
||||
"[features.context_management]\nexperimental_mode = false\n[features.token_budget]\nenabled = true\nuse_history_notes_extension = {use_history_notes}\n"
|
||||
)
|
||||
"[features.context_management]\nexperimental_mode = false\n[features.token_budget]\nenabled = true\n"
|
||||
.to_string()
|
||||
};
|
||||
std::fs::write(home.join("config.toml"), config)
|
||||
.expect("write token-budget configuration");
|
||||
@@ -409,7 +337,6 @@ async fn token_budget_history_notes_can_be_enabled_without_experimental_context(
|
||||
model_info.supports_experimental_context = supports_context;
|
||||
let mut defaults = model_token_budget_config();
|
||||
defaults.enabled = use_model_defaults;
|
||||
defaults.use_history_notes_extension = use_history_notes;
|
||||
model_info
|
||||
.model_messages
|
||||
.as_mut()
|
||||
@@ -458,10 +385,7 @@ async fn token_budget_history_notes_can_be_enabled_without_experimental_context(
|
||||
.header("x-codex-turn-metadata")
|
||||
.expect("request should include turn metadata"),
|
||||
)?;
|
||||
assert_eq!(
|
||||
turn_metadata["history_ingest_requested"].as_bool(),
|
||||
use_history_notes.then_some(true)
|
||||
);
|
||||
assert_eq!(turn_metadata.get("history_ingest_requested"), None);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -474,7 +398,6 @@ async fn token_budget_uses_model_message_defaults() -> Result<()> {
|
||||
let response = mount_sse_once(&server, sse_completed("resp-1")).await;
|
||||
let mut model_defaults = model_token_budget_config();
|
||||
model_defaults.enabled = true;
|
||||
model_defaults.use_history_notes_extension = true;
|
||||
let expected_guidance = model_defaults.guidance_message.clone();
|
||||
let test = test_codex()
|
||||
.with_model_info_override("gpt-5.2", move |model_info| {
|
||||
@@ -557,7 +480,6 @@ async fn token_budget_explicit_default_template_overrides_model_defaults() -> Re
|
||||
}
|
||||
|
||||
#[test_case(Feature::TokenBudget; "explicit_activation")]
|
||||
#[test_case(Feature::ContextManagement; "experimental_activation")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn token_budget_defaults_follow_the_active_model(activation: Feature) -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
@@ -570,11 +492,7 @@ async fn token_budget_defaults_follow_the_active_model(activation: Feature) -> R
|
||||
.await;
|
||||
let backend_url = format!("{}/backend-api/codex", server.uri());
|
||||
let test = test_codex()
|
||||
.with_auth(CodexAuth::from_external_chatgpt_tokens(
|
||||
"header.e30.signature",
|
||||
"account-123",
|
||||
Some("plus"),
|
||||
)?)
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_model_info_override("gpt-5.2", |model_info| {
|
||||
model_info.supports_experimental_context = true;
|
||||
let mut defaults = model_token_budget_config();
|
||||
@@ -1699,7 +1617,6 @@ async fn new_context_tool_skips_auto_compact_fallback() -> Result<()> {
|
||||
omit_descriptions: false,
|
||||
max_context_tokens: config.skill_max_context_tokens,
|
||||
bundled_skills_enabled: config.bundled_skills_enabled(),
|
||||
cloud_skill_enabled: config.cloud_skill_enabled,
|
||||
shadow_selection_enabled: config.features.enabled(Feature::SkillSearch),
|
||||
});
|
||||
let test = test_codex()
|
||||
|
||||
Reference in New Issue
Block a user