Skip to content

Add budget control guide for LangChain agents#93

Merged
amavashev merged 3 commits intomainfrom
claude/cycles-mcp-server-haRvD
Mar 19, 2026
Merged

Add budget control guide for LangChain agents#93
amavashev merged 3 commits intomainfrom
claude/cycles-mcp-server-haRvD

Conversation

@amavashev
Copy link
Contributor

Title: Add budget control guide for LangChain agents

Body:

Summary

  • Add new how-to guide: "How to Add Budget Control to a LangChain Agent"
  • Covers per-run budget wrapping of AgentExecutor using Cycles reservations (complementary to existing per-LLM-call callback handler doc)
  • Includes patterns for tool-level budget checks, multi-tenant scoping, and graceful degradation with ALLOW_WITH_CAPS
  • Fix protocol accuracy: budget denial for non-dry-run reservations is a 409 error, not decision=DENY on a 200 (per protocol spec line 637)
  • Add sidebar entry under How-To Guides

Test plan

  • VitePress build passes with no errors
  • Verify sidebar shows "Budget Control for LangChain Agents" under How-To Guides
  • Verify all internal cross-links resolve (callback handler doc, reserve/commit lifecycle, degradation paths, Python quickstart)
  • Confirm code examples use correct runcycles client API (field names, constructor signatures, response access patterns)

https://claude.ai/code/session_01PzuaGmFdDW83EJxwt6kQua

claude added 3 commits March 19, 2026 18:41
New guide covering per-run budget wrapping of AgentExecutor using the
runcycles Python client. Complements the existing per-LLM-call callback
handler doc with a pattern for whole-run reservations, tool-level checks,
multi-tenant scoping, and graceful degradation via ALLOW_WITH_CAPS.

https://claude.ai/code/session_01PzuaGmFdDW83EJxwt6kQua
1 USD = 100,000,000 microcents. The original amounts were off by
orders of magnitude (e.g. 5_000_000 labeled as $50 when it's actually
$0.05). Corrected all amounts and added inline dollar comments.

https://claude.ai/code/session_01PzuaGmFdDW83EJxwt6kQua
- Remove DENY-after-success checks: per protocol spec (line 637),
  budget denial for dry_run=false comes as 409 BUDGET_EXCEEDED, not
  decision=DENY on a 200. Matches existing callback handler doc pattern.
- Simplify tool-level check to just is_success
- Degradation section now shows correct two-way branch (ALLOW vs
  ALLOW_WITH_CAPS) with error handling for 409 above
- Remove unused CyclesMetrics import

https://claude.ai/code/session_01PzuaGmFdDW83EJxwt6kQua
@amavashev amavashev merged commit 942adfc into main Mar 19, 2026
2 checks passed
@amavashev amavashev deleted the claude/cycles-mcp-server-haRvD branch March 25, 2026 01:31
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.

2 participants