--- name: llm-application-dev-langchain-agent description: "LangChain/LangGraph Agent Development Expert workflow skill. Use this skill when the user needs You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off." version: "0.0.1" category: ai-agents tags: ["llm-application-dev-langchain-agent", "you", "are", "expert", "langchain", "developer", "specializing", "production-grade"] complexity: advanced risk: caution tools: ["codex-cli", "claude-code", "cursor", "gemini-cli", "opencode"] source: community author: "sickn33" date_added: "2026-04-15" date_updated: "2026-04-25" --- # LangChain/LangGraph Agent Development Expert ## Overview This public intake copy packages `plugins/antigravity-awesome-skills-claude/skills/llm-application-dev-langchain-agent` from `https://github.com/sickn33/antigravity-awesome-skills` into the native Omni Skills editorial shape without hiding its origin. Use it when the operator needs the upstream workflow, support files, and repository context to stay intact while the public validator and private enhancer continue their normal downstream flow. This intake keeps the copied upstream files intact and uses the `external_source` block in `metadata.json` plus `ORIGIN.md` as the provenance anchor for review. # LangChain/LangGraph Agent Development Expert You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph. Imported source sections that did not map cleanly to the public headings are still preserved below or in the support files. Notable imported sections: Context, Core Requirements, Essential Architecture, Agent Types, Memory Systems, RAG Pipeline. ## When to Use This Skill Use this section as the trigger filter. It should make the activation boundary explicit before the operator loads files, runs commands, or opens a pull request. - Working on langchain/langgraph agent development expert tasks or workflows - Needing guidance, best practices, or checklists for langchain/langgraph agent development expert - The task is unrelated to langchain/langgraph agent development expert - You need a different domain or tool outside this scope - Use when the request clearly matches the imported source intent: You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph. - Use when the operator should preserve upstream workflow detail instead of rewriting the process from scratch. ## Operating Table | Situation | Start here | Why it matters | | --- | --- | --- | | First-time use | `metadata.json` | Confirms repository, branch, commit, and imported path through the `external_source` block before touching the copied workflow | | Provenance review | `ORIGIN.md` | Gives reviewers a plain-language audit trail for the imported source | | Workflow execution | `SKILL.md` | Starts with the smallest copied file that materially changes execution | | Supporting context | `SKILL.md` | Adds the next most relevant copied source file without loading the entire package | | Handoff decision | `## Related Skills` | Helps the operator switch to a stronger native skill when the task drifts | ## Workflow This workflow is intentionally editorial and operational at the same time. It keeps the imported source useful to the operator while still satisfying the public intake standards that feed the downstream enhancer flow. 1. Clarify goals, constraints, and required inputs. 2. Apply relevant best practices and validate outcomes. 3. Provide actionable steps and verification. 4. If detailed examples are required, open resources/implementation-playbook.md. 5. Confirm the user goal, the scope of the imported workflow, and whether this skill is still the right router for the task. 6. Read the overview and provenance files before loading any copied upstream support files. 7. Load only the references, examples, prompts, or scripts that materially change the outcome for the current request. ### Imported Workflow Notes #### Imported: Instructions - Clarify goals, constraints, and required inputs. - Apply relevant best practices and validate outcomes. - Provide actionable steps and verification. - If detailed examples are required, open `resources/implementation-playbook.md`. #### Imported: Context Build sophisticated AI agent system for: $ARGUMENTS ## Examples ### Example 1: Ask for the upstream workflow directly ```text Use @llm-application-dev-langchain-agent to handle . Start from the copied upstream workflow, load only the files that change the outcome, and keep provenance visible in the answer. ``` **Explanation:** This is the safest starting point when the operator needs the imported workflow, but not the entire repository. ### Example 2: Ask for a provenance-grounded review ```text Review @llm-application-dev-langchain-agent against metadata.json and ORIGIN.md, then explain which copied upstream files you would load first and why. ``` **Explanation:** Use this before review or troubleshooting when you need a precise, auditable explanation of origin and file selection. ### Example 3: Narrow the copied support files before execution ```text Use @llm-application-dev-langchain-agent for . Load only the copied references, examples, or scripts that change the outcome, and name the files explicitly before proceeding. ``` **Explanation:** This keeps the skill aligned with progressive disclosure instead of loading the whole copied package by default. ### Example 4: Build a reviewer packet ```text Review @llm-application-dev-langchain-agent using the copied upstream files plus provenance, then summarize any gaps before merge. ``` **Explanation:** This is useful when the PR is waiting for human review and you want a repeatable audit packet. ## Best Practices Treat the generated public skill as a reviewable packaging layer around the upstream repository. The goal is to keep provenance explicit and load only the copied source material that materially improves execution. - Always use async: ainvoke, astream, agetrelevantdocuments - Handle errors gracefully: Try/except with fallbacks - Monitor everything: Trace, log, and metric all operations - Optimize costs: Cache responses, use token limits, compress memory - Secure secrets: Environment variables, never hardcode - Test thoroughly: Unit tests, integration tests, evaluation suites - Document extensively: API docs, architecture diagrams, runbooks ### Imported Operating Notes #### Imported: Best Practices 1. **Always use async**: `ainvoke`, `astream`, `aget_relevant_documents` 2. **Handle errors gracefully**: Try/except with fallbacks 3. **Monitor everything**: Trace, log, and metric all operations 4. **Optimize costs**: Cache responses, use token limits, compress memory 5. **Secure secrets**: Environment variables, never hardcode 6. **Test thoroughly**: Unit tests, integration tests, evaluation suites 7. **Document extensively**: API docs, architecture diagrams, runbooks 8. **Version control state**: Use checkpointers for reproducibility --- Build production-ready, scalable, and observable LangChain agents following these patterns. ## Troubleshooting ### Problem: The operator skipped the imported context and answered too generically **Symptoms:** The result ignores the upstream workflow in `plugins/antigravity-awesome-skills-claude/skills/llm-application-dev-langchain-agent`, fails to mention provenance, or does not use any copied source files at all. **Solution:** Re-open `metadata.json`, `ORIGIN.md`, and the most relevant copied upstream files. Check the `external_source` block first, then restate the provenance before continuing. ### Problem: The imported workflow feels incomplete during review **Symptoms:** Reviewers can see the generated `SKILL.md`, but they cannot quickly tell which references, examples, or scripts matter for the current task. **Solution:** Point at the exact copied references, examples, scripts, or assets that justify the path you took. If the gap is still real, record it in the PR instead of hiding it. ### Problem: The task drifted into a different specialization **Symptoms:** The imported skill starts in the right place, but the work turns into debugging, architecture, design, security, or release orchestration that a native skill handles better. **Solution:** Use the related skills section to hand off deliberately. Keep the imported provenance visible so the next skill inherits the right context instead of starting blind. ## Related Skills - `@00-andruia-consultant` - Use when the work is better handled by that native specialization after this imported skill establishes context. - `@00-andruia-consultant-v2` - Use when the work is better handled by that native specialization after this imported skill establishes context. - `@10-andruia-skill-smith` - Use when the work is better handled by that native specialization after this imported skill establishes context. - `@10-andruia-skill-smith-v2` - Use when the work is better handled by that native specialization after this imported skill establishes context. ## Additional Resources Use this support matrix and the linked files below as the operator packet for this imported skill. They should reflect real copied source material, not generic scaffolding. | Resource family | What it gives the reviewer | Example path | | --- | --- | --- | | `references` | copied reference notes, guides, or background material from upstream | `references/n/a` | | `examples` | worked examples or reusable prompts copied from upstream | `examples/n/a` | | `scripts` | upstream helper scripts that change execution or validation | `scripts/n/a` | | `agents` | routing or delegation notes that are genuinely part of the imported package | `agents/n/a` | | `assets` | supporting assets or schemas copied from the source package | `assets/n/a` | ### Imported Reference Notes #### Imported: Core Requirements - Use latest LangChain 0.1+ and LangGraph APIs - Implement async patterns throughout - Include comprehensive error handling and fallbacks - Integrate LangSmith for observability - Design for scalability and production deployment - Implement security best practices - Optimize for cost efficiency #### Imported: Essential Architecture ### LangGraph State Management ```python from langgraph.graph import StateGraph, MessagesState, START, END from langgraph.prebuilt import create_react_agent from langchain_anthropic import ChatAnthropic class AgentState(TypedDict): messages: Annotated[list, "conversation history"] context: Annotated[dict, "retrieved context"] ``` ### Model & Embeddings - **Primary LLM**: Claude Sonnet 4.5 (`claude-sonnet-4-5`) - **Embeddings**: Voyage AI (`voyage-3-large`) - officially recommended by Anthropic for Claude - **Specialized**: `voyage-code-3` (code), `voyage-finance-2` (finance), `voyage-law-2` (legal) #### Imported: Agent Types 1. **ReAct Agents**: Multi-step reasoning with tool usage - Use `create_react_agent(llm, tools, state_modifier)` - Best for general-purpose tasks 2. **Plan-and-Execute**: Complex tasks requiring upfront planning - Separate planning and execution nodes - Track progress through state 3. **Multi-Agent Orchestration**: Specialized agents with supervisor routing - Use `Command[Literal["agent1", "agent2", END]]` for routing - Supervisor decides next agent based on context #### Imported: Memory Systems - **Short-term**: `ConversationTokenBufferMemory` (token-based windowing) - **Summarization**: `ConversationSummaryMemory` (compress long histories) - **Entity Tracking**: `ConversationEntityMemory` (track people, places, facts) - **Vector Memory**: `VectorStoreRetrieverMemory` with semantic search - **Hybrid**: Combine multiple memory types for comprehensive context #### Imported: RAG Pipeline ```python from langchain_voyageai import VoyageAIEmbeddings from langchain_pinecone import PineconeVectorStore # Setup embeddings (voyage-3-large recommended for Claude) embeddings = VoyageAIEmbeddings(model="voyage-3-large") # Vector store with hybrid search vectorstore = PineconeVectorStore( index=index, embedding=embeddings ) # Retriever with reranking base_retriever = vectorstore.as_retriever( search_type="hybrid", search_kwargs={"k": 20, "alpha": 0.5} ) ``` ### Advanced RAG Patterns - **HyDE**: Generate hypothetical documents for better retrieval - **RAG Fusion**: Multiple query perspectives for comprehensive results - **Reranking**: Use Cohere Rerank for relevance optimization #### Imported: Tools & Integration ```python from langchain_core.tools import StructuredTool from pydantic import BaseModel, Field class ToolInput(BaseModel): query: str = Field(description="Query to process") async def tool_function(query: str) -> str: # Implement with error handling try: result = await external_call(query) return result except Exception as e: return f"Error: {str(e)}" tool = StructuredTool.from_function( func=tool_function, name="tool_name", description="What this tool does", args_schema=ToolInput, coroutine=tool_function ) ``` #### Imported: Production Deployment ### FastAPI Server with Streaming ```python from fastapi import FastAPI from fastapi.responses import StreamingResponse @app.post("/agent/invoke") async def invoke_agent(request: AgentRequest): if request.stream: return StreamingResponse( stream_response(request), media_type="text/event-stream" ) return await agent.ainvoke({"messages": [...]}) ``` ### Monitoring & Observability - **LangSmith**: Trace all agent executions - **Prometheus**: Track metrics (requests, latency, errors) - **Structured Logging**: Use `structlog` for consistent logs - **Health Checks**: Validate LLM, tools, memory, and external services ### Optimization Strategies - **Caching**: Redis for response caching with TTL - **Connection Pooling**: Reuse vector DB connections - **Load Balancing**: Multiple agent workers with round-robin routing - **Timeout Handling**: Set timeouts on all async operations - **Retry Logic**: Exponential backoff with max retries #### Imported: Testing & Evaluation ```python from langsmith.evaluation import evaluate # Run evaluation suite eval_config = RunEvalConfig( evaluators=["qa", "context_qa", "cot_qa"], eval_llm=ChatAnthropic(model="claude-sonnet-4-5") ) results = await evaluate( agent_function, data=dataset_name, evaluators=eval_config ) ``` #### Imported: Key Patterns ### State Graph Pattern ```python builder = StateGraph(MessagesState) builder.add_node("node1", node1_func) builder.add_node("node2", node2_func) builder.add_edge(START, "node1") builder.add_conditional_edges("node1", router, {"a": "node2", "b": END}) builder.add_edge("node2", END) agent = builder.compile(checkpointer=checkpointer) ``` ### Async Pattern ```python async def process_request(message: str, session_id: str): result = await agent.ainvoke( {"messages": [HumanMessage(content=message)]}, config={"configurable": {"thread_id": session_id}} ) return result["messages"][-1].content ``` ### Error Handling Pattern ```python from tenacity import retry, stop_after_attempt, wait_exponential @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10)) async def call_with_retry(): try: return await llm.ainvoke(prompt) except Exception as e: logger.error(f"LLM error: {e}") raise ``` #### Imported: Implementation Checklist - [ ] Initialize LLM with Claude Sonnet 4.5 - [ ] Setup Voyage AI embeddings (voyage-3-large) - [ ] Create tools with async support and error handling - [ ] Implement memory system (choose type based on use case) - [ ] Build state graph with LangGraph - [ ] Add LangSmith tracing - [ ] Implement streaming responses - [ ] Setup health checks and monitoring - [ ] Add caching layer (Redis) - [ ] Configure retry logic and timeouts - [ ] Write evaluation tests - [ ] Document API endpoints and usage #### Imported: Limitations - Use this skill only when the task clearly matches the scope described above. - Do not treat the output as a substitute for environment-specific validation, testing, or expert review. - Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.