惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
O
OpenAI News
V
V2EX
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
S
Schneier on Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
L
LINUX DO - 热门话题
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - Franky
Security Latest
Security Latest
S
SegmentFault 最新的问题
Project Zero
Project Zero
Spread Privacy
Spread Privacy
K
Kaspersky official blog
J
Java Code Geeks
V
Vulnerabilities – Threatpost
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
月光博客
月光博客
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
Scott Helme
Scott Helme
WordPress大学
WordPress大学
量子位
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Simon Willison's Weblog
Simon Willison's Weblog
S
Secure Thoughts
博客园 - 【当耐特】
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Visual Studio Blog
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
腾讯CDC
Cyberwarzone
Cyberwarzone
IT之家
IT之家
GbyAI
GbyAI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
云风的 BLOG
云风的 BLOG
T
Troy Hunt's Blog
D
Docker

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I Used Gemma 4 as a Private Log Analyst for App Crashes
Nitin Kalra · 2026-05-24 · via DEV Community

This is a submission for the Gemma 4 Challenge: Write About Gemma 4

Cover image showing a local Gemma 4 log analyst reading crash logs and surfacing findings

Most AI debugging workflows are still on demand.

A year ago, that usually meant copying a stack trace, pasting it into a large model, and asking what went wrong.

Now the workflow is better. I can ask Codex, Claude Code, or another coding agent to inspect the repo, read the relevant files, explain the failure, and even make the fix.

But the first step is still mostly the same:

Something breaks. I notice the stack trace, Gradle error, crash line, or suspicious log message. Then I bring that evidence to the agent and ask it to start from there.

That works, but it is still reactive.

The problem is that this is not how crashes actually happen during development.

Crashes happen while the app is running.

Gradle failures happen while I am switching branches.

Warnings pile up before the actual failure.

Sometimes the real issue is not the red stack trace. It is a swallowed exception inside a try/catch block, a suspicious warning 200 lines earlier, or a lifecycle message that only makes sense when you look at the surrounding code.

So I built around a different idea:

Gemma 4 runs locally on my dev laptop as a continuous log analyst.

Not a replacement for a large model.

Not a chatbot I manually open after everything breaks.

Just a small local model watching logs, clustering noise, catching suspicious patterns, and telling me when something deserves attention.

Why Local Matters For Logs

Logs are messy, repetitive, and often private.

Android logs can contain package names, API paths, device details, feature flags, user identifiers, request IDs, internal class names, and business logic clues. Gradle output can expose project structure, dependency names, local file paths, signing configuration mistakes, and CI environment details.

That makes logs a strange fit for always-on cloud analysis.

For one-off debugging, I am comfortable invoking a stronger hosted model when I choose to. But I do not want every log line from my development machine streamed to a remote API just in case something interesting happens.

This is where Gemma 4 becomes useful in a very specific way:

  • It can run locally.
  • It can be cheap enough to call repeatedly.
  • It can inspect noisy text without needing a perfect prompt every time.
  • It can sit near the developer loop instead of behind a manual copy/paste step.

That changes the product shape.

A large cloud model is a consultant.

A local Gemma 4 process can be a background reviewer.

Running Gemma 4 Locally With Ollama

For this workflow I used Ollama:

ollama run gemma4:26b

I chose the 26B Mixture-of-Experts model because my laptop has enough headroom for it, and this task benefits from more than tiny-model pattern matching.

The smaller Gemma 4 models are attractive for phones, Raspberry Pi projects, and very low-friction local apps. But a log analyst is doing a slightly different job. It needs to read noisy context, connect earlier warnings to later crashes, decide whether to use tools, and produce structured findings without constantly interrupting me.

That is why I picked the MoE option: the challenge describes it as a highly efficient 26B model designed for high-throughput, advanced reasoning. On my machine, Ollama reports it as gemma4:26b, a 25.8B Q4_K_M local model, about 18GB on disk.

