<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/4XyMTpxpd" -->

---
title: Building a Local, Ollama-Powered Insurance Claim Review...
description: A developer built a ReAct-style insurance claim review agent using LangChain/LangGraph running on local models via Ollama, and documents the tool-calling...
canonical: https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building a Local, Ollama-Powered Insurance Claim Review Agent: What Broke Along the Way | daily.dev
og:description: A developer built a ReAct-style insurance claim review agent using LangChain/LangGraph running on local models via Ollama, and documents the tool-calling...
og:url: https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd
og:image: https://api.daily.dev/og/posts/4XyMTpxpd.png
og:image:alt: Building a Local, Ollama-Powered Insurance Claim Review Agent: What Broke Along the Way
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Local, Ollama-Powered Insurance Claim Review Agent: What Broke Along the Way

**[Medium](https://daily.dev/sources/medium_js)** · 8 min read · 2 upvotes · 1 comments

## Summary

A developer built a ReAct-style insurance claim review agent using LangChain/LangGraph running on local models via Ollama, and documents the tool-calling reliability problems encountered along the way. Small local models (llama3.1, qwen2.5) repeatedly failed to produce valid structured JSON as tool arguments, truncating output or narrating tool calls as plain text instead of invoking them. The fix wasn't a bigger model but redesigning tools to minimize what the model must generate: replacing a tool that required generating an entire JSON record with one that only requires generating a short patient ID, with the actual lookup done in Python. This eliminated malformed-output failures. A separate Excel quirk (leading dash interpreted as a formula) corrupted output CSVs unrelated to the AI pipeline. The project's code and a preprint write-up are linked.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@abiola.olayimika/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-c798cb6e20f1>

## Questions this post answers

### Why does my local Ollama model fail at tool calls that work fine with a frontier hosted model like GPT-4?

Small local models are meaningfully worse at emitting valid, complete structured output as function arguments, even when their conversational reasoning seems comparable to larger models. Testing llama3.1 and qwen2.5 through Ollama showed truncated JSON, tool calls printed as plain text instead of invoked, and rambling intermediate reasoning when the model had to generate a large structured object like a full JSON record as a tool argument.

_Anyone building agents on local models can compare tool-calling reliability notes like these on daily.dev._

### How can I fix a local LLM agent that produces malformed JSON when calling tools?

Redesign the tool so the model only has to generate a trivial value, like a short ID string, instead of a full structured object. Changing a tool from taking an entire JSON record as an argument to taking just a patient_id (with Python doing the actual data lookup) eliminated truncation and malformed-JSON failures completely, because copying a few known characters is far easier for a small model than generating structured data from scratch.

_daily.dev helps developers debugging agent tool-calling failures find similar architectural fixes._

### Can local models like those running through Ollama reliably run structured agent workflows such as insurance claim processing?

Yes, but only once tools are redesigned around minimal generation rather than treated as a drop-in replacement for a frontier API. After restructuring the tool interface to minimize what the model needs to generate, a local-model-backed ReAct agent matched reference decisions on all 15 records of a synthetic validation set, split 10/10 on review-flagged cases and 5/5 on approvals.

_Developers weighing local versus hosted LLMs for agent workflows can track findings like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@leonidbugaev** · 0 upvotes

> RAW record_str as a single '{' is the failure I'd keep printing. summarize_patient_record asking llama3.1 to rebuild the whole JSON was never going to hold. Switching to get_claim_summary(P001) and doing the lookup in Python is what actually stopped the truncation.

## Similar posts on daily.dev

- [Building a Bulletproof Multi-Agent Data Analyst with CrewAI \(and Why Small LLMs Fail at It\)](https://daily.dev/posts/building-a-bulletproof-multi-agent-data-analyst-with-crewai-and-why-small-llms-fail-at-it--y7cy3z8sh) · Medium · 2 upvotes · 0 comments
- [How to Protect Sensitive Data by Running LLMs Locally with Ollama](https://daily.dev/posts/how-to-protect-sensitive-data-by-running-llms-locally-with-ollama-krjyxqjkt) · freeCodeCamp · 2 upvotes · 0 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#agentic-ai](https://daily.dev/tags/agentic-ai), [#langchain](https://daily.dev/tags/langchain), [#ollama](https://daily.dev/tags/ollama), [#langgraph](https://daily.dev/tags/langgraph)

[View this post on daily.dev](https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building a Local, Ollama-Powered Insurance Claim Review Agent: What Broke Along the Way","url":"https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd"},"datePublished":"2026-09-10T05:05:59.993Z","dateModified":"2026-09-14T06:46:35.558Z","description":"A developer built a ReAct-style insurance claim review agent using LangChain/LangGraph running on local models via Ollama, and documents the tool-calling...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f243223f671232d56efcec10f23a2c05?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f243223f671232d56efcec10f23a2c05?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"llm,agentic-ai,langchain,ollama,langgraph","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Building a Local, Ollama-Powered Insurance Claim Review Agent: What Broke Along the Way"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd","comment":[{"@type":"Comment","text":"RAW record_str as a single ‘{’ is the failure I’d keep printing. summarize_patient_record asking llama3.1 to rebuild the whole JSON was never going to hold. Switching to get_claim_summary(P001) and doing the lookup in Python is what actually stopped the truncation.","datePublished":"2026-09-10T07:09:50.379Z","url":"https://daily.dev/posts/4XyMTpxpd#c-qIfHjj4PY","author":{"@type":"Person","name":"Leonid Bugaev","url":"https://daily.dev/leonidbugaev","image":"https://lh3.googleusercontent.com/a/ACg8ocLhMgurwTmJElWaH9A8Ju8cHvZxgMCDt009jEYkmFCyUGAoaGSw=s96-c"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/building-a-local-ollama-powered-insurance-claim-review-agent-what-broke-along-the-way-4xymtpxpd#faq","mainEntity":[{"@type":"Question","name":"Why does my local Ollama model fail at tool calls that work fine with a frontier hosted model like GPT-4?","acceptedAnswer":{"@type":"Answer","text":"Small local models are meaningfully worse at emitting valid, complete structured output as function arguments, even when their conversational reasoning seems comparable to larger models. Testing llama3.1 and qwen2.5 through Ollama showed truncated JSON, tool calls printed as plain text instead of invoked, and rambling intermediate reasoning when the model had to generate a large structured object like a full JSON record as a tool argument. Anyone building agents on local models can compare tool-calling reliability notes like these on daily.dev."}},{"@type":"Question","name":"How can I fix a local LLM agent that produces malformed JSON when calling tools?","acceptedAnswer":{"@type":"Answer","text":"Redesign the tool so the model only has to generate a trivial value, like a short ID string, instead of a full structured object. Changing a tool from taking an entire JSON record as an argument to taking just a patient_id (with Python doing the actual data lookup) eliminated truncation and malformed-JSON failures completely, because copying a few known characters is far easier for a small model than generating structured data from scratch. daily.dev helps developers debugging agent tool-calling failures find similar architectural fixes."}},{"@type":"Question","name":"Can local models like those running through Ollama reliably run structured agent workflows such as insurance claim processing?","acceptedAnswer":{"@type":"Answer","text":"Yes, but only once tools are redesigned around minimal generation rather than treated as a drop-in replacement for a frontier API. After restructuring the tool interface to minimize what the model needs to generate, a local-model-backed ReAct agent matched reference decisions on all 15 records of a synthetic validation set, split 10/10 on review-flagged cases and 5/5 on approvals. Developers weighing local versus hosted LLMs for agent workflows can track findings like this on daily.dev."}}]}
```

