Skip to content

feat: add langchain-rustchain — LangChain tools for RustChain API (answers #3074) [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] - #8199

Open
waterWang wants to merge 1 commit into
Scottcjn:mainfrom
waterWang:feat/langchain-rustchain-tool
Open

feat: add langchain-rustchain — LangChain tools for RustChain API (answers #3074) [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]#8199
waterWang wants to merge 1 commit into
Scottcjn:mainfrom
waterWang:feat/langchain-rustchain-tool

Conversation

@waterWang

Copy link
Copy Markdown
Contributor

Summary

Adds a standalone langchain-rustchain Python package under integrations/langchain-rustchain/ that exposes RustChain read-only API endpoints as LangChain BaseTool subclasses.

Wallet: fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT

Tools

Tool Endpoint Description
rustchain_check_balance GET /wallet/balance?miner_id=... Check RTC balance of any wallet
rustchain_list_bounties GitHub Issues API List open ecosystem bounties (labelled "bounty")
rustchain_get_node_health GET /health Node health: DB, tip age, uptime, version
rustchain_get_current_epoch GET /epoch Current epoch, slot, enrolled miners, emission

Structure

integrations/langchain-rustchain/
├── pyproject.toml          # pip-installable package (langchain-rustchain)
├── README.md               # Quick start + docs
├── example.py              # Direct demo script (no LLM needed)
└── langchain_rustchain/
    ├── __init__.py          # Public API exports
    └── tools.py             # 4 BaseTool subclasses + get_tools() factory

Verification

All 4 tools tested against the live public node (https://rustchain.org):

  • rustchain_check_balance("test_wallet"){"balance_rtc": 0.0}
  • rustchain_list_bounties(limit=3) → 3 open bounties returned
  • rustchain_get_node_health(){"version": "2.2.1-rip200", "uptime_s": 174000+}
  • rustchain_get_current_epoch(){"epoch": 249, "slot": 35909, "enrolled_miners": 17}

Acceptance Checklist

  • pip install . works (pyproject.toml)
  • All 4 tools call live endpoints
  • No auth required for RustChain node endpoints
  • GitHub API uses optional GH_TOKEN/GITHUB_TOKEN env var (higher rate limit, no token = unauthenticated fallback)
  • example.py runs without an LLM (direct tool calls)
  • MIT licensed

Closes rustchain-bounties#3074

…eck_balance, list_bounties, node_health, current_epoch) [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added documentation Improvements or additions to documentation BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) labels Aug 9, 2026
@github-actions github-actions Bot added the size/L PR: 201-500 lines label Aug 9, 2026

@FlintLeng FlintLeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: LangChain-RustChain Integration

Reviewed on: 2026-08-13

Bounty

rustchain-bounties#3074: LangChain tools for RustChain API — bounty claimed in PR body.

Summary

Adds a standalone Python package langchain-rustchain that exposes RustChain read-only API endpoints as LangChain BaseTool subclasses. Enables any LangChain agent to check RTC balances, list bounties, inspect node health, and read the current epoch.

Architecture ✅

Clean LangChain integration. Four tools:

  • RustChainBalanceTool/wallet/balance endpoint
  • RustChainBountiesTool — GitHub issues with bounty labels
  • RustChainNodeHealthTool/health endpoint
  • RustChainCurrentEpochTool/epoch endpoint

All tools inherit from BaseTool and implement _run() with the standard LangChain interface. No write operations — all read-only, appropriate for untrusted agent environments.

Package structure is correct:

  • langchain_rustchain/__init__.py exports all tools + convenience get_tools() factory
  • pyproject.toml with proper metadata (MIT license, Python 3.9+)
  • example.py demonstrates direct tool calls without requiring an LLM

Dependencies are minimal: Only langchain-core and requests. No heavy LLM SDKs — the package is tool-only, leaving LLM choice to the user.

API Design ✅

RustChainBountiesTool uses GitHub API correctly: Queries repos/Scottcjn/rustchain-bounties/issues with labels=bounty and state=open. No authentication required for public issues — correct.

All tools target https://rustchain.org by default with configurable override via environment variable. Appropriate for a read-only integration.

Error handling: Each tool catches requests.RequestException and returns a user-friendly error string instead of raising. This is the right behaviour for LangChain tools — agents can handle the error message gracefully.

Minor Notes

  1. RustChainBountiesTool pagination: The tool fetches per_page=20 by default. For a bounty program with many open issues, this may miss older bounties. Consider adding pagination support or increasing the limit.

  2. No caching: Each tool call hits the live API. For frequently-called tools like NodeHealthTool, caching with a short TTL (e.g., 30s) would reduce load. Not critical for a v1.

  3. pyproject.toml version: No explicit version field — setuptools will infer from git tags or default to 0.0.0. Consider adding an explicit version for PyPI publishing.

Wallet: RTC019e78d600fb3131c29d7ba80aba8fe644be426e

✅ LGTM — clean, well-scoped LangChain integration that answers #3074 with appropriate read-only tooling.

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

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) documentation Improvements or additions to documentation size/L PR: 201-500 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants