[Bug] lfm2.5-thinking:1.2b — Tool calls ignored and data hallucinated;
Bug : Inconsistent and broken tool call behavior
lfm2.5-thinking:1.2b exhibits multiple failure modes when tool calling is involved:
1. Wrong query / wrong arguments: The model executes the tool call but passes incorrect arguments — for example using a wrong column name that does not exist in the schema, causing the tool to failure, however complete schema is provided in the system prompt.
2. No response after successful tool call: Sometimes the model calls the tool correctly and receives a valid result, but then stops and returns no response to the user. The tool result is silently dropped.
Expected: Model calls the tool with correct arguments, receives the result, and always completes a full response based on that result.
Actual: Behavior is inconsistent across runs — wrong arguments, silent drops after tool result. There is no reliable pattern and the failures are non-deterministic.
**Attaching the 2. No response after successful tool call screenshot : **
Thanks for rising this issue @Asjad22 .
Could you please share the code, or at least the exact prompts you are using, plus exact model quantization, so I can reproduce this?
ollama model : lfm2.5-thinking:latest quantization: Q4_K_M
Here is a full self-contained reproduction for bug. No database or external services required other than Ollama.
Setup
1. Install Rust
macOS / Linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
Windows: Download and run the installer from https://rustup.rs
Verify:
rustc --version
cargo --version
2. Install Ollama and pull the model
macOS:
brew install ollama
ollama serve
Linux:
curl -fsSL https://ollama.com/install.sh | sh
ollama serve
Windows: Download and install from https://ollama.com/download/windows
Then in a new terminal, pull the model:
ollama pull lfm2.5-thinking:latest
ollama pull qwen3:8b # to test with other model
3. Create the Rust project
cargo new reproduce_bug
cd reproduce_bug
Replace the contents of Cargo.toml with:
[package]
name = "reproduce_bug"
version = "0.1.0"
edition = "2024"
[dependencies]
rig-core = { git = "https://github.com/0xPlaygrounds/rig", branch = "main" }
tokio = { version = "1.49.0", features = ["full"] }
serde = "1.0.228"
serde_json = "1.0.149"
thiserror = "2.0.18"
futures = "0.3.31"
Replace the contents of src/main.rs with the code below, then run:
cargo run
4. src/main.rs
use futures::StreamExt;
use rig::agent::MultiTurnStreamItem;
use rig::client::CompletionClient;
use rig::client::Nothing;
use rig::completion::ToolDefinition;
use rig::providers::ollama;
use rig::streaming::{StreamedAssistantContent, StreamingPrompt};
use rig::tool::Tool;
use serde::Deserialize;
use serde_json::{Map, Value, json};
use std::io::Write;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use thiserror::Error;
// ── Fake tool ─────────────────────────────────────────────────────────────────
#[derive(Debug, Error)]
pub enum FakeDbError {
#[error("Custom error: {0}")]
Custom(String),
}
#[derive(Deserialize)]
pub struct FakeDbArgs {
pub query: String,
}
pub struct FakeDbTool {
// Incremented inside call() so we can detect Call 1 completed
call_count: Arc<AtomicUsize>,
}
impl Tool for FakeDbTool {
const NAME: &'static str = "execute_sql_query";
type Error = FakeDbError;
type Args = FakeDbArgs;
type Output = Vec<Map<String, Value>>;
async fn definition(&self, _prompt: String) -> ToolDefinition {
ToolDefinition {
name: Self::NAME.to_string(),
description: "Executes a SELECT query on the RAN KPI database and returns rows as JSON. Only SELECT queries are allowed.".to_string(),
parameters: json!({
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The SQL SELECT query to execute."
}
},
"required": ["query"]
}),
}
}
async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
self.call_count.fetch_add(1, Ordering::SeqCst);
println!(
"\n [CALL 1 COMPLETE] Tool executed with query:\n {}",
args.query
);
println!(" [EXPECTING CALL 2] Model should now make a second API call...\n");
// Detect wrong column usage
let q = args.query.to_uppercase();
if q.contains("CELL_AVAIL") && !q.contains("DL_USER_THP") {
println!(
" [BUG 1 - WRONG COLUMN] Used cell_avail instead of dl_user_thp for throughput query."
);
}
if q.contains("CELL_NAME") && !q.contains("LNCEL_NAME") {
println!(
" [BUG 1 - WRONG COLUMN] Used cell_name which does not exist. Should be lncel_name."
);
}
if !args.query.trim_start().to_uppercase().starts_with("SELECT") {
return Err(FakeDbError::Custom(
"Only SELECT queries are allowed".to_string(),
));
}
// Return 25 realistic RAN rows
let cell_names = vec![
("ENODEB_001_ALPHA_C1", 2.31),
("ENODEB_002_BETA_C2", 3.45),
("ENODEB_003_GAMMA_C3", 1.87),
("ENODEB_004_DELTA_C1", 4.12),
("ENODEB_005_EPSILON_C2", 2.98),
("ENODEB_006_ZETA_C3", 5.34),
("ENODEB_007_ETA_C1", 1.23),
("ENODEB_008_THETA_C2", 3.67),
("ENODEB_009_IOTA_C3", 2.54),
("ENODEB_010_KAPPA_C1", 4.89),
("ENODEB_011_LAMBDA_C2", 1.45),
("ENODEB_012_MU_C3", 3.21),
("ENODEB_013_NU_C1", 2.76),
("ENODEB_014_XI_C2", 4.43),
("ENODEB_015_OMICRON_C3", 1.98),
("ENODEB_016_PI_C1", 3.87),
("ENODEB_017_RHO_C2", 2.13),
("ENODEB_018_SIGMA_C3", 4.56),
("ENODEB_019_TAU_C1", 1.67),
("ENODEB_020_UPSILON_C2", 3.34),
("ENODEB_021_PHI_C3", 2.89),
("ENODEB_022_CHI_C1", 4.21),
("ENODEB_023_PSI_C2", 1.54),
("ENODEB_024_OMEGA_C3", 3.98),
("ENODEB_025_ALPHA2_C1", 2.67),
];
let rows: Vec<Map<String, Value>> = cell_names
.iter()
.map(|(name, val)| {
let mut m = Map::new();
m.insert("lncel_name".into(), json!(name));
m.insert("avg_dl_thp_mbps".into(), json!(val));
m
})
.collect();
Ok(rows)
}
}
// ── Main ──────────────────────────────────────────────────────────────────────
#[tokio::main]
async fn main() {
let client: ollama::Client = ollama::Client::new(Nothing).unwrap();
let system_prompt = "You are a database assistant. You have a tool called execute_sql_query. You MUST call it.\n\nSTEP 1: Call execute_sql_query with a SELECT query.\nSTEP 2: Wait for the real data to come back.\nSTEP 3: Write a markdown table from the real data.\nSTEP 4: Write a short analysis.\n\nDo NOT skip Step 1. Do NOT write a table before calling the tool. Do NOT fabricate data.\nYou CAN call the tool. The tool is available. Call it now when the user asks a question.\n\nTABLE: ran_kpi_hourly_clean\n\nCOLUMNS:\n- lncel_name (text): cell name. Use for GROUP BY cell. NEVER use cell_name.\n- lnbts_name (text): site name. Use for GROUP BY site.\n- dl_user_thp (numeric): DL throughput Mbps. Use for ALL throughput queries.\n- ul_user_thp (numeric): UL throughput Mbps.\n- cell_avail (numeric): availability %. NOT throughput.\n- dl_prb_util (numeric): DL PRB utilization %.\n- ul_prb_util (numeric): UL PRB utilization %.\n- ods_ps_setup_success_rate (numeric): setup success rate %.\n- erab_drop_rate (numeric): drop rate %. Lower is better.\n- erab_esr (numeric): ERAB success rate %.\n- avg_users (numeric): average connected users.\n- ps_traffic (numeric): traffic volume GB.\n- period_start_time (timestamp): measurement hour.\n\nCOLUMN MAPPING:\n- DL throughput / downlink speed -> dl_user_thp\n- UL throughput / uplink speed -> ul_user_thp\n- availability / uptime -> cell_avail\n- drop rate -> erab_drop_rate\n- setup success rate -> ods_ps_setup_success_rate\n- users / load -> avg_users\n- group by cell -> lncel_name\n- group by site -> lnbts_name\n\nSQL RULES:\n- Only SELECT. Always end with LIMIT 25.\n- Always WHERE column IS NOT NULL when averaging.\n- Always GROUP BY lncel_name when grouping by cell.\n\nEXAMPLE:\nUser: lowest DL throughput cells\nYou call: execute_sql_query with query: SELECT lncel_name, AVG(dl_user_thp) AS avg_dl_thp_mbps FROM ran_kpi_hourly_clean WHERE dl_user_thp IS NOT NULL GROUP BY lncel_name ORDER BY avg_dl_thp_mbps ASC LIMIT 25";
let queries = vec!["Which cells have the lowest average DL throughput?"];
let mut total_call1 = 0usize;
let mut total_call2 = 0usize;
for (i, user_query) in queries.iter().enumerate() {
println!("═══════════════════════════════════════════════════");
println!("Query #{}: {}", i + 1, user_query);
println!("Expected: 2 Ollama API calls (Call 1: tool, Call 2: response)");
println!("═══════════════════════════════════════════════════\n");
// Fresh counter per query
let call_counter = Arc::new(AtomicUsize::new(0));
let agent = client
.agent("lfm2.5-thinking:latest")
// .agent("qwen3:8b") // uncoment to use this for testing actual behavior.
.preamble(system_prompt)
.tool(FakeDbTool {
call_count: Arc::clone(&call_counter),
})
.build();
let mut stream = agent.stream_prompt(user_query.to_string()).await;
let mut pre_tool_text = String::new();
let mut post_tool_text = String::new();
let mut thinking_fired = false;
while let Some(item) = stream.next().await {
match item {
Ok(MultiTurnStreamItem::StreamAssistantItem(content)) => match content {
StreamedAssistantContent::Reasoning(r) => {
thinking_fired = true;
println!(
"[BUG 2] <think> block present despite think:false:\n{:?}",
r.reasoning
);
}
StreamedAssistantContent::ReasoningDelta { reasoning, .. } => {
thinking_fired = true;
print!("[THINKING] {}", reasoning);
std::io::stdout().flush().unwrap();
}
StreamedAssistantContent::Text(txt) => {
print!("{}", txt.text);
std::io::stdout().flush().unwrap();
if call_counter.load(Ordering::SeqCst) > 0 {
post_tool_text.push_str(&txt.text);
} else {
pre_tool_text.push_str(&txt.text);
}
}
StreamedAssistantContent::Final(_) => break,
_ => {}
},
Err(e) => {
eprintln!("\n[STREAM ERROR] {}", e);
break;
}
_ => {}
}
}
println!("\n");
let tool_called = call_counter.load(Ordering::SeqCst) > 0;
let has_response = !post_tool_text.trim().is_empty();
if !pre_tool_text.trim().is_empty() {
println!(
" [NOTE] Model generated {} chars BEFORE tool call.",
pre_tool_text.len()
);
}
println!("── Results for Query #{} ──", i + 1);
if tool_called {
total_call1 += 1;
}
if tool_called && has_response {
total_call2 += 1;
println!(
"[OK] Call 1 ✓ Call 2 ✓ Post-tool response: {} chars",
post_tool_text.len()
);
} else if tool_called && !has_response {
println!("[BUG 1 ✗] Call 1 ✓ Call 2 MISSING — model silent after tool result.");
} else {
println!("[BUG 1 ✗] Call 1 MISSING — tool was never called.");
}
if thinking_fired {
println!("[BUG 2 ✗] Thinking output present despite think:false.");
}
println!();
// Summary
println!("═══════════════════════════════════════════════════");
println!("SUMMARY");
println!("═══════════════════════════════════════════════════");
println!(
"Call 1 (tool) : expected {} got {}",
queries.len(),
total_call1
);
println!(
"Call 2 (response): expected {} got {}",
queries.len(),
total_call2
);
if total_call2 < queries.len() {
println!(
"\n[BUG 1 CONFIRMED] {} of {} queries had no response after tool execution.",
queries.len() - total_call2,
queries.len()
);
}
}
}
Expected output (working model)
Query #1: Which cells have the lowest average DL throughput?
Expected: 2 Ollama API calls (Call 1: tool, Call 2: response)
[CALL 1 COMPLETE] Tool executed with query: SELECT ...
[EXPECTING CALL 2] ...
| lncel_name | avg_dl_thp_mbps |
|---------------------|-----------------|
| ENODEB_007_ETA_C1 | 1.23 |
...
── Results for Query #1 ──
[OK] Call 1 ✓ Call 2 ✓ Post-tool response: XXXX chars
═══════════════════════════════════════════════════
SUMMARY
═══════════════════════════════════════════════════
Total queries : 1
Call 1 (tool) : expected 1 got 1
Call 2 (response): expected 1 got 1
Actual output
Query #1: Which cells have the lowest average DL throughput?
[NOTE] Model generated XXXX chars BEFORE tool call (hallucination).
[CALL 1 COMPLETE] Tool executed with query: SELECT ...
[EXPECTING CALL 2] ...
── Results for Query #1 ──
[BUG 1 ✗] Call 1 ✓ Call 2 MISSING — model silent after tool result.
SUMMARY
Call 1 (tool) : expected 1 got 1
Call 2 (response): expected 1 got 0
[BUG 1 CONFIRMED] 1 of 1 queries had no response after tool execution.
I've been trying to use it as a backend in OpenCode and it's almost impossible to make it even attempt to run a tool.
This is the only prompt that actually makes it run a tool successfully: https://github.com/ollama/ollama/issues/14742#issuecomment-4025421161
OpenCode supplies these tools by default: https://opencode.ai/docs/tools/