The watcher does not call ollama run directly each time. I keep the model warm, then call Ollama's local HTTP API:

const response = await fetch("http://127.0.0.1:11434/api/chat", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    model: "gemma4:26b",
    stream: false,
    messages,
    tools,
    options: {
      temperature: 0.1
    }
  })
});

That keeps the setup simple: local model, local logs, local code, local findings.

What I Built

I built a small local workflow around three inputs:

  1. adb logcat output from an Android app
  2. Gradle build failures
  3. Nearby source files when the log points to a class or line number

The goal was not to make Gemma 4 fix code automatically. The goal was narrower:

Read the logs continuously, ignore obvious noise, identify likely root causes, ask for missing context when needed, and suggest the next debugging step.

The loop looks like this:

adb logcat / Gradle output
        |
        v
small rolling buffer
        |
        v
noise filter + event grouping
        |
        v
Gemma 4 local analysis
        |
        v
structured issue summary
        |--------------------|
        v                    v
bell notification      localhost:3001 viewer
        |
        v
optional source lookup through tools

The important part is the rolling buffer. Instead of sending one isolated stack trace, the local watcher can keep the last few hundred or thousand lines around the failure.

That matters because the most useful clue is often before the crash.

Diagram showing the local Gemma 4 debugging loop from logs to bell notification, localhost viewer, and read-file tools

Making The Background Process Noticeable

One problem with a background log analyst is obvious:

If it is running in a separate terminal, how do I notice it found something?

I did not want another terminal tab that quietly fills with text while I am focused on code. So I added two small tools around the model.

The first one is intentionally simple: ring a bell.

When Gemma 4 classifies something as a real finding instead of noise, the watcher can play a short bell sound. Not for every warning. Not for every repeated stack trace. Only when the model thinks the event crosses a threshold:

  • a new crash signature
  • a Gradle failure with a clear source location
  • a swallowed exception that later becomes a visible failure
  • repeated warnings that are likely connected
  • a missing file, permission, or dependency that blocks the app

The implementation can be as small as this:

async function ring_bell({ reason }) {
  process.stdout.write("\u0007");

  if (process.env.GEMMA_BELL_CMD) {
    const [cmd, ...args] = process.env.GEMMA_BELL_CMD.split(" ");
    execFile(cmd, args, () => {});
  }

  await appendFile("bell-events.log", `${new Date().toISOString()} ${reason}\n`);
  return { alerted: true, reason };
}

The second tool is a tiny local viewer.

I run it on localhost:3001 and open it in Chrome. It shows recent Gemma 4 findings as a small debugging inbox:

Screenshot of the local Gemma 4 log viewer running in Chrome with sample crash findings

  • latest issue summary
  • severity
  • first seen / last seen time
  • related log lines
  • suspected root cause
  • suggested files to inspect
  • next debugging step
  • whether the bell already fired for that issue

That made the workflow much more practical. Gemma 4 can run in the background, but I do not have to keep staring at its terminal output. The bell tells me something needs attention. The browser view gives me the short version when I am ready to look.

Giving Gemma 4 Small Tools

Logs are useful, but they often point to code.

So I gave the local analyzer a small tool surface:

const tools = [
  {
    type: "function",
    function: {
      name: "read_file",
      description: "Read a local source file by path or basename.",
      parameters: {
        type: "object",
        properties: {
          path: { type: "string" },
          startLine: { type: "number" },
          endLine: { type: "number" }
        },
        required: ["path"]
      }
    }
  },
  {
    type: "function",
    function: {
      name: "ring_bell",
      description: "Notify me when a high-confidence finding needs attention.",
      parameters: {
        type: "object",
        properties: {
          reason: { type: "string" }
        },
        required: ["reason"]
      }
    }
  },
  {
    type: "function",
    function: {
      name: "save_finding",
      description: "Save a structured finding for the localhost viewer.",
      parameters: {
        type: "object",
        properties: {
          finding: { type: "object" }
        },
        required: ["finding"]
      }
    }
  }
];

