Skip to content

feat(examples): add CSV data analysis agent example#1777

Open
Mohammad Mohtashim (keenborder786) wants to merge 2 commits intolangchain-ai:mainfrom
keenborder786:example_data_analysis_agent
Open

feat(examples): add CSV data analysis agent example#1777
Mohammad Mohtashim (keenborder786) wants to merge 2 commits intolangchain-ai:mainfrom
keenborder786:example_data_analysis_agent

Conversation

@keenborder786
Copy link
Contributor

@keenborder786 Mohammad Mohtashim (keenborder786) commented Mar 10, 2026

Adds a new data-analysis-agent example that analyzes CSV files using pandas
and matplotlib, producing structured reports with charts.

Use case as per in #951 to add more example

Why this example

The existing examples all use FilesystemBackend and return free-text responses.
This example fills two notable SDK gaps:

  1. LocalShellBackend — first example to use shell execution via the
    execute tool. The agent writes and runs self-contained Python scripts
    (pandas, matplotlib) to compute statistics and generate charts, which is a
    fundamentally different interaction pattern from the file read/write workflows
    in other examples.

  2. Structured output (ToolStrategy) — first example to use response_format.
    The agent returns a typed DataReport Pydantic model with findings, severity
    levels, and recommendations instead of unstructured text. This makes the output
    programmatically consumable.

It also uses memory (AGENTS.md) as enforceable analytical standards (rounding
rules, chart conventions) rather than persona context, and skills for three
distinct analysis workflows (exploratory, statistical, anomaly detection).

What's included

  • analyze.py — async streaming with Rich progress display showing each tool call
  • AGENTS.md — analysis standards (rounding, chart formatting, reporting rules)
  • 3 skills: exploratory-analysis, statistical-summary, anomaly-detection
  • Bundled data/sample_sales.csv (103 rows) for immediate demo
  • README with installation, usage, and architecture docs

How I verified

  • Ran the agent against the sample dataset with several queries
    ("Summarize this dataset", "Which region has the highest revenue?",
    "Find anomalies in daily revenue")
  • Confirmed structured DataReport output renders correctly in the terminal
  • Confirmed chart PNGs are generated in output/

Disclaimer: This contribution was developed with the assistance of AI agents.

@github-actions github-actions bot added dependencies Pull requests that update a dependency file size: L 500-999 LOC labels Mar 10, 2026
@org-membership-reviewer org-membership-reviewer bot added the external User is not a member of the `langchain-ai` GitHub organization label Mar 10, 2026
@github-actions github-actions bot added the feature New feature/enhancement or request for one label Mar 10, 2026
@keenborder786 Mohammad Mohtashim (keenborder786) changed the title feat: Complete Example feat(examples): add CSV data analysis agent example Mar 10, 2026
@github-actions github-actions bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Mar 10, 2026
@keenborder786
Copy link
Contributor Author

Hello Mason Daugherty (@mdrxy), I’ve added another example as requested in issue #951.

@mdrxy
Copy link
Member

A couple things to align with the example contributing guidelines:

  1. Commit uv.lock — the .gitignore currently excludes it, but all existing examples include their lock file for reproducible builds. Remove the uv.lock line from .gitignore and commit the generated lock file.

  2. Tighten the deepagents version pindeepagents>=0.3.5 has no upper bound, which could break on a future major release. Use a range instead, e.g. deepagents>=0.3.5,<0.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file external User is not a member of the `langchain-ai` GitHub organization feature New feature/enhancement or request for one size: L 500-999 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants