Skip to content

Commit 4480309

Browse files
zhaojing.jzclaude
andcommitted
feat: add support for CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS and CLAUDE_CODE_DISABLE_1M_CONTEXT
- Add two new fields to Configuration struct to preserve additional environment variables - Update get_env_field_names() to include new fields (12 total) - Update all test files to include new fields in Configuration instantiations - All 55 tests pass, no clippy warnings, code properly formatted Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e585be9 commit 4480309

10 files changed

Lines changed: 225 additions & 13 deletions

File tree

.serena/project.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,17 @@ read_only_memory_patterns: []
133133
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
134134
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
135135
line_ending:
136+
137+
# list of regex patterns for memories to completely ignore.
138+
# Matching memories will not appear in list_memories or activate_project output
139+
# and cannot be accessed via read_memory or write_memory.
140+
# To access ignored memory files, use the read_file tool on the raw file path.
141+
# Extends the list from the global configuration, merging the two lists.
142+
# Example: ["_archive/.*", "_episodes/.*"]
143+
ignored_memory_patterns: []
144+
145+
# advanced configuration option allowing to configure language server-specific options.
146+
# Maps the language key to the options.
147+
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
148+
# No documentation on options means no options are available.
149+
ls_specific_settings: {}

src/claude_settings.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,47 @@ impl ClaudeSettings {
118118
small_fast_model.clone(),
119119
);
120120
}
121+
122+
// Set additional configuration values that should not be removed
123+
if let Some(max_thinking_tokens) = config.max_thinking_tokens {
124+
self.env.insert(
125+
"ANTHROPIC_MAX_THINKING_TOKENS".to_string(),
126+
max_thinking_tokens.to_string(),
127+
);
128+
}
129+
130+
if let Some(timeout) = config.api_timeout_ms {
131+
self.env
132+
.insert("API_TIMEOUT_MS".to_string(), timeout.to_string());
133+
}
134+
135+
if let Some(flag) = config.claude_code_disable_nonessential_traffic {
136+
self.env.insert(
137+
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC".to_string(),
138+
flag.to_string(),
139+
);
140+
}
141+
142+
if let Some(model) = &config.anthropic_default_sonnet_model
143+
&& !model.is_empty()
144+
{
145+
self.env
146+
.insert("ANTHROPIC_DEFAULT_SONNET_MODEL".to_string(), model.clone());
147+
}
148+
149+
if let Some(model) = &config.anthropic_default_opus_model
150+
&& !model.is_empty()
151+
{
152+
self.env
153+
.insert("ANTHROPIC_DEFAULT_OPUS_MODEL".to_string(), model.clone());
154+
}
155+
156+
if let Some(model) = &config.anthropic_default_haiku_model
157+
&& !model.is_empty()
158+
{
159+
self.env
160+
.insert("ANTHROPIC_DEFAULT_HAIKU_MODEL".to_string(), model.clone());
161+
}
121162
}
122163

123164
/// Remove Anthropic environment variables

src/cli/main.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ fn handle_add_command(mut params: AddCommandParams, storage: &mut ConfigStorage)
434434
anthropic_default_sonnet_model: final_anthropic_default_sonnet_model,
435435
anthropic_default_opus_model: final_anthropic_default_opus_model,
436436
anthropic_default_haiku_model: final_anthropic_default_haiku_model,
437+
claude_code_experimental_agent_teams: None,
438+
claude_code_disable_1m_context: None,
437439
};
438440

439441
storage.add_configuration(config);
@@ -632,20 +634,16 @@ pub fn run() -> Result<()> {
632634
let storage_mode = storage.default_storage_mode.clone().unwrap_or_default();
633635

634636
// Update settings.json with the configuration
635-
let mut settings = ClaudeSettings::load(
636-
storage.get_claude_settings_dir().map(|s| s.as_str()),
637-
)?;
637+
let mut settings =
638+
ClaudeSettings::load(storage.get_claude_settings_dir().map(|s| s.as_str()))?;
638639
settings.switch_to_config_with_mode(
639640
&config,
640641
storage_mode,
641642
storage.get_claude_settings_dir().map(|s| s.as_str()),
642643
)?;
643644

644645
println!("Switched to configuration '{}'", alias_name);
645-
println!(
646-
" URL: {}",
647-
config.url
648-
);
646+
println!(" URL: {}", config.url);
649647
println!(
650648
" Token: {}",
651649
crate::cli::display_utils::format_token_for_display(&config.token)

src/config/types.rs

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ pub struct Configuration {
6060
/// Default Haiku model name
6161
#[serde(skip_serializing_if = "Option::is_none")]
6262
pub anthropic_default_haiku_model: Option<String>,
63+
/// Enable experimental agent teams flag
64+
#[serde(skip_serializing_if = "Option::is_none")]
65+
pub claude_code_experimental_agent_teams: Option<u32>,
66+
/// Disable 1M context limit flag
67+
#[serde(skip_serializing_if = "Option::is_none")]
68+
pub claude_code_disable_1m_context: Option<u32>,
6369
}
6470

6571
impl Configuration {
@@ -77,6 +83,8 @@ impl Configuration {
7783
"ANTHROPIC_MAX_THINKING_TOKENS",
7884
"API_TIMEOUT_MS",
7985
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
86+
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS",
87+
"CLAUDE_CODE_DISABLE_1M_CONTEXT",
8088
"ANTHROPIC_DEFAULT_SONNET_MODEL",
8189
"ANTHROPIC_DEFAULT_OPUS_MODEL",
8290
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
@@ -104,12 +112,14 @@ mod tests {
104112
"ANTHROPIC_DEFAULT_SONNET_MODEL",
105113
"ANTHROPIC_DEFAULT_OPUS_MODEL",
106114
"ANTHROPIC_DEFAULT_HAIKU_MODEL",
115+
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS",
116+
"CLAUDE_CODE_DISABLE_1M_CONTEXT",
107117
];
108118

109119
assert_eq!(
110120
fields.len(),
111121
expected_fields.len(),
112-
"Should have exactly 10 fields"
122+
"Should have exactly 12 fields"
113123
);
114124

115125
for expected_field in expected_fields {
@@ -204,6 +214,85 @@ mod tests {
204214
anthropic_default_sonnet_model: Some("new_sonnet".to_string()),
205215
anthropic_default_opus_model: Some("new_opus".to_string()),
206216
anthropic_default_haiku_model: Some("new_haiku".to_string()),
217+
claude_code_experimental_agent_teams: None,
218+
claude_code_disable_1m_context: None,
219+
};
220+
221+
// Switch to new configuration
222+
settings.switch_to_config(&config);
223+
224+
// Verify the required fields are set correctly
225+
assert_eq!(
226+
settings.env.get("ANTHROPIC_AUTH_TOKEN"),
227+
Some(&"new_token".to_string())
228+
);
229+
assert_eq!(
230+
settings.env.get("ANTHROPIC_BASE_URL"),
231+
Some(&"https://api.new.com".to_string())
232+
);
233+
assert_eq!(
234+
settings.env.get("ANTHROPIC_MODEL"),
235+
Some(&"new_model".to_string())
236+
);
237+
assert_eq!(
238+
settings.env.get("ANTHROPIC_SMALL_FAST_MODEL"),
239+
Some(&"new_fast_model".to_string())
240+
);
241+
242+
// Verify additional fields are set correctly when provided in config
243+
assert_eq!(
244+
settings.env.get("ANTHROPIC_MAX_THINKING_TOKENS"),
245+
Some(&"50000".to_string())
246+
);
247+
assert_eq!(
248+
settings.env.get("API_TIMEOUT_MS"),
249+
Some(&"300000".to_string())
250+
);
251+
assert_eq!(
252+
settings.env.get("CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC"),
253+
Some(&"1".to_string())
254+
);
255+
assert_eq!(
256+
settings.env.get("ANTHROPIC_DEFAULT_SONNET_MODEL"),
257+
Some(&"new_sonnet".to_string())
258+
);
259+
assert_eq!(
260+
settings.env.get("ANTHROPIC_DEFAULT_OPUS_MODEL"),
261+
Some(&"new_opus".to_string())
262+
);
263+
assert_eq!(
264+
settings.env.get("ANTHROPIC_DEFAULT_HAIKU_MODEL"),
265+
Some(&"new_haiku".to_string())
266+
);
267+
}
268+
269+
#[test]
270+
fn test_switch_to_config_removes_optional_fields_when_not_provided() {
271+
let mut settings = ClaudeSettings::default();
272+
273+
// Add all possible environment variables with old values
274+
let env_fields = Configuration::get_env_field_names();
275+
for field in &env_fields {
276+
settings
277+
.env
278+
.insert(field.to_string(), "old_value".to_string());
279+
}
280+
281+
// Create a test configuration without optional fields
282+
let config = Configuration {
283+
alias_name: "test".to_string(),
284+
token: "new_token".to_string(),
285+
url: "https://api.new.com".to_string(),
286+
model: Some("new_model".to_string()),
287+
small_fast_model: Some("new_fast_model".to_string()),
288+
max_thinking_tokens: None,
289+
api_timeout_ms: None,
290+
claude_code_disable_nonessential_traffic: None,
291+
anthropic_default_sonnet_model: None,
292+
anthropic_default_opus_model: None,
293+
anthropic_default_haiku_model: None,
294+
claude_code_experimental_agent_teams: None,
295+
claude_code_disable_1m_context: None,
207296
};
208297

209298
// Switch to new configuration
@@ -227,7 +316,7 @@ mod tests {
227316
Some(&"new_fast_model".to_string())
228317
);
229318

230-
// Verify fields not set in the config are removed (not just left with old values)
319+
// Verify optional fields are removed when not provided in config
231320
assert!(!settings.env.contains_key("ANTHROPIC_MAX_THINKING_TOKENS"));
232321
assert!(!settings.env.contains_key("API_TIMEOUT_MS"));
233322
assert!(

src/interactive/interactive.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,12 @@ fn handle_full_interactive_menu(
664664
// Clean up terminal before processing selection
665665
cleanup_terminal(stdout);
666666

667-
return handle_selection_action(&configs.iter().collect::<Vec<_>>(), 0, storage, storage_mode);
667+
return handle_selection_action(
668+
&configs.iter().collect::<Vec<_>>(),
669+
0,
670+
storage,
671+
storage_mode,
672+
);
668673
}
669674
KeyCode::Char('e') | KeyCode::Char('E') => {
670675
// Only allow editing if a config is selected (not official or exit)
@@ -691,7 +696,11 @@ fn handle_full_interactive_menu(
691696
Ok(_) => {
692697
// Configuration was saved successfully, reload configs
693698
if let Ok(reloaded_storage) = ConfigStorage::load() {
694-
*configs = reloaded_storage.configurations.values().cloned().collect();
699+
*configs = reloaded_storage
700+
.configurations
701+
.values()
702+
.cloned()
703+
.collect();
695704
configs.sort_by(|a, b| a.alias_name.cmp(&b.alias_name));
696705
// Keep selection within bounds
697706
if *selected_index > configs.len() + 1 {

tests/error_handling_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ mod error_handling_tests {
1717
anthropic_default_sonnet_model: None,
1818
anthropic_default_opus_model: None,
1919
anthropic_default_haiku_model: None,
20+
claude_code_experimental_agent_teams: None,
21+
claude_code_disable_1m_context: None,
2022
}
2123
}
2224

tests/integration_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ mod integration_tests {
2424
anthropic_default_sonnet_model: None,
2525
anthropic_default_opus_model: None,
2626
anthropic_default_haiku_model: None,
27+
claude_code_experimental_agent_teams: None,
28+
claude_code_disable_1m_context: None,
2729
}
2830
}
2931

tests/interactive_tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ mod tests {
1717
anthropic_default_sonnet_model: None,
1818
anthropic_default_opus_model: None,
1919
anthropic_default_haiku_model: None,
20+
claude_code_experimental_agent_teams: None,
21+
claude_code_disable_1m_context: None,
2022
}
2123
}
2224

@@ -40,6 +42,8 @@ mod tests {
4042
anthropic_default_sonnet_model: None,
4143
anthropic_default_opus_model: None,
4244
anthropic_default_haiku_model: None,
45+
claude_code_experimental_agent_teams: None,
46+
claude_code_disable_1m_context: None,
4347
}
4448
}
4549

@@ -236,6 +240,8 @@ mod tests {
236240
anthropic_default_sonnet_model: None,
237241
anthropic_default_opus_model: None,
238242
anthropic_default_haiku_model: None,
243+
claude_code_experimental_agent_teams: None,
244+
claude_code_disable_1m_context: None,
239245
};
240246

241247
let env_config = EnvironmentConfig::from_config(&config);

tests/main_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ mod tests {
1818
anthropic_default_sonnet_model: None,
1919
anthropic_default_opus_model: None,
2020
anthropic_default_haiku_model: None,
21+
claude_code_experimental_agent_teams: None,
22+
claude_code_disable_1m_context: None,
2123
}
2224
}
2325

@@ -41,6 +43,8 @@ mod tests {
4143
anthropic_default_sonnet_model: None,
4244
anthropic_default_opus_model: None,
4345
anthropic_default_haiku_model: None,
46+
claude_code_experimental_agent_teams: None,
47+
claude_code_disable_1m_context: None,
4448
}
4549
}
4650

0 commit comments

Comments
 (0)