LangChain Integration¶
Integrate Zubbl with LangChain agents.
Setup¶
Wrapping a LangChain Agent¶
from langchain.agents import create_openai_tools_agent
from zubbl import ZubblClient
zubbl = ZubblClient(api_key="zubbl_xxx")
# Create your LangChain agent
agent = create_openai_tools_agent(llm, tools, prompt)
# Wrap it with Zubbl
smart_agent = zubbl.wrap(agent)
# Use as normal — Zubbl records and learns
result = smart_agent.invoke({"input": "Analyze this codebase"})
Manual Integration¶
# Get recommendations before running
policies = zubbl.query(task_type="code_analysis")
# Inject into agent prompt
enhanced_prompt = f"{base_prompt}\n\nRecommended strategies:\n"
for p in policies:
enhanced_prompt += f"- {p.pattern}: {p.description}\n"
# Run and record
result = agent.invoke({"input": task})
zubbl.ingest(
trajectory_id=str(uuid4()),
task_description=task,
steps=extract_steps(result),
status="success" if result else "failure",
)