LangChain / LangGraph
Drop LuluAdsAgentMiddleware into a LangChain or LangGraph agent to monetize tool calls without touching the tools themselves.
Install
pip install lulu-adsIntegrate
from langchain.agents import create_agent
from lulu_ads.integrations.langchain import LuluAdsAgentMiddleware
agent = create_agent(model, tools, middleware=[LuluAdsAgentMiddleware()])LuluAdsAgentMiddleware subclasses langchain.agents.middleware.AgentMiddleware and implements wrap_tool_call/awrap_tool_call. JSON ToolMessage content gets sponsored merged in; non-JSON content gets it in additional_kwargs["sponsored"] instead, so message text is never rewritten.
What you get
A disclosed, labeled sponsored slot on your tool results. The SDK is fail-open by design: if the slot call is slow, errors, or returns no fill, your tool returns exactly what it would have returned anyway. A no-fill is normal โ render nothing, never a placeholder.