Universal memory for agentic AI. Attach a brain to any LangChain/LangGraph agent in a single line.
Dasein learns from your agent's execution history and automatically injects learned rules to improve performance, reduce costs, and increase reliability across runs.
β¨ Zero-friction integration - Wrap any LangChain or LangGraph agent in one line
π§ Automatic learning - Agents learn from successes and failures
π Performance tracking - Built-in token usage, timing, and success metrics
π Retry logic - Intelligent retry with learned optimizations
π Execution traces - Detailed step-by-step visibility into agent behavior
βοΈ Cloud-powered - Distributed rule synthesis and storage
pip install dasein-coreOr install from source:
git clone https://github.com/nickswami/dasein-core.git
cd dasein-core
pip install -e .π Zero setup required! Try all three examples in your browser:
Three complete examples with automatic learning:
ποΈ SQL Agent β’ π Browser Agent β’ π Deep Research
30-50% token reduction β’ Optimized navigation β’ 20-40% multi-agent savings
from dasein import cognate
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain.agents import create_sql_agent
from langchain_community.agent_toolkits import SQLDatabaseToolkit
# Create your agent as usual
llm = ChatGoogleGenerativeAI(model="gemini-2.5-flash")
toolkit = SQLDatabaseToolkit(db=your_database, llm=llm)
agent = create_sql_agent(llm=llm, toolkit=toolkit, agent_type="tool-calling")
# Wrap with Dasein - that's it!
agent = cognate(agent)
# Use exactly like the original
result = agent.run("Show me the top 5 customers by revenue")from dasein import cognate
# Enable automatic retry and performance comparison
agent = cognate(
your_agent,
retry=2, # Run twice to learn and improve
performance_tracking=True # Show before/after metrics
)
result = agent.run("your query")
# π― Dasein automatically shows improvement metricsfrom dasein import cognate
# Customize what Dasein optimizes for
agent = cognate(
your_agent,
weights={
"w1": 2.0, # Heavily favor successful rules
"w2": 0.5, # Less emphasis on turn count
"w3": 1.0, # Standard uncertainty penalty
"w4": 3.0, # Heavily optimize for token efficiency
"w5": 0.1 # Minimal time emphasis
}
)Dasein uses a cloud-first architecture for rule learning and synthesis:
βββββββββββββββββββ
β Your Agent β
β (LangChain/ β
β LangGraph) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Dasein Wrapper β βββ cognate()
β - Trace Capture β
β - Rule Injectionβ
ββββββββββ¬βββββββββ
β
ββββββ΄βββββ
βΌ βΌ
ββββββββββ ββββββββββ
βPre-Run β βPost-Runβ
βService β βService β
β β β β
βRecalls β βLearns β
βRules β βRules β
ββββββββββ ββββββββββ
- Pre-Run: Dasein queries cloud services for relevant learned rules based on the task
- Execution: Rules are injected into the agent's prompts/tools at optimal injection points
- Trace Capture: Every LLM call, tool invocation, and decision is captured
- Post-Run: Traces are sent to cloud services for rule synthesis and learning
- Next Run: Improved rules are automatically available
Wrap any LangChain/LangGraph agent with Dasein's learning capabilities.
Parameters:
agent- LangChain or LangGraph agent instanceweights(dict) - Custom optimization weights for rule selection (w1-w5)verbose(bool) - Enable detailed debug loggingretry(int) - Number of retries with learning (0 = single run, 2 = run twice with improvement)performance_tracking(bool) - Show before/after performance metricsrule_trace(bool) - Show detailed rule application trace
Returns: Wrapped agent with identical interface to the original
Display the execution trace of the last agent run.
Retrieve the execution trace as a list of dictionaries.
Returns: List[Dict] - Trace steps with timestamps, tokens, and decisions
Clear the current execution trace.
Manually inject a hint/rule for the next agent run.
Parameters:
hint(str) - The hint text to inject
Clear all local state and event storage.
- β LangChain Agents (all agent types)
- β LangGraph Agents (CompiledStateGraph)
- β Custom agents implementing standard interfaces
See the examples/ directory for complete examples:
- SQL Agent - Learn query patterns for a Chinook database
- Browser Agent - Learn web scraping strategies
- Research Agent - Multi-agent research coordination
For debugging, enable verbose logging:
agent = cognate(your_agent, verbose=True)This shows detailed information about:
- Rule retrieval from cloud services
- Rule injection points and content
- Trace capture steps
- Post-run learning triggers
- Python 3.8+
- LangChain 0.1.0+
- LangChain Community 0.1.0+
- LangChain Google GenAI 0.0.6+
See pyproject.toml for complete dependency list.
Dasein uses cloud services for rule synthesis and storage. Configure service endpoints via environment variables:
export DASEIN_PRE_RUN_URL="https://your-pre-run-service.com"
export DASEIN_POST_RUN_URL="https://your-post-run-service.com"Contact the Dasein team for cloud service access.
Dasein is designed for minimal overhead:
- Pre-run: ~100-200ms for rule retrieval
- Runtime: <1% overhead for trace capture
- Post-run: Async - doesn't block your code
The benefits far outweigh the costs:
- π― 30-50% token reduction on repeated tasks
- π― Fewer failed runs through learned error handling
- π― Faster execution with optimized tool usage
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
MIT License - see LICENSE file for details.
Q: I see timeout warnings for dasein-pre-run and dasein-post-run services
A: These warnings can appear on first connection while the cloud services wake up (cold start). The services are fully public and will work after a brief initialization period. Your agent will continue running and learning will activate automatically once the services respond.
Q: I see dependency conflict warnings
A: These are safe to ignore in Colab. The package will work correctly despite version mismatches with Colab's pre-installed packages.
- π Issues: GitHub Issues
If you use Dasein in your research, please cite:
@software{dasein2025,
title={Dasein: Universal Memory for Agentic AI},
author={Dasein Team},
year={2025},
url={https://github.com/nickswami/dasein-core}
}Built with β€οΈ for the agentic AI community