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: 0 additions & 5 deletions BitFun-Installer/src-tauri/src/connection_test/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2097,7 +2097,6 @@ mod tests {
temperature: None,
top_p: None,
enable_thinking_process: false,
support_preserved_thinking: false,
inline_think_in_text: false,
custom_headers: None,
custom_headers_mode: None,
Expand All @@ -2121,7 +2120,6 @@ mod tests {
temperature: None,
top_p: None,
enable_thinking_process: false,
support_preserved_thinking: false,
inline_think_in_text: false,
custom_headers: None,
custom_headers_mode: None,
Expand Down Expand Up @@ -2150,7 +2148,6 @@ mod tests {
temperature: None,
top_p: None,
enable_thinking_process: false,
support_preserved_thinking: false,
inline_think_in_text: false,
custom_headers: None,
custom_headers_mode: None,
Expand Down Expand Up @@ -2180,7 +2177,6 @@ mod tests {
temperature: Some(0.2),
top_p: Some(0.8),
enable_thinking_process: true,
support_preserved_thinking: true,
inline_think_in_text: false,
custom_headers: None,
custom_headers_mode: None,
Expand Down Expand Up @@ -2259,7 +2255,6 @@ mod tests {
temperature: None,
top_p: None,
enable_thinking_process: false,
support_preserved_thinking: true,
inline_think_in_text: false,
custom_headers: None,
custom_headers_mode: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ pub struct AIConfig {
pub temperature: Option<f64>,
pub top_p: Option<f64>,
pub enable_thinking_process: bool,
pub support_preserved_thinking: bool,
pub inline_think_in_text: bool,
pub custom_headers: Option<std::collections::HashMap<String, String>>,
/// "replace" (default) or "merge" (defaults first, then custom)
Expand Down
1 change: 0 additions & 1 deletion BitFun-Installer/src-tauri/src/installer/ai_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub fn ai_config_from_installer_model(m: &ModelConfig) -> Result<AIConfig, Strin
temperature: None,
top_p: None,
enable_thinking_process: false,
support_preserved_thinking: false,
inline_think_in_text: false,
custom_headers: m.custom_headers.clone(),
custom_headers_mode: m.custom_headers_mode.clone(),
Expand Down
1 change: 0 additions & 1 deletion BitFun-Installer/src-tauri/src/installer/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,6 @@ fn apply_first_launch_model(model: &ModelConfig) -> Result<(), String> {
model_map.insert("recommended_for".to_string(), Value::Array(Vec::new()));
model_map.insert("metadata".to_string(), Value::Null);
model_map.insert("enable_thinking_process".to_string(), Value::Bool(false));
model_map.insert("support_preserved_thinking".to_string(), Value::Bool(false));
model_map.insert("inline_think_in_text".to_string(), Value::Bool(false));

if let Some(skip_ssl_verify) = model.skip_ssl_verify {
Expand Down
15 changes: 9 additions & 6 deletions src/crates/core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ fn embed_announcement_content() -> Result<(), Box<dyn std::error::Error>> {
.join("announcement")
.join("content");

println!(
"cargo:rerun-if-changed={}",
content_root.display()
);
println!("cargo:rerun-if-changed={}", content_root.display());
emit_rerun_if_changed(&content_root);

let mut entries: HashMap<String, String> = HashMap::new();
Expand Down Expand Up @@ -282,7 +279,10 @@ fn embed_announcement_content() -> Result<(), Box<dyn std::error::Error>> {
.to_string_lossy()
.to_string();
// Strip leading numeric prefix (e.g. "001_") to use bare id as key.
let key_stem = if stem.len() > 4 && stem.chars().take(3).all(|c| c.is_ascii_digit()) && stem.chars().nth(3) == Some('_') {
let key_stem = if stem.len() > 4
&& stem.chars().take(3).all(|c| c.is_ascii_digit())
&& stem.chars().nth(3) == Some('_')
{
stem[4..].to_string()
} else {
stem
Expand All @@ -308,7 +308,10 @@ fn generate_embedded_announcements_code(
let dest_path = Path::new(&out_dir).join("embedded_announcements.rs");
let mut file = fs::File::create(&dest_path)?;

writeln!(file, "// Embedded announcement content (auto-generated by build.rs)")?;
writeln!(
file,
"// Embedded announcement content (auto-generated by build.rs)"
)?;
writeln!(file, "// Do not edit manually.")?;
writeln!(file)?;
writeln!(file, "use std::collections::HashMap;")?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::service::ai_memory::AIMemoryManager;
use crate::service::ai_rules::get_global_ai_rules_service;
use crate::service::bootstrap::build_workspace_persona_prompt;
use crate::service::config::get_app_language_code;
use crate::service::filesystem::get_formatted_directory_listing;
use crate::service::config::global::GlobalConfigManager;
use crate::service::filesystem::get_formatted_directory_listing;
use crate::service::project_context::ProjectContextService;
use crate::util::errors::{BitFunError, BitFunResult};
use log::{debug, warn};
Expand Down
25 changes: 10 additions & 15 deletions src/crates/core/src/agentic/coordination/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,22 +988,17 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet
let session_max_tokens = session.config.max_context_tokens;

// Unify context_window: min(model capability, session config)
let model_context_window = match crate::infrastructure::ai::get_global_ai_client_factory()
.await
{
Ok(factory) => {
let model_id = session
.config
.model_id
.as_deref()
.unwrap_or("default");
match factory.get_client_resolved(model_id).await {
Ok(client) => Some(client.config.context_window as usize),
Err(_) => None,
let model_context_window =
match crate::infrastructure::ai::get_global_ai_client_factory().await {
Ok(factory) => {
let model_id = session.config.model_id.as_deref().unwrap_or("default");
match factory.get_client_resolved(model_id).await {
Ok(client) => Some(client.config.context_window as usize),
Err(_) => None,
}
}
}
Err(_) => None,
};
Err(_) => None,
};
let context_window = match model_context_window {
Some(mcw) => mcw.min(session_max_tokens),
None => session_max_tokens,
Expand Down
19 changes: 7 additions & 12 deletions src/crates/core/src/agentic/core/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ pub struct MessageMetadata {
pub turn_id: Option<String>,
pub round_id: Option<String>,
pub tokens: Option<usize>,
#[serde(skip)] // Not serialized, auxiliary field for runtime use only
pub keep_thinking: bool,
/// Anthropic extended thinking signature (for passing back in multi-turn conversations)
#[serde(skip_serializing_if = "Option::is_none")]
pub thinking_signature: Option<String>,
Expand Down Expand Up @@ -168,7 +166,6 @@ impl From<Message> for AIMessage {
MessageRole::Tool => "tool",
MessageRole::System => "system",
};
let keep_thinking = msg.metadata.keep_thinking;
let thinking_signature = msg.metadata.thinking_signature.clone();

match msg.content {
Expand Down Expand Up @@ -273,16 +270,10 @@ impl From<Message> for AIMessage {
};

// Reasoning content (interleaved thinking mode)
let reasoning = if keep_thinking {
reasoning_content.filter(|r| !r.is_empty())
} else {
None
};

Self {
role: "assistant".to_string(),
content,
reasoning_content: reasoning,
reasoning_content: reasoning_content.filter(|r| !r.is_empty()),
thinking_signature: thinking_signature.clone(),
tool_calls: converted_tool_calls,
tool_call_id: None,
Expand Down Expand Up @@ -506,7 +497,7 @@ impl Message {
50 + tiles * 200
}

pub fn estimate_tokens(&self) -> usize {
pub fn estimate_tokens_with_reasoning(&self, include_reasoning: bool) -> usize {
let mut total = 0usize;
total += 4;

Expand All @@ -525,7 +516,7 @@ impl Message {
text,
tool_calls,
} => {
if self.metadata.keep_thinking {
if include_reasoning {
if let Some(reasoning) = reasoning_content.as_ref() {
total += TokenCounter::estimate_tokens(reasoning);
}
Expand Down Expand Up @@ -564,6 +555,10 @@ impl Message {

total
}

fn estimate_tokens(&self) -> usize {
self.estimate_tokens_with_reasoning(true)
}
}

impl Display for MessageContent {
Expand Down
Loading
Loading