r/LangChain • • 39m ago

Discussion How are you catching agents that say "done" when they didn't do the thing?

Thumbnail reddit.com
2 Upvotes

I started verifying agent runs by checking the final state against the database instead of trusting the agent's summary. Caught a lot.

Then someone pointed out that an agent can land in the right end state for the wrong reasons, like retrying a tool 4 times or calling something it shouldn't have along the way.

So now I check the path too, not just where it ended up.

How are you all evaluating runs in production? Traces plus manual review, evals, something custom?


r/LangChain • • 3h ago

Projects Tips for open source AI agent monitoring tool

Thumbnail
github.com
1 Upvotes

I opened source a tool to montior AI agents that run in production and writes into external systems and DBs.

The point of the tool is to catch silent failures, like the agent says it did something, the tool call returned success, but the record in the DB is missing, wrong, or changed afterwards.
For example, the refund was written as $120 instead of $12, or the booking row never got committed.

When the agent call a tool, my tool goes into the external system, check for the record if its correct and by what the user asked, and set a score for that span and trace in Langfuse.

I talked into many peoples about the tool, and built it from what they were saying to me and about their problems.

Right now, I am looking for other contributors to make the project better and integrate with more systems.

I would love to know, what would you add to that kind of tool? what will make you use one like this?

Would love to hear what you have to say and I would love to hear you feedback :)


r/LangChain • • 5h ago

Discussion Graph rag vs agentic rag

Thumbnail reddit.com
1 Upvotes

r/LangChain • • 11h ago

Discussion Had to look up something in the docs and oh my god…

2 Upvotes

…it was genuinely not a experience??

I never thought there’d ever be a day I’d say that the LANGCHAIN docs were actually helpful, but they were so credit where credit is due.

The nav was still confusing, and the search seems still meh and linking a bunch of random pages, but their little chatbot thing understands my question and either answers me or points me exactly to the pages I want.

It wasn’t just a one time experience. I’ve probably used it like 15-20 times over the last few weeks and it’s truly been super helpful.

My only feedback is sometimes a page just reads like claude slop so just hire a human to rewrite a lot of those pages with that shiny series C :-)

Thanks Langchain team!

You’ve come a long way (but still have more to go)


r/LangChain • • 22h ago

Discussion For teams running AI agents in production: what's still painful when debugging them?

11 Upvotes

I'm trying to understand how engineering teams actually investigate failures in production AI agents

I'm particularly interested in teams using tools like LangSmith, Langfuse, Braintrust, or custom observability setups

A few questions:

  1. When was the last time an agent behaved unexpectedly in production? What happened?
  2. How did you identify the root cause?
  3. Did your existing observability tools give you everything you needed, or did you have to investigate manually using application logs, database records, code changes, etc.?
  4. What part of the investigation took the most time?
  5. Is this a recurring problem, and has it caused meaningful engineering time or customer impact?

I'm interested in actual production experiences, not hypothetical feature requests

Also, if your existing tools already solve these problems well, I'd genuinely like to hear how


r/LangChain • • 14h ago

Tutorial Your LLM is LYING to you. Here's how to fix it.

Thumbnail
youtube.com
2 Upvotes

I built a Hello World RAG App in Python

Normal LLM = Answers from training data (can hallucinate)

RAG LLM = Answers from YOUR documents

I asked it Saudi it didn't say Saudi Arabia.

It said "Contractor at Saudi Aramco" - because it read MY LinkedIn PDF.

This is how it works:

  1. Load PDF
  2. Split into Chunks
  3. Create Embeddings (Google Gemini)
  4. Store in ChromaDB
  5. Search Top 3 Chunks
  6. Send Context + Question to Groq LLM

Tech: Python + LangChain + ChromaDB + Groq + Gemini Embeddings

Save this for your next interview

Comment "RAG" and I'll send you the full code + next part.

Follow for AI Engineer series - Part 2 coming next.


r/LangChain • • 1d ago

Question | Help how to add company research and people search to a LangChain agent without loading too many tools?

9 Upvotes

building a small b2b research chain in python this week and trying to keep the number of tools manageable. the agent needs to look up company information like employee count, recent funding and open job postings, then find employees by job title and seniority to identify the right marketing director or vp. after that, it looks up their business email and checks whether it's valid. giving the agent too many apiss and MCP tool seems to make tool selection harder, when several have similar parameters. trying Monid for some of these company data and contact lookups because the agent can search for the tool it needs instead of loading every integration upfront. curious how others are handling company data APIs, B2B people search and email verification in LangChain. do you use one tool interface or separate integrations for each data source?


r/LangChain • • 13h ago

Tutorial LangGraph vs CrewAI vs OpenAI Agents SDK: Which Framework to Pick

Thumbnail
acta.ai
0 Upvotes

r/LangChain • • 1d ago

Projects IR evals for your RAG retriever without any model calls

3 Upvotes

When a RAG answer is wrong, the cause is often retrieval: the right chunk never reached the model. An LLM judge that grades the final answer won't show you that, and you pay for a model call on every query.

Evret scores only the retriever. You give it queries and the doc IDs each query should return. It computes Hit Rate, Recall, MRR, nDCG, ERR, and RBP at k by comparing doc IDs, so it makes no model calls.

It works with Qdrant, Chroma, Weaviate, Milvus, Elasticsearch, LangChain, LlamaIndex, and Haystack.

🔗 GitHub: https://github.com/kaivid-labs/evret


r/LangChain • • 1d ago

Discussion blamed the model all week, it was my browse tool

15 Upvotes

my langchain agent asked me which library it was supposed to be checking. i blamed the model for a week, tried a bigger one, no change. it was my browse tool

it reads changelogs for the sdks we use and drafts the weekly upgrade note, and it lost the thread a few changelogs in. i printed the messages going into that call. mostly nav menus, cookie banners and the same docs footer, once per page it already left. the actual ask was buried up top

the tool returns the whole rendered page and nothing leaves history

what do your browse tools hand back to the model? does a page stay in context after the agent moves on?


r/LangChain • • 21h ago

Question | Help Most LLM apps silently break their own prompt cache. Here's what I found auditing 20 open-source ones (feedback wanted)

0 Upvotes

Disclosure: I'm the author of leanprompt, the free, Apache-2.0 tool I used for this. There's no paid version, no hosted service, no account.

Every LLM call resends the system prompt, the tool list and the history. Providers cache the part that didn't change, but only if it didn't change byte for byte, from the first token. I ran audits on open-source LLM apps (gpt-researcher, anything-llm, bilingual_book_maker, better-chatbot and others) and kept seeing the same few mistakes.

  1. Something volatile at the top of the prompt.
  2. A timestamp to the second on the first line of the system prompt means no call can ever reuse what follows it. In our example app that was an estimated 6.7M tokens per 1,000 calls the cache could have served.
  3. A history window that shifts every turn.
  4. Trimming the oldest message each turn changes the prefix, so every turn re-reads the whole conversation.
  5. No cache marks on Anthropic.
  6. Anthropic caches only where the client asks. On replayed coding-agent sessions, a client sending no marks got 0 tokens from cache over 29 turns. A client sending 3 marks got 92% of prompt tokens from cache on a single session.
  7. Caching that's off by default in a gateway.
  8. One app's default model ran through a gateway where caching has to be switched on explicitly.
  9. Cost meters that ignore cache fields.
  10. 3 of the first 4 apps metered their own spend from `input_tokens` and never read the cached-token fields, so their dashboards were wrong in either direction.
  11. Paying twice for output.
  12. Retrying a truncated answer from scratch, or sending a batch that the limit cuts off, re-buys tokens you already paid for. One of these fixes was merged upstream (bilingual_book_maker #590).

And one that went the other way. Moving the date to the end of the prompt, to protect the cache, cut correct date answers from 10/12 to 1/12 and didn't help the cache. So the rule isn't "move everything dynamic down"; meaning comes first, then cache.

Two smaller things: on a hybrid-thinking model, toggling thinking on and off between turns lost 47% of the reusable prefix. Tools built from an unsorted dict also change order between calls.

How it works: leanprompt is a set of skills for your coding agent (Claude Code, Codex, Cursor, OpenCode, anything that reads AGENTS.md). `/leanprompt audit` finds every LLM call in your app and ranks where it loses tokens. `fix` shows a diff and applies it on your yes. `measure` proves the change with a before-and-after number. The audit numbers are estimates from reading the code; `measure` is what turns them into measurements. Every figure in this post has a row in the evidence table with its source and limits.

npx leanprompt install

Repo: https://github.com/Podwarden/leanprompt

Audit logs - what we found in multi-star github projects: https://lmwarden.com/leanprompt/audits/

What I'm asking for: feedback. The rules are the part that matters, and they only get better from cases I haven't seen. The skills, rules and provider tables are CC BY 4.0, so whatever you teach them goes back to everyone who uses them, with credit if you want it. Most useful:

- a rule that's wrong or missing for your provider or engine (self-hosted vLLM or SGLang, Gemini, Bedrock, OpenRouter...)

- a finding that turned out to be a false positive on your code

- a cache or cost mistake you've hit that isn't on this list

- an audit that missed an LLM call, or ranked a small problem above a big one

Reply here, open an issue, or use the "lesson learned" form in the repo. It's fine in general terms, without sharing your code. Every report I can verify becomes a rule or a fix to one.


r/LangChain • • 1d ago

Question | Help How do I make my existing RAG project into production?

Thumbnail
gallery
1 Upvotes

I have built a RAG on research papers,

Tech stack i have used :

Framework - Langchain

Ingestion - llamaparse and Pypdf as backup

Retrieval - Hybrid Search with dense semantic search (MongoDB Atlas Vector Search) with sparse keyword matching (BM25).

Then Reciprocal Rank Fusion(RRF) and Cohere Reranker on top of it.

Evals : offline evals currently, RAGAS (Faithfulness, Relevancy, Context Utilization) still figuring for online Evals (might move to LangFuse)

Models:

for embedding -

nvidia/nemotron-3.5-embed-1b

(Changing models based on their lifetime)

For Generation -

nvidia/nemotron-3.5-lightning-30b-a3b

llama-3.3-70b-versatile

Kept Groq model fallback on 500/400 ERRORS of Nvidia.

LOGGING : API server errors (majorly 503/429 etc) , timeouts, groq_fallbacks, bm25 fallbacks, last_error_time.

Also Built a test set of queries.

Along with if both generation model fails

Then will fallback to BM25 RESULTS.

I believe the results are good.

Also I feel gap to push this project into production.

Looking for good assistance.

Ps: will share repo later.


r/LangChain • • 1d ago

Discussion Google adk vs langgraph

Thumbnail reddit.com
1 Upvotes

r/LangChain • • 1d ago

Discussion I built a banking agent reference architecture where the LLM has no write path to money — not "guarded," just no tool

Thumbnail
reddit.com
0 Upvotes

r/LangChain • • 1d ago

Discussion I'm exploring a browser memory layer that remembers what you were researching, not just which websites you visited

Thumbnail
reddit.com
1 Upvotes

r/LangChain • • 1d ago

Discussion Why Can't all Coding Agents Reach 100% on DataAgentBench benchmark?

Post image
0 Upvotes

We spent a week optimizing our coding agent on DataAgentBench (DAB), only to discover that the biggest obstacle to reaching 100% might not be the agent itself, but the quality of the ground truth.

A little context. DataAgentBench is a benchmark designed to evaluate agents' ability to query databases, retrieve information, process data, perform calculations, and return answers in numerical, textual, or tabular formats. It covers 12 datasets and 54 queries across 9 domains and 4 DBMSes.

Our optimization journey. Starting with an accuracy of 87.9%, we continuously leveraged Agent Self-Evolution in Camber Agent Labs to automatically improve our agent, reaching 95.4% and beyond. However, after more than 10 rounds of self-improvement, two queries remained consistently unresolved: Query #2 and Query #3 from the AG's News database.

Camber Agent Labs is designed to help developers evaluate and continuously improve AI agents through automated experimentation. Its Agent Self-Evolution capability enables agents to learn from evaluation feedback, identify failure patterns, and iteratively optimize their configurations, reducing the need for manual intervention.

AG's News database overview. AG's News is a news classification dataset covering four categories: World, Sports, Business, and Science/Technology (Sci/Tech). Each article includes a title and a description, which the agent must use to infer its category.

It was time for us to investigate manually. One query asks for the fraction of Amy Jones's articles belonging to the Science/Technology category. The expected answer is 16 out of 111 articles. However, our agent consistently classified an article titled "Texas Instruments Posts Higher 3Q Profits" as Business, while the ground truth labeled it as Sci/Tech. After reviewing the article ourselves, we agreed with the agent's classification.

The other query asks for the average annual number of Business articles published in Europe between 2010 and 2020. We encountered a similar potential issue, but at a much larger scale, involving 14,860 articles.

Why does this happen? DataAgentBench reuses the AG's News dataset from 2015. The original dataset contains multiple fields, but the classification task relies primarily on article titles and descriptions. Moreover, a technical report on AG's News preprocessing documents that descriptions longer than 60 tokens were truncated. These preprocessing choices can unintentionally remove important context, making the original category labels ambiguous or inconsistent with the text available to an agent.

The fundamental problem. DataAgentBench requires agents to infer article categories from their titles and descriptions without accessing the original labeled AG's News dataset. When the available information is insufficient to recover the expected labels, even a more capable agent may fail to reproduce the ground truth. Hardcoding answers or retrieving the original labels would violate the benchmark rules and defeat the purpose of the evaluation.

This raises a broader question about AI evaluation: Are we measuring an agent's actual intelligence or simply its ability to reproduce the expected answers?

Can a more capable agent actually score worse because of noisy ground truth? And how should benchmark designers address this problem after a release for a long time?

I'd love to hear your thoughts, especially from those working on AI agents and evaluations.

References:


r/LangChain • • 2d ago

Question | Help Silent failure modes in multi-step AI agents

7 Upvotes

Hi All!

We've been cataloging silent failure modes in multi-step AI agents.

What was the last time your agent failed silently without throwing a 500 error or an error code?


r/LangChain • • 2d ago

Discussion A 100-page fetch test run by Octen: Octen Extract 88%, You.com Contents 81%

3 Upvotes

Disclosure: I work at Hackmamba, Octen is a client, and Octen ran this test itself.

The score covers retrieval (did each page come back?), so check parsing quality yourself. It was a single round on Sept 1.

Octen Extract vs You.com's Contents API, Octen listed first:

• 100-page set: 88% vs 81%

• 42 anti-bot pages: 89% vs 90%

• 22 document files: 100% vs 82%

• The 7 PDFs among them: 100% vs 43%, which accounts for the whole document gap

• 10 robustness probes (empty and error pages, oversize pages, a redirect chain and more): 95% vs 55%

Treat the small slices with care, since 7 PDFs and 10 probes are tiny samples. The method notes also say that a single round can't separate tools that are a few points apart, such as 89% and 90%.

The page set and commands are public. A rerun needs a key for each tool you test, plus an LLM key for the judges: https://github.com/Octen-Team/benchmark-for-accuracy

What fails most often in your fetch step?


r/LangChain • • 2d ago

Resources How do you manage chat history in production LLM applications?

Thumbnail
medium.com
3 Upvotes

I've been exploring different ways to manage conversation history in LLM apps.

Appending the entire chat history to every API call works initially, but as conversations grow, token costs increase, context gets cluttered, and important information can get lost.

I experimented with a turn-based 10 + 10 hybrid approach:

  • Maintain a persistent summary of older conversations.
  • Keep the latest 10 turns untouched.
  • Every 5 new turns, condense the oldest 5 into the summary.
  • Prune unnecessary historical tool outputs while preserving the actual responses.
  • Keep the active turn untouched to avoid breaking tool-call sequences.

I've written about the approach and the trade-offs and included a Python implementation using LangChain.

Article: https://medium.com/@anishvv212002/how-to-manage-chat-history-in-llm-apps-the-architecture-i-use-in-production-and-why-naive-efe9a55a570f

Curious to know how others are handling this.


r/LangChain • • 2d ago

Discussion What are you using to run AI agents in production across different frameworks?

Thumbnail reddit.com
4 Upvotes

r/LangChain • • 2d ago

Projects Product analytics for MCP and Agent Skills: how to build a roadmap from your logs

Thumbnail
reddit.com
2 Upvotes

r/LangChain • • 2d ago

Discussion Apparently, building an agentic workflow in LangGraph doesn't count unless you literally name a variable agent 💀

Thumbnail reddit.com
2 Upvotes

r/LangChain • • 3d ago

Discussion How are you enforcing per-user tool permissions in LangChain agents in production?

6 Upvotes

The LangChain tools docs show how to filter tools per user with wrap_model_call, and a neighbouring example carries the comment "Only enable sensitive tools after authentication". We reran the repro from issue #41801 on langchain 1.5.2 this week, and create_agent still ran a delete tool for a viewer.

The filter we used, close to the docs version:

from langchain.agents.middleware import wrap_model_call

def viewer_tools(request, handler):
    if request.runtime.context.user_role != "admin":
        request = request.override(
            tools=[t for t in request.tools if t.name.startswith("read_")]
        )
    return handler(request)

With a viewer context the model only saw read_data. We had the model call delete_data anyway (a scripted fake model, so this tests what the framework does once the call shows up). create_agent ran it and returned "deleted r2" as the tool result.

The filter edits the tool list sent to the model and nothing else. When a call comes back, the tool node checks the name against every tool registered on the agent. A made-up name gets an "is not a valid tool" error, and delete_data passes that check because it is still registered.

Hosted models send these calls too. In the same issue, the author kept an admin's earlier delete in the message history and had a viewer ask for the same thing. By their count, claude-haiku-4-5 called the hidden tool in 3 of 3 runs and claude-haiku-5-5 in 5 of 6. gpt-4o-mini and gpt-6-luna didn't call it in their runs. The issue has been open since Nov 11 with no fix merged yet.

The workaround suggested in the issue thread, a second check where the tool executes, keyed on the same role, stopped it for us:

from langchain.agents.middleware import wrap_tool_call
from langchain_core.messages import ToolMessage

def enforce_tools(request, handler):
    role = request.runtime.context.user_role
    name = request.tool_call["name"]
    if role != "admin" and not name.startswith("read_"):
        return ToolMessage(
            content=f"{name} is not allowed for this user",
            tool_call_id=request.tool_call["id"],
            status="error",
        )
    return handler(request)

With both middlewares on, the viewer run gets "delete_data is not allowed for this user" back as an error ToolMessage, and the delete never executes. Admin runs still go through. In a real app we would check an explicit allowlist per role. The read_ prefix only keeps the example short. We kept the filter as well, since the same docs page notes that too many tools can overwhelm the model and increase errors.

For tools served over MCP, the open-source gateway we build checks each tools/call request against the calling API key's allowed and denied lists when key auth is on, so a tool a key can't see also can't be called.

Where do your tool permissions live today, in agent middleware like this or down at the tool and MCP server level?


r/LangChain • • 2d ago

Discussion In my pipeline, the model doesn't choose which numbers to count: the code tries each combination, then rejection and acceptance gates before any result.

2 Upvotes

The problem I started with: I planted a three-step calculation in a test case, with the numbers coming from three different sources. A general agent with complete arithmetic tools couldn't find it. He knew how to multiply, but he didn't know which numbers belonged to which group!

The usual method is for the model to write the equation and for a tool to calculate it. But this way, the model still chooses the inputs, and that's where the problem lies.

So my pipeline ended up like this:

  1. extract => two models extract every quantity => unit => denominator => scope (structured output).
  2. reconcile => keep a value only if both extractions agree, or a verbatim source quote settles it.
  3. enumerate => code tries every combination of 2-4 quantities whose units produce a decision unit.
  4. compute => unit library (pint), never the model.
  5. reject => 6 deterministic checks on the numbers
  6. accept => 6 gates in order; one failure drops the candidate
  7. explain => the model only writes up what survived; "no discovery" is the default

In a prototype: 230 candidate accounts, two remained, with the one planted in between. The second was disguised, passing because a number in it had no denominator. Hence the rejection gates: recalculation, an impossible number due to its lack of a denominator, a quantity without a denominator or unit, discrepancies between the extractors, mixing ranges (weekly with monthly), and the fragility of the conclusion with a 5% change.

Then the admission gates in order: new to the file, then new to the field, then non-intuitive, then influential, then case-specific, then change the decision.

The assessment method was recorded in advance before any case was built: 100 cases, of which 30 were empty and 20 were misleading, with a false positive limit of 5%: https://doi.org/10.5281/zenodo.24506889

Questions I haven't thought of yet;

  1. How could you extract units and denominators with organized outputs? This is my weakest point.
  2. Has anyone thought of building a layer to verify the deterministic outputs after the agent's outputs? What could you put in it?
  3. What happens when the combinations get too large? I have a maximum of 4 quantities, and I'm considering trimming by units before counting.

r/LangChain • • 3d ago

Question | Help Agents running in prod, hand made script or prod harness?

Thumbnail reddit.com
3 Upvotes