I’m proposing a small, focused open-source tool that makes it easy and safe for LangChain agents to generate Matplotlib plots.
Goal: one well-documented, tested Matplotlib tool + agent factory that works across all LangChain agent types (zero-shot ReAct, tool-calling, openai-tools, openai-functions) and supports single/multiple DataFrames.
I am creating this issue for feedback, collaborators, and agreement on security/sandboxing, API shape, tests and examples.
Problem / Motivation
Many LangChain projects need to generate charts as part of agent workflows (data exploration, dashboards, reports).
Current examples are fragmented: different prompts, different tooling per agent type, and a lot of fragile copy/paste. Agents may return code, base64 images, or try to save files — behaviour varies by model and agent runner.
This makes it hard for downstream projects and users to adopt agent-driven plotting reliably and safely.
Proposal: a Universal Matplotlib Tool for LangChain
A single small library (or repository folder) that provides:
-
Work consistently across agent types: zero-shot React, tool-calling, openai-functions, legacy openai-tools.
-
Support single and multiple DataFrames (expose df or df1/df2/…).
-
Clear opt-in for running arbitrary code (safety).
-
Provide consistent output contract so callers can rely on outputs (file saved, base64 returned, or _out summary).
-
Provide tests demonstrating cross-agent compatibility and example prompts.
I want to know what others think about it.