r/LangChain • • 17h ago

Discussion Should AI agents get their own identity and permissions like a regular user?

8 Upvotes

Most agents run with the full access of the app or service account they sit on, which is usually far more than they need. If one gets manipulated, it can do anything that account can do.

Is anyone giving agents their own scoped identities and audit trails? Or is that too much overhead for now?


r/LangChain • • 5h ago

Projects ChatOpenAI(model="gpt-5-mini") stops working Friday. Made a checker that finds these in a repo

Thumbnail
gallery
4 Upvotes

OpenAI shuts down gpt-5, gpt-5-mini, gpt-5-nano, gpt-5-pro, o3 and o3-pro on Friday 11 Dec (https://developers.openai.com/api/docs/deprecations). Calls with those IDs fail after that.

In agent code the ID is rarely in one place. It's the default in a ChatOpenAI(...) call, an env fallback like os.getenv("LLM_MODEL", "gpt-5-mini"), a cheaper model for a sub-agent, a YAML config. We searched public GitHub today: 249 repos matched, and reading them by hand, 46 org-owned repos really send a retired ID, mostly through defaults like those.

So we built a checker (I'm one of the two people who made it, at a hackathon today). Point it at a public repo and it lists every file and line, with OpenAI's replacement. There's also a GitHub Action that fails CI on them, and a fix script that swaps the IDs and writes the PR description: https://github.com/koopatroopa787/deadline-check

The same scan covers Anthropic, Gemini, Bedrock and Azure model retirements too, plus Node/Python and npm package end-of-life. All 900+ dates are searchable on the site, each linked to the vendor page it came from.

Limits: it matches model IDs written as strings, so a name assembled at runtime won't be caught. If you know other places these hide in LangChain or LangGraph projects, I'd like to add them.


r/LangChain • • 18h ago

Discussion When you route easy requests to a smaller model, how do you actually measure the quality you lose?

3 Upvotes

AWS announced smart routing in Amazon Bedrock on Dec 1 (gated preview). The idea is the familiar one: inside a model family, send hard requests to the large frontier model and simple ones to a cheaper model. Their headline is comparable quality at up to 50% lower cost versus always using the largest model in the family, based on early results. They haven't said which tasks or what quality metric that "comparable" is based on.

That gap is the part I keep coming back to, because most of us end up building some version of this ourselves in LangChain or LangGraph, usually with a classifier or a cheap model deciding the route. The cost side is easy to measure. The quality side is not, especially for agents where a weak answer at step 2 quietly breaks step 5.

Questions for people running routing in production:

  • What's your quality signal? Human-graded samples, an LLM judge, task success at the end of the chain, or user corrections?
  • Do you evaluate the router itself (how often it sent a hard request to the small model), or only end-to-end outcomes?
  • Do you route per request, or per step inside an agent loop? Per-step routing sounds cheaper but seems harder to debug.
  • What share of traffic actually ended up on the small model once you were happy with quality? Curious whether 50% savings is realistic or optimistic.
  • Anything you route that you later pulled back to always-large because the failures were too expensive?

Interested in concrete setups more than vendor numbers.


r/LangChain • • 5h ago

Question | Help A weird guardrail failure mode we hit in production: our prompt-leak detector kept blocking completely valid answers

Thumbnail reddit.com
2 Upvotes

r/LangChain • • 21h ago

Discussion Visualizing how stale RAG memory leaks EUR 14,200 silently (and how a 0.15 ms zero-dep Python gate catches it before send)

1 Upvotes

After seeing several production RAG agents fail silently around month 3, the root cause was rarely the vector store itself. It was memory blending: an expired/resolved incident row gets retrieved alongside an open ticket for the same client, and the LLM smoothly merges both into a confident wrong reply.

We visualized the exact failure mode and the deterministic Python gate we put in front of delivery:

  1. Scoped metadata: Every retrieved row carries source_id, entity scope, and valid_until / status=resolved.
  2. Inline source citations: The LLM only proposes a draft citing exact row IDs (e.g. [ref#402]).
  3. Deterministic post-check (~0.15 ms p50): A zero-dependency Python verifier validates citation existence, scope match, expiration window, and numeric polarity before delivery. If any check fails, auto-send halts with HALLUCINATION_BLOCKED -> ABSTAIN and routes the exact stale row ID to human review.

The model proposes. The code decides.

Curious how others here handle temporal/scope contradictions in long-running RAG systems: strict metadata pre-filtering only, LLM-as-a-judge, or deterministic post-checks in code?


r/LangChain • • 2h ago

Resources How do you prevent AI agents from getting stuck in infinite tool-calling loops?

Thumbnail
medium.com
0 Upvotes

Ever had an AI agent call the same tool 10 times, each time with a slightly different query, without getting any closer to the answer?

That's the agent loop problem.

I experimented with cyclic graphs using:

  • Parallel tool execution
  • Independent verification gates
  • 80% completeness threshold
  • Targeted refinement
  • Hard iteration limits and tool circuit breakers

The goal: agents that can self-correct without running forever.

Here's the architecture and implementation:

https://medium.com/@anishvv212002/stop-agent-loops-how-to-build-cyclic-graphs-that-dont-get-stuck-51e4bbffb5bf

A few things I'd like to discuss:

  1. Do you use hard iteration limits or let the LLM decide when to stop?
  2. Do you use a separate evaluator or rely on the reasoning model's self-evaluation?
  3. How do you handle agents that keep retrying tools when the results are incomplete?

PS: Used AI to paraphrase the post.

Do like the post if you like it and follow me on GitHub. Thank you!!


r/LangChain • • 13h ago

Tutorial Notes on LangChain and LangGraph with a diagram per concept and runnable code (tools, RAG, agents)

0 Upvotes

I wrote a set of notes on LangChain and LangGraph where every concept gets a diagram first and code second.

What is in it:

- Runnables, pipe, RunnableParallel and RunnablePassthrough, explained with pictures

- Tool calling: u/tool, bind_tools and the full loop with ToolMessage

- RAG: document loaders, text splitters, embeddings, Chroma, and a RAG chatbot with history

- LangGraph: state and reducers, conditional edges, fan-out and fan-in, loops, memory, human in the loop, conditional RAG

All code is in one repo, one folder per topic, each with requirements.txt and .env.example. It runs on free API keys.

Notes: https://genai-notes.vercel.app

Code: https://github.com/dhruv608/genai-notes

If something is wrong or outdated, please tell me and I will fix it.

More lessons are coming (GraphRAG, advanced agents and more). ⭐ Star the repo to keep it for revision and to get the updates.