Skip to content

feat: add LangGraph integration helper (v0.2.6)#13

Merged
arieradle merged 7 commits intomainfrom
feat/langgraph-integration
Mar 12, 2026
Merged

feat: add LangGraph integration helper (v0.2.6)#13
arieradle merged 7 commits intomainfrom
feat/langgraph-integration

Conversation

@arieradle
Copy link
Owner

Summary

  • Adds shekel.integrations.langgraph.budgeted_graph(max_usd, **kwargs) — a @contextmanager wrapping shekel.budget() for LangGraph workflows
  • Adds langgraph optional extra to pyproject.toml
  • 8 TDD tests covering: import, callable, budget yielded, limit/name forwarded, BudgetExceededError propagation, cost recording

How it works

No new provider adapter needed — existing OpenAI/Anthropic patches automatically intercept all LLM calls inside LangGraph nodes. budgeted_graph is purely a convenience import.

from shekel.integrations.langgraph import budgeted_graph

with budgeted_graph(max_usd=0.10, name="research-graph") as b:
    result = app.invoke(state)
    print(f"Spent: \${b.spent:.4f} / \${b.limit:.2f}")

Test plan

  • pytest tests/integrations/test_langgraph_integration.py -v — 8/8 pass
  • pytest tests/ --ignore=tests/integrations/test_groq_integration.py --ignore=tests/integrations/test_gemini_integration.py --ignore=tests/performance/ -q — 391 passed, 0 failures
  • ruff check — clean

🤖 Generated with Claude Code

Adds shekel.integrations.langgraph.budgeted_graph() — a convenience
context manager wrapping shekel.budget() for LangGraph workflows.
Existing OpenAI/Anthropic patches cover cost tracking automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

arieradle and others added 6 commits March 12, 2026 13:31
- Add budgeted_graph() to api-reference.md with full signature and examples
- Add shekel[langgraph] extra to installation.md (section, dep table, troubleshooting)
- Fix install command in langgraph.md and langgraph_demo.py to use shekel[langgraph]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mypy 1.19.1 follows imports into _pytest/terminal.py which uses match
syntax (Python 3.10+), causing a hard [syntax] error when
python_version = "3.9".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mypy 1.19.1 traverses into _pytest/terminal.py (site-packages) which
uses match syntax incompatible with python_version = "3.9". Adding
exclude = ["/_pytest/"] prevents the path from being scanned.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
On Python 3.11, mypy 1.19.1 follows imports into _pytest/terminal.py
which uses match syntax (Python 3.10+), causing a fatal [syntax] error.
Python 3.12 can parse match natively so the issue only surfaces in CI.

Using follow_imports="skip" prevents mypy from traversing into _pytest.*
regardless of how the import is reached.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@arieradle arieradle merged commit f4896be into main Mar 12, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant