Skip to content

Add LangChain.js integration guide and expand incident documentation#66

Merged
amavashev merged 2 commits intomainfrom
claude/analyze-doc-website-FTmG8
Mar 16, 2026
Merged

Add LangChain.js integration guide and expand incident documentation#66
amavashev merged 2 commits intomainfrom
claude/analyze-doc-website-FTmG8

Conversation

@amavashev
Copy link
Contributor

Summary

This PR expands the Cycles documentation with a comprehensive LangChain.js integration guide and significantly enhances incident documentation with TypeScript examples, severity analysis, detection strategies, monitoring rules, and testing patterns.

Key Changes

New Documentation

  • LangChain.js Integration Guide (how-to/integrating-cycles-with-langchain-js.md): Complete guide for adding budget governance to LangChain.js applications using a custom CyclesBudgetHandler callback handler that wraps every LLM call with Cycles reservations. Includes examples for chat models, agents with tools, and streaming responses.

  • Glossary (glossary.md): Comprehensive definitions of key Cycles concepts including Budget Authority, Reservation, Commit, Release, Estimate, Decide, Scope, Subject, Three-Way Decision, Overage Policy, and Units.

  • Integrations Overview (how-to/integrations-overview.md): High-level overview of all supported Cycles integrations across LLM providers, frameworks, and web servers with language support and streaming capabilities.

  • 404 Page (404.md): Custom 404 error page with navigation to key documentation sections.

  • Web App Manifest (public/manifest.json): PWA manifest for installable documentation site.

Enhanced Incident Documentation

Concurrent Agent Overspend (incidents/concurrent-agent-overspend.md):

  • Added Python and TypeScript code examples demonstrating the problem and solution
  • Added severity and impact analysis with concrete cost multiplication examples
  • Added detection strategies (querying active reservations, spotting TOCTOU patterns)
  • Added comprehensive Prometheus alerting rules
  • Added concurrent load testing patterns in both Python and TypeScript

Retry Storms and Idempotency Failures (incidents/retry-storms-and-idempotency-failures.md):

  • Added TypeScript equivalent using withCycles wrapper
  • Added severity and impact analysis showing cost explosion across retries and fleet multiplication
  • Added detection strategies (reservation-to-commit ratio analysis, idempotency key pattern matching)
  • Added Prometheus alerting rules for retry storm detection
  • Expanded prevention strategies with detailed implementation examples in both languages
  • Added testing patterns for verifying retry behavior under budget constraints

Scope Misconfiguration and Budget Leaks (incidents/scope-misconfiguration-and-budget-leaks.md):

  • Added severity and impact section explaining silent nature of scope misconfiguration
  • Added pattern Add comprehensive deployment guide and admin server documentation #5: dynamic scope values from user input with sanitization examples
  • Added TypeScript detection example for programmatically finding scope gaps
  • Added Prometheus alerting rules for scope mismatch detection
  • Added testing patterns for verifying scope configuration consistency
  • Added centralized scope builder pattern with TypeScript implementation

Enhanced How-To Guides

Handling Streaming Responses with Cycles (how-to/handling-streaming-responses-with-cycles.md):

  • Added TypeScript section with reserveForStream pattern for streaming responses
  • Includes automatic heartbeat handling and cap application examples

Configuration Updates

VitePress Config (.vitepress/config.ts):

  • Added apple-touch-icon and manifest.json links for PWA support

Notable Implementation Details

  • The LangChain.js callback handler uses runId to track concurrent reservations, ensuring proper lifecycle management for multi-turn agents
  • Incident documentation now includes both Python and TypeScript examples consistently across all patterns
  • Detection and monitoring sections provide actionable Prometheus queries and alerting rules
  • Testing patterns demonstrate how to verify budget enforcement under concurrent and retry scenarios
  • Scope configuration examples emphasize input validation and sanitization to prevent bypass vulnerabilities

https://claude.ai/code/session_01LVeAZGvccG11HfdcBGqECM

claude added 2 commits March 16, 2026 19:38
…de, SEO, and UX

- Add glossary page with key Cycles terminology
- Expand three thin incident pattern pages with detection, monitoring,
  TypeScript examples, and severity/impact sections
- Add LangChain.js (TypeScript) integration guide
- Add integrations overview landing page with comparison table
- Add TypeScript streaming examples to streaming guide
- Add apple-touch-icon, web app manifest, and per-page canonical URLs
- Create custom 404 page
- Uncollapse Integrations sidebar section
- Add LangChain.js to sidebar navigation

https://claude.ai/code/session_01LVeAZGvccG11HfdcBGqECM
… table

- LangChain.js guide: fix CyclesClient calls to use snake_case wire
  format (idempotency_key, ttl_ms, tokens_input, tokens_output) instead
  of camelCase; remove invalid subject param from reserveForStream;
  simplify error handling to match documented TS patterns
- manifest.json: align name/description with config.ts (use "Cycles"
  and matching description)
- Integrations overview: fix OpenAI/Anthropic to Python-only (not
  Python+TypeScript); fix Express streaming=Yes; fix FastAPI pattern
  to Middleware/Decorator; fix OpenClaw pattern to Plugin

https://claude.ai/code/session_01LVeAZGvccG11HfdcBGqECM
@amavashev amavashev merged commit 1f59124 into main Mar 16, 2026
1 check 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.

2 participants