FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Add Agent Safety to Any LangChain Tool in Two Lines
NewsProgramming Languages

Add Agent Safety to Any LangChain Tool in Two Lines

via Dev.to PythonMavericksantander2h ago

You have a LangChain agent with tool access. It can run shell commands, call APIs, modify files. It works great in development. Then you give it production credentials and it does something you didn't expect. The fix is two lines. The Problem With Tool Access Today When you define a LangChain tool, there's nothing between the model's decision and the execution: from langchain.tools import tool @tool def run_bash ( command : str ) -> str : """ Execute a bash command and return the output. """ import subprocess return subprocess . check_output ( command , shell = True ). decode () The model decides to call run_bash . It runs. No questions asked. If the model decides rm -rf /tmp/important_data is the right move, that's what happens. No log. No gate. No way to know it happened until something is broken. The Fix: @safe_tool Canopy 0.2.1 ships a decorator that wraps any function with a policy check before execution: from langchain.tools import tool from canopy import safe_tool @tool @safe_to

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
0 views

Related Articles

I Stopped Self-Reviewing My Code — Claude Code’s /simplify Does It Better
News

I Stopped Self-Reviewing My Code — Claude Code’s /simplify Does It Better

Medium Programming • 30m ago

The Postgres Query That Deleted $430K in Revenue (And the 12-Character Fix)
News

The Postgres Query That Deleted $430K in Revenue (And the 12-Character Fix)

Medium Programming • 56m ago

Amazon is clearing out these popular DeWalt power tools by up to $190 off
News

Amazon is clearing out these popular DeWalt power tools by up to $190 off

ZDNet • 1h ago

Save Almost 20 Percent On Our Favorite Portable Bluetooth Speaker
News

Save Almost 20 Percent On Our Favorite Portable Bluetooth Speaker

Wired • 1h ago

RHAPSODY OF REALITIES - 16TH MARCH 2026
"Facts may change, but truth is eternal.
News

RHAPSODY OF REALITIES - 16TH MARCH 2026 "Facts may change, but truth is eternal.

Medium Programming • 1h ago

Discover More Articles