The most important one is read_file.

When a stack trace includes HomeAdapter.kt:88, Gemma 4 can ask for that file instead of guessing what the adapter does. When a Gradle error points to CheckoutViewModel.kt:44, it can read the surrounding code and give a more grounded suggestion.

I kept the tools deliberately boring.

No automatic edits.

No deleting files.

No running random commands.

Just enough local context to move from "this log looks bad" to "read this file and check this assumption."

Example 1: The Stack Trace Was Obvious

The easy case is a normal crash:

FATAL EXCEPTION: main
Process: com.example.notes, PID: 18342
java.lang.IllegalStateException: Fragment NotesFragment not attached to a context.
    at androidx.fragment.app.Fragment.requireContext(Fragment.java:967)
    at com.example.notes.NotesFragment.showEmptyState(NotesFragment.kt:118)
    at com.example.notes.NotesFragment$loadNotes$1.invokeSuspend(NotesFragment.kt:92)

Gemma 4 did not need to be brilliant here. The root cause is already in the stack trace.

The useful output was the structure:

{
  "severity": "crash",
  "likely_root_cause": "NotesFragment calls requireContext() after the fragment is detached.",
  "noisy_lines": ["process restart messages", "unrelated Choreographer skipped-frame warning"],
  "next_step": "Check whether loadNotes() completes after onDestroyView() or after navigation away from the fragment.",
  "code_to_read": [
    "NotesFragment.loadNotes",
    "NotesFragment.showEmptyState",
    "Fragment lifecycle around onDestroyView"
  ]
}

That is already more useful than a raw stack trace sitting in a terminal.

It converts the crash into a short debugging task.

Example 2: The Real Problem Was Hidden Above The Crash

The more interesting case was a noisy sequence like this:

W/ConfigRepository: Failed to parse remote config, using defaults
org.json.JSONException: No value for max_items
    at org.json.JSONObject.get(JSONObject.java:398)
    at com.example.app.ConfigRepository.parse(ConfigRepository.kt:61)
    at com.example.app.ConfigRepository.refresh(ConfigRepository.kt:42)

W/HomeViewModel: Config refresh failed, continuing with cached config

E/RecyclerView: No adapter attached; skipping layout

FATAL EXCEPTION: main
java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 0
    at com.example.app.HomeAdapter.onBindViewHolder(HomeAdapter.kt:88)

If I only pasted the fatal exception into a model, the answer would probably focus on HomeAdapter.

But the rolling log window shows a better story:

  1. Config parsing failed.
  2. The app swallowed the exception and continued.
  3. The fallback state was empty or malformed.
  4. The adapter crashed later.

That is exactly the kind of issue that a continuous local analyst is better positioned to catch.

Gemma 4's summary was more useful when I asked it to separate trigger, root cause, and visible crash:

{
  "visible_crash": "IndexOutOfBoundsException in HomeAdapter.onBindViewHolder",
  "probable_trigger": "Remote config parsing failed because max_items was missing.",
  "root_cause_hypothesis": "The app continues after ConfigRepository.refresh() fails, but downstream UI code assumes the config produced a non-empty item list.",
  "risk": "The try/catch hides the real failure and converts it into a later UI crash.",
  "suggested_fix": [
    "Return a typed error or safe default from ConfigRepository instead of swallowing the exception.",
    "Make HomeViewModel expose an error/empty state when config parsing fails.",
    "Guard HomeAdapter binding against mismatched item counts."
  ]
}

This is the moment where the local model became more interesting than a manual prompt.

It was not just answering a question.

It was watching enough context to notice that the question I would have asked was incomplete.

Letting It Read Nearby Code

Logs alone are useful, but logs plus a small amount of local source context are much better.

When the analyzer saw ConfigRepository.kt:61, the next step was to read that file locally and include the surrounding function:

