Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/crates/core/src/agentic/agents/prompts/agentic_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ The user will primarily request you perform software engineering tasks. This inc
- For security-sensitive tasks, support defensive analysis and remediation only. Refuse malicious code, exploit workflows, credential harvesting, or instructions that would facilitate abuse.
- Edit reliability discipline:
- Read a file in this session before Edit. Partial range reads are allowed, but the Read range must include every line you will copy into `old_string`.
- Base `old_string` on the latest Read result for that file (or exact content from a successful prior Edit/Write on the same file).
- Base `old_string` on the latest Read result for that file; after Write, use the post-write Read result returned by the system.
- Read output uses cat -n format: spaces, line number, tab, then file content. Copy only the text after the tab into `old_string` and `new_string`.
- Do not reformat HTML/CSS/JS when constructing Edit strings; match indentation and blank lines exactly.
- Treat Read output as stale after a successful edit to the same file; re-read before the next Edit unless you are continuing from the updated content in the prior tool result.
- Treat Read output as stale after a successful edit to the same file; re-read before the next Edit unless you are continuing from the exact text returned by that Edit or by the post-write Read result.
- Use Write only to create a new file or intentionally replace a whole file in one step. After Write succeeds for a path, do not call Write again for that path to continue, refine, or patch it; use Edit against the latest Read content.
- Use 2-4 adjacent lines with stable surrounding context when that is enough to make `old_string` unique.
- Use `replace_all` only when every occurrence should change.
- If Edit fails because text was not found or matched multiple locations, Read the target lines again and retry with freshly copied text — do not adjust the failed string from memory.
Expand Down
31 changes: 5 additions & 26 deletions src/crates/core/src/agentic/execution/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,6 @@ impl ExecutionEngine {
.unwrap_or_else(|| "auto".to_string())
}

fn should_use_fast_auto_model(turn_index: usize, original_user_input: &str) -> bool {
turn_index == 0 && original_user_input.chars().count() <= 10
}

fn collect_unlocked_collapsed_tools(
messages: &[Message],
collapsed_tools: &[String],
Expand Down Expand Up @@ -822,9 +818,11 @@ impl ExecutionEngine {
let resolved_configured_model_id =
Self::resolve_configured_model_id(&ai_config, &configured_model_id);

let model_id = if configured_model_id == "auto" || resolved_configured_model_id == "auto" {
let use_fast_model = Self::should_use_fast_auto_model(turn_index, original_user_input);
let fallback_model = if use_fast_model { "fast" } else { "primary" };
let model_id = if configured_model_id == "auto"
|| configured_model_id == "default"
|| resolved_configured_model_id == "auto"
{
let fallback_model = "primary";
let resolved_model_id = ai_config.resolve_model_selection(fallback_model);

if let Some(resolved_model_id) = resolved_model_id {
Expand Down Expand Up @@ -3169,25 +3167,6 @@ mod tests {
}
}

#[test]
fn auto_model_uses_fast_for_short_first_message() {
assert!(ExecutionEngine::should_use_fast_auto_model(0, "你好"));
assert!(ExecutionEngine::should_use_fast_auto_model(0, "1234567890"));
}

#[test]
fn auto_model_uses_primary_for_long_first_message() {
assert!(!ExecutionEngine::should_use_fast_auto_model(
0,
"12345678901"
));
}

#[test]
fn auto_model_uses_primary_after_first_turn() {
assert!(!ExecutionEngine::should_use_fast_auto_model(1, "短消息"));
}

#[test]
fn resolve_configured_fast_model_falls_back_to_primary_when_fast_is_stale() {
let mut ai_config = AIConfig::default();
Expand Down
Loading
Loading