langchain-1-error-handling

Sub-skill of langchain: 1. Error Handling (+2).

5 stars

Best use case

langchain-1-error-handling is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Sub-skill of langchain: 1. Error Handling (+2).

Teams using langchain-1-error-handling should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/1-error-handling/SKILL.md --create-dirs "https://raw.githubusercontent.com/vamseeachanta/workspace-hub/main/.agents/skills/_archive/ai/prompting/langchain/1-error-handling/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/1-error-handling/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How langchain-1-error-handling Compares

Feature / Agentlangchain-1-error-handlingStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Sub-skill of langchain: 1. Error Handling (+2).

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 1. Error Handling (+2)

## 1. Error Handling


```python
from langchain_core.runnables import RunnableConfig
from langchain_core.callbacks import CallbackManager
import logging

logger = logging.getLogger(__name__)

def safe_invoke(chain, input_data, max_retries=3):
    """Invoke chain with retry logic."""
    for attempt in range(max_retries):
        try:
            return chain.invoke(input_data)
        except Exception as e:
            logger.warning(f"Attempt {attempt + 1} failed: {e}")
            if attempt == max_retries - 1:
                raise
            time.sleep(2 ** attempt)  # Exponential backoff
```


## 2. Prompt Versioning


```python
from pathlib import Path
import yaml

def load_prompt_template(version: str = "v1"):
    """Load versioned prompt template."""
    prompt_path = Path(f"prompts/{version}.yaml")
    with open(prompt_path) as f:
        config = yaml.safe_load(f)

    return ChatPromptTemplate.from_template(config["template"])
```


## 3. Cost Monitoring


```python
from langchain_community.callbacks import get_openai_callback

def track_costs(chain, input_data):
    """Track API costs for chain invocation."""
    with get_openai_callback() as cb:
        result = chain.invoke(input_data)

    print(f"Total Tokens: {cb.total_tokens}")
    print(f"Prompt Tokens: {cb.prompt_tokens}")
    print(f"Completion Tokens: {cb.completion_tokens}")
    print(f"Total Cost: ${cb.total_cost:.4f}")

    return result, cb
```

Related Skills

tax-form-currency-field-handling

5
from vamseeachanta/workspace-hub

Handle currency field rounding and formatting quirks when entering precise decimal values into tax software forms

diagnose-venv-shebang-import-errors

5
from vamseeachanta/workspace-hub

Debugging pattern for ModuleNotFoundError when CLI entry points use wrong Python interpreter

diagnose-shebang-virtualenv-import-errors

5
from vamseeachanta/workspace-hub

Debugging pattern for ModuleNotFoundError when CLI entry points use wrong Python interpreter

diagnose-shebang-venv-import-errors

5
from vamseeachanta/workspace-hub

Troubleshoot ModuleNotFoundError in CLI tools by identifying shebang-venv mismatches

diagnose-dirty-ntfs-mount-errors

5
from vamseeachanta/workspace-hub

Troubleshoot NTFS mount failures by identifying dirty volume flags and driver type

debug-toml-section-scoping-errors

5
from vamseeachanta/workspace-hub

Diagnose and fix TOML configuration errors caused by misplaced key-value pairs in named sections

batch-syntax-repair-from-injection-errors

5
from vamseeachanta/workspace-hub

Detect and fix systematic syntax errors caused by line-injection scripts that split multiline constructs

bash-pipefail-grep-error-handling

5
from vamseeachanta/workspace-hub

Handle grep exit codes safely under set -eo pipefail by isolating pipeline failure scope

bash-cli-framework-5-error-handling

5
from vamseeachanta/workspace-hub

Sub-skill of bash-cli-framework: 5. Error Handling (+1).

instrument-data-allotrope-calculated-data-handling

5
from vamseeachanta/workspace-hub

Sub-skill of instrument-data-allotrope: Calculated Data Handling.

n8n-4-conditional-branching-and-error-handling

5
from vamseeachanta/workspace-hub

Sub-skill of n8n: 4. Conditional Branching and Error Handling.

activepieces-8-error-handling-and-retry-logic

5
from vamseeachanta/workspace-hub

Sub-skill of activepieces: 8. Error Handling and Retry Logic.