class ConfigRepository {
    fun refresh(rawJson: String): AppConfig {
        return try {
            parse(rawJson)
        } catch (e: Exception) {
            Log.w("ConfigRepository", "Config refresh failed, continuing with cached config", e)
            AppConfig.empty()
        }
    }

    private fun parse(rawJson: String): AppConfig {
        val json = JSONObject(rawJson)
        return AppConfig(
            maxItems = json.getInt("max_items"),
            title = json.getString("title")
        )
    }
}

This is where the suggestion became more like code review than log parsing.

Gemma 4 pointed out that AppConfig.empty() was not a neutral fallback. It changed the state shape in a way the UI did not expect. The crash happened later, but the bug was born here.

The suggested improvement was not "catch fewer exceptions" in the abstract. It was more specific:

sealed interface ConfigRefreshResult {
    data class Success(val config: AppConfig) : ConfigRefreshResult
    data class Failed(val reason: String, val fallback: AppConfig?) : ConfigRefreshResult
}

Then the UI layer can make an explicit decision:

  • show cached config if it exists
  • show an empty state if there are no items
  • show an error state if the config is invalid
  • avoid binding an adapter with impossible assumptions

That is the workflow I care about:

  1. notice the crash
  2. find the earlier suspicious log
  3. read the nearby source
  4. suggest a safer boundary

That is more useful than "here is what IndexOutOfBoundsException means."

Example 3: Gradle Failures Are Mostly Triage

Gradle output is a different kind of problem. It is usually long, repetitive, and full of noise.

For example:

Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

e: file:///Users/me/project/app/src/main/java/com/example/CheckoutViewModel.kt:44:21
Type mismatch: inferred type is String? but String was expected

The useful job for Gemma 4 is not to explain Kotlin nullability from scratch.

The useful job is to reduce the build output to:

Primary failure:
- CheckoutViewModel.kt:44 passes a nullable String into a non-null parameter.

Likely fix:
- Check whether user.email can be null.
- Either validate before calling submitOrder(), provide a fallback, or change the called function to accept String? if null is valid.

Ignore:
- Gradle worker wrapper stack
- Generic "Compilation error" line
- Repeated task execution noise

This is a small thing, but small things matter when they happen 30 times a day.

The Ring Buffer

The watcher does not send my entire terminal history to the model.

It keeps a rolling window:

class RingBuffer {
  constructor(maxLines = 500) {
    this.maxLines = maxLines;
    this.lines = [];
  }

  push(text) {
    for (const line of String(text).split(/\r?\n/)) {
      if (line.trim()) this.lines.push(line);
    }
    if (this.lines.length > this.maxLines) {
      this.lines = this.lines.slice(this.lines.length - this.maxLines);
    }
  }

  snapshot() {
    return this.lines.join("\n");
  }
}

That sounds basic, but it is the key difference from manual copy/paste. The model sees what happened around the crash, not only the final red line.

Why I Would Not Use A Large Model For This First

Large models are better at deep reasoning. I still use them when the failure crosses multiple modules, touches architecture, or needs a careful patch.

But continuous log analysis has different constraints.

It needs to be:

  • cheap
  • private
  • low-friction
  • always available
  • good at summarizing repetitive noise
  • able to run before I know there is a problem

That is the important distinction.

For deep debugging, I use the strongest model I can get.

For continuous debugging, I keep the model close to the logs.

Gemma 4 on a developer laptop fits that second role.

The Prompt Shape That Worked Best

The most reliable prompt was not conversational. It was closer to a small incident-report contract:

You are a local crash-log analyst.

Analyze the log window below.

Return JSON with:
- severity: "ignore" | "warning" | "crash" | "build_failure"
- primary_signal: the line or event that matters most
- likely_root_cause: concise hypothesis
- noisy_lines: log patterns that are probably irrelevant
- missing_context: files, commands, or runtime state needed to confirm
- next_steps: 1 to 3 concrete debugging steps
- source_files_to_read: likely files/classes/functions

Rules:
- Do not invent files.
- If the log is insufficient, say what is missing.
- Separate the visible crash from earlier suspicious events.
- Treat swallowed exceptions as suspicious.
- Prefer practical debugging steps over generic explanations.
- Use read_file only when a log points to a concrete local file.
- Ring the bell only for new or high-confidence findings.

That last rule mattered:

Treat swallowed exceptions as suspicious.

Without that, the model often focused too much on the final crash. With it, the model started paying attention to warning/error logs that appeared earlier but did not crash the app immediately.

The actual loop is a normal tool-calling loop: call Ollama, execute any tool calls, send the tool results back, and stop when the model returns a final JSON finding.

const messages = [
  { role: "system", content: SYSTEM_PROMPT },
  { role: "user", content: buildUserPrompt({ buffer: ringBuffer.snapshot() }) }
];

for (let round = 0; round < 5; round += 1) {
  const response = await ollama.chat({ messages, tools });
  const message = response.message;
  messages.push(message);

  if (!message.tool_calls?.length) {
    return JSON.parse(message.content);
  }

  for (const call of message.tool_calls) {
    const result = await executeTool(call);
    messages.push({
      role: "tool",
      content: JSON.stringify(result)
    });
  }
}

In my test, gemma4:26b used the read_file tool when the prompt asked it to inspect ConfigRepository.kt, then continued from the tool result. That is the part that makes the log watcher feel less like a summarizer and more like a local debugging assistant.

Where Gemma 4 Helped

Gemma 4 was useful for:

  • compressing noisy logs into a short issue summary
  • grouping repeated errors
  • separating primary failures from wrapper stack traces
  • noticing earlier warnings before a crash
  • suggesting which source files to inspect
  • producing structured JSON that the local dashboard renders

The biggest win was not raw intelligence.

The biggest win was presence.

Because the model can run locally, it can be part of the normal dev loop. It does not need me to decide that a log line is important enough to upload somewhere.

Where It Was Not Enough

Gemma 4 was less reliable when:

  • the log needed domain knowledge that was only in the codebase
  • the crash involved async ordering across several classes
  • the real issue depended on backend state
  • the stack trace pointed to generated code
  • the logs were too aggressively filtered before reaching the model

The fix was not to pretend the local model could know everything.

The fix was to let it ask for context:

{
  "missing_context": [
    "HomeViewModel.loadHome()",
    "ConfigRepository.refresh()",
    "HomeAdapter.getItemCount()",
    "The JSON payload used for remote config"
  ]
}

That is the right boundary.

Gemma 4 should not hallucinate the code. It should tell the developer or tool which code to read next.

The Workflow I use now

The workflow I use now is simple:

  1. A local watcher tails adb logcat, Gradle output, and test output.
  2. Gemma 4 continuously turns noisy streams into issue candidates.
  3. The tool groups repeated failures instead of spamming me.
  4. New high-confidence findings ring a bell so I actually notice them.
  5. The local viewer on localhost:3001 shows recent findings in Chrome.
  6. When a suspicious event points to code, Gemma 4 uses read_file to inspect the local source.
  7. It suggests one small next step.
  8. If the problem is deep, I escalate the compact summary and selected files to a stronger model.

That gives each model the right job.

Gemma 4 handles continuous private observation.

A bigger model handles expensive reasoning on demand.

My Take

Before trying this, I thought of local models mostly as a privacy story.

That is still true, but it is not the whole story.

Local models also change when we can use AI.

If every model call is expensive, remote, and deliberate, AI becomes something we invoke after we notice a problem.

If a capable enough model is running on the same machine as the logs, AI can start watching for weak signals before the problem becomes obvious.

That is especially useful for mobile development, where crashes are surrounded by lifecycle noise, device noise, framework noise, and build-tool noise.

Gemma 4 does not need to be the smartest debugger in the world to be useful here.

It just needs to be local, cheap, private, and good enough to say:

"This crash is probably not where the bug started. Read the warning 40 lines above it."

That is a small sentence.

But during a debugging session, it can save an hour.

Resources