refactor: improve code readability and consistency across multiple files
This commit is contained in:
@@ -788,7 +788,7 @@ pub fn count_tokens(text: &str) -> usize {
|
||||
return bpe.encode_with_special_tokens(text).len();
|
||||
}
|
||||
// Fallback: ~4 chars per token
|
||||
(text.len() + 3) / 4
|
||||
text.len().div_ceil(4)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! Flow: push user message → spawn OS thread → loop: call blocking LLM
|
||||
//! client → execute tool calls → push TurnEvents → repeat until done.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::collections::VecDeque;
|
||||
@@ -53,7 +53,7 @@ pub fn spawn_agent_turn(state: &mut AppStateRest, text: String) {
|
||||
/// The core agent turn — LLM call → tool execution → repeat.
|
||||
fn run_turn(
|
||||
messages: &mut Vec<ChatMessage>,
|
||||
session_dir: &PathBuf,
|
||||
session_dir: &Path,
|
||||
workspace_roots: &[PathBuf],
|
||||
turn_events: &Arc<Mutex<VecDeque<TurnEvent>>>,
|
||||
in_flight: &Arc<Mutex<bool>>,
|
||||
@@ -89,7 +89,7 @@ fn run_turn(
|
||||
messages.insert(0, sys_msg);
|
||||
|
||||
let tool_ctx = ToolCtx::builder()
|
||||
.session_dir(session_dir.clone())
|
||||
.session_dir(session_dir.to_path_buf())
|
||||
.workspaces(workspace_roots.to_vec())
|
||||
.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user