Skip to content

Instantly share code, notes, and snippets.

View sydney-runkle's full-sized avatar

Sydney Runkle sydney-runkle

View GitHub Profile
from langchain.tools import ToolRuntime
from typing_extensions import TypedDict
from langchain.agents import create_agent
from langchain.agents.middleware.model_call_limit import (
ModelCallLimitMiddleware,
ModelCallLimitExceededError,
)
from langchain_core.tools import tool
from langchain.agents import create_agent
from langchain.agents.middleware import SummarizationMiddleware
from langchain_community.retrievers import WikipediaRetriever
from langchain_core.tools import tool
retriever = WikipediaRetriever( # type: ignore
top_k_results=1,
doc_content_chars_max=20_000,
)
from langchain.agents import create_agent
from langchain.agents.middleware import ModelFallbackMiddleware
agent = create_agent(
# simulate model failure w/ a typo in the model name (404)
model="anthropic:claude-sonnet-with-typo",
middleware=[
ModelFallbackMiddleware("openai:gpt-4o-with-typo", "openai:gpt-4o-mini")
],
import os
import subprocess
import tempfile
from langchain.agents import create_agent
from langchain.agents.middleware import TodoListMiddleware
from langchain_core.tools import tool
@tool(parse_docstring=True)
@sydney-runkle
sydney-runkle / demo_tool_call_limit.py
Created November 5, 2025 17:30
tool call limit middleware
from langchain.agents import create_agent
from langchain.agents.middleware import ToolCallLimitMiddleware
from langchain_core.tools import tool
@tool(parse_docstring=True)
def search_items(query: str) -> str:
"""Search for items in the store.
Args:
@sydney-runkle
sydney-runkle / demo_human_in_the_loop.py
Last active November 14, 2025 22:56
human in the loop demo
from langchain.agents import create_agent
from langchain_core.tools import tool
from langchain.agents.middleware import HumanInTheLoopMiddleware
@tool(parse_docstring=True)
def send_email(recipient: str, subject: str, body: str) -> str:
"""Send an email to a recipient.
Args: