trulens
AGENTS.md3.6k starsChanged 7 months agoMITView on GitHub
Enable optional tests: TEST_OPTIONAL=true Before submitting a pull request, confirm it includes this checked certification:
- Reads credentials
Trending
Quiet since September.about the whole repository
Who's talking about truera/trulens
- A Hacker News story“Stop Evaluating LLMs on Vibes”Hacker News · Jun 7, 2023 · 35 points
- A Hacker News story“Evaluate and Track Your LLM Experiments: Introducing TruLens for LLMs”Hacker News · May 24, 2023 · 25 points
- guevara/read-it-later“高级 RAG 技术图解概览 [译]”GitHub · Feb 19, 2024 · 1 reactions
- adhabnr-ux/evalport“Adapter: TruLens (trulens-core) standalone adapter”GitHub · Sep 19, 2026
- Abelo9996/abelo9996.github.io“Add 2026 research progress (publications, open source, awards, metadata)”GitHub · Sep 17, 2026
The biggest 5 of 23 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 23
Talked about on GitHub and Hacker News (23 times).
On GitHub · 21
- Feb 19, 2024高级 RAG 技术图解概览 [译] — guevara/read-it-later1 reaction
- Sep 19, 2026Adapter: TruLens (trulens-core) standalone adapter — adhabnr-ux/evalport0 reactions
- Sep 17, 2026Add 2026 research progress (publications, open source, awards, metadata) — Abelo9996/abelo9996.github.io0 reactions
- Sep 8, 2026Weekly link audit needs attention — yzhao062/awesome-auditable-ai0 reactions
- Aug 25, 2026Bump trulens-apps-llamaindex from 2.13.0 to 2.13.1 — wahidur028/Legal-Query-RAG0 reactions · 1 comment
16 more on GitHub
- Aug 13, 2026Weekly link audit needs attention — yzhao062/awesome-auditable-ai0 reactions · 1 comment
- Aug 7, 2026research: индустриальные практики оценки качества AI-агентов (Agentic Evaluation, Evals, Golden Sets) — G-Ivan-A/hybrid-Intelligence-lab0 reactions
- Jun 27, 2026research: document baseline RAG pipeline and readiness signals — 1104030360/Systograph0 reactions · 1 comment
- Jun 4, 2026feat(content): add trulens — JSONbored/awesome-claude0 reactions · 2 comments
- May 14, 2026Add TruLens, LMDeploy, and LangWatch to catalog — nimit2801/Agentic-AI-For-Good0 reactions · 2 comments
- Feb 22, 2026Add blog post: Agent Trace Evaluation with TruLens Scorers in MLflow — mlflow/mlflow-website0 reactions · 7 comments
- Dec 11, 2025Add TruLens agent trace scorers for goal-plan-action alignment evaluation — mlflow/mlflow0 reactions · 7 comments
- Jun 8, 2025Implement comprehensive evaluation of LLM answers using TruLens or similar tool — mkahe/finance-rag0 reactions
- Oct 17, 2024trulens-providers-cortex 1.1.0 :snowflake: — AnacondaRecipes/trulens-providers-cortex-feedstock0 reactions
- Oct 17, 2024trulens-connectors-snowflake 1.1.0 :snowflake: — AnacondaRecipes/trulens-connectors-snowflake-feedstock0 reactions · 1 comment
- Oct 10, 2024trulens-feedback 1.0.7 :snowflake: — AnacondaRecipes/trulens-feedback-feedstock0 reactions · 7 comments
- Oct 10, 2024trulens-core 1.0.7 :snowflake: — AnacondaRecipes/trulens-core-feedstock0 reactions · 7 comments
- Jul 15, 2024[Documentation]: Broken 'Examples' Link — run-llama/llama_index0 reactions · 3 comments
- Mar 10, 2024Update README.md — MunGell/awesome-for-beginners0 reactions · 1 comment
- Dec 15, 2023Priority Task : start using trulens to evaluate Gemini — Josephrp/DataTonic0 reactions · 6 comments
- Nov 22, 2023TBD - Products to add — e2b-dev/awesome-ai-sdks0 reactions
On Hacker News · 2
- Jun 7, 2023Stop Evaluating LLMs on Vibes35 points · 7 comments
- May 24, 2023Evaluate and Track Your LLM Experiments: Introducing TruLens for LLMs25 points · 7 comments
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- docs/llms.txtllms.txt
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
23 rules. About 0 are common, 4 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Start documentation server: make docs-serve
- Distinctive: line 16
Import modules, not classes directly:
- Very specific: line 36
Use TYPE_CHECKING blocks for type-only imports
- Very specific: line 37
Use from __future__ import annotations for forward references
- Very specific: line 38
Call model_rebuild() after Pydantic models with forward refs
- Very specific: line 42
Run all unit tests: make test-unit
- Very specific: line 43
Run single test file: TEST_OPTIONAL=true poetry run pytest tests/unit/test_file.py -v
- Very specific: line 44
Run specific test: TEST_OPTIONAL=true poetry run pytest tests/unit/test_file.py::TestClass::test_method
- Distinctive: line 58
Before submitting a pull request, confirm it includes this checked certification:
- Very specific: line 71
Update poetry locks: make lock
- Very specific: line 119
Do not set TRULENS_OTEL_TRACING=1 - is_otel_tracing_enabled() returns True unless the variable is explicitly "0" or "false", so "1" is a …
- Very specific: line 121
Do not pass Feature.OTEL_TRACING to TruSession - it is set and frozen to True during setup whenever tracing is enabled, so passing it is …
- Very specific: line 139
Use span_type to categorize spans for semantic meaning:
- Very specific: line 205
Use instrument_method() when you can't modify source code:
- Very specific: line 243
Use Selector to explicitly select instrumented span attributes for evaluation:
- Very specific: line 306
Create src/providers/<name>/ with pyproject.toml
- Distinctive: line 309
Add endpoint class for API interactions
- Very specific: line 318
Add a prompt template class to the appropriate templates/ domain file (e.g.
- Very specific: line 321
Add the evaluation method to the provider class or LLMProvider
- Distinctive: line 323
Add Google-style docstring with example
- Very specific: line 324
Add re-exports to templates/__init__.py, and to prompts.py / v2/feedback.py shims if needed for backward compat
- Very specific: line 329
Circular imports: Use from __future__ import annotations and TYPE_CHECKING blocks
- Very specific: line 331
No spans recorded / evaluations find nothing: check for a leftover TRULENS_OTEL_TRACING=0 in the shell or .env.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Setup commands
- Install deps:
poetry install - Install with dev tools:
poetry install --with dev - Install with all optional packages:
poetry install --with dev,apps,providers - Install pre-commit hooks:
pre-commit install - Start documentation server:
make docs-serve
Code style
- Line length: 80 characters
- Formatter/linter:
ruff(runmake formatandmake lint) - Google-style docstrings
- Import modules, not classes directly:
# ✓ Do this from trulens.schema import record as record_schema from trulens.providers.openai import provider as openai_provider # ✗ Not this from trulens.schema.record import Record - Standard module rename patterns:
from trulens.schema import X as X_schema from trulens.utils import X as X_utils from trulens.providers.X import provider as X_provider from trulens.apps.X import Y as Y_app from trulens.core import X as core_X from trulens.core.database import base as core_db from trulens.feedback.templates import rag as templates_rag from trulens.feedback.templates import base as templates_base - Use
TYPE_CHECKINGblocks for type-only imports - Use
from __future__ import annotationsfor forward references - Call
model_rebuild()after Pydantic models with forward refs
Testing instructions
- Run all unit tests:
make test-unit - Run single test file:
TEST_OPTIONAL=true poetry run pytest tests/unit/test_file.py -v - Run specific test:
TEST_OPTIONAL=true poetry run pytest tests/unit/test_file.py::TestClass::test_method - OTEL tests require isolation (uses pytest-xdist):
TEST_OPTIONAL=1 poetry run pytest tests/unit/test_otel*.py -n auto --dist=loadscope - Regenerate golden files:
WRITE_GOLDEN=1 TEST_OPTIONAL=1 poetry run pytest <test_path>
Test markers
@pytest.mark.optional- requires optional dependencies@pytest.mark.snowflake- requires Snowflake credentials@pytest.mark.huggingface- requires HuggingFace access
Enable optional tests: TEST_OPTIONAL=true
Pull request certification
Before submitting a pull request, confirm it includes this checked certification:
## Certification
- [x] This change follows the TruLens standards (https://www.trulens.org/contributing/standards/)Build commands
- Format code:
make format - Lint code:
make lint - Build all packages:
make build - Build docs:
make docs - Update poetry locks:
make lock - Generate coverage:
make coverage
Project structure
src/
├── core/ # trulens-core: Core abstractions, session, database
├── feedback/ # trulens-feedback: Feedback function implementations
│ ├── templates/ # Prompt template classes organized by domain:
│ │ ├── base.py # FeedbackTemplate base class, shared scaffolding
│ │ ├── rag.py # RAG evals (Groundedness, ContextRelevance, …)
│ │ ├── safety.py # Moderation (Harmfulness, Toxicity, …)
│ │ ├── quality.py # Text quality (Coherence, Sentiment, …)
│ │ └── agent.py # Agentic evals (ToolSelection, PlanAdherence, …)
│ ├── llm_provider.py # LLMProvider base — orchestrates template → LLM calls
│ ├── v2/ # Backward-compat shim (re-exports from templates/)
│ └── prompts.py # Backward-compat shim (re-exports from templates/)
├── dashboard/ # trulens-dashboard: Streamlit UI + React components
├── apps/ # App integrations (langchain, langgraph, llamaindex)
├── providers/ # LLM providers (openai, bedrock, cortex, huggingface, litellm)
├── connectors/ # Database connectors (snowflake)
└── otel/semconv/ # OpenTelemetry semantic conventionsKey patterns
TruSession (main entry point)
from trulens.core import TruSession
session = TruSession() # Default SQLite
session = TruSession(database_url="postgresql://...")App wrappers
from trulens.apps.langchain import TruChain
tru_app = TruChain(chain, app_name="MyApp", app_version="v1", feedbacks=[...])
with tru_app as recording:
result = chain.invoke("query")OTEL instrumentation
OTEL tracing is enabled by default. There is nothing to turn on:
- Do not set
TRULENS_OTEL_TRACING=1-is_otel_tracing_enabled()returnsTrueunless the variable is explicitly"0"or"false", so"1"is a no-op. - Do not pass
Feature.OTEL_TRACINGtoTruSession- it is set and frozen toTrueduring setup whenever tracing is enabled, so passing it is redundant.
The variable is only useful for disabling tracing. Disabling it logs a warning, because the symptom is otherwise an absence of spans rather than an error.
Basic instrumentation - captures function args and return as span attributes:
from trulens.core.otel.instrument import instrument
@instrument()
def my_function():
pass # Automatically tracedSpan types
Use span_type to categorize spans for semantic meaning:
from trulens.core.otel.instrument import instrument
from trulens.otel.semconv.trace import SpanAttributes
@instrument(span_type=SpanAttributes.SpanType.RETRIEVAL)
def retrieve(self, query: str) -> list:
pass
@instrument(span_type=SpanAttributes.SpanType.GENERATION)
def generate(self, prompt: str) -> str:
passAvailable span types: RETRIEVAL, GENERATION, RERANKING, TOOL, AGENT, WORKFLOW, GRAPH_NODE, GRAPH_TASK, MCP, GUARDRAIL, RECORD_ROOT, EVAL_ROOT, UNKNOWN
Custom span attributes
Map function args/return to semantic attributes:
@instrument(
span_type=SpanAttributes.SpanType.RETRIEVAL,
attributes={
SpanAttributes.RETRIEVAL.QUERY_TEXT: "query", # maps "query" arg
SpanAttributes.RETRIEVAL.RETRIEVED_CONTEXTS: "return", # maps return value
},
)
def retrieve(self, query: str) -> list:
return ["context1", "context2"]Common attribute namespaces:
SpanAttributes.RETRIEVAL-QUERY_TEXT,RETRIEVED_CONTEXTS,NUM_CONTEXTSSpanAttributes.RECORD_ROOT-INPUT,OUTPUT,ERRORSpanAttributes.MCP-TOOL_NAME,SERVER_NAME,INPUT_ARGUMENTS,OUTPUT_CONTENTSpanAttributes.RERANKING-QUERY_TEXT,MODEL_NAME,TOP_N,INPUT_CONTEXT_TEXTS
Manipulating attributes with lambdas
For complex data extraction, use a lambda with signature (ret, exception, *args, **kwargs):
@instrument(
attributes=lambda ret, exception, *args, **kwargs: {
SpanAttributes.RETRIEVAL.RETRIEVED_CONTEXTS: [
doc["text"] for doc in ret
],
SpanAttributes.RETRIEVAL.QUERY_TEXT: kwargs["query"].upper(),
}
)
def retrieve_contexts(self, query: str) -> list:
return [
{"text": "ctx1", "source": "doc.pdf"},
{"text": "ctx2", "source": "doc2.pdf"},
]Lambda parameters:
ret- function return valueexception- any exception raised (None if successful)*args- positional arguments**kwargs- keyword arguments (includes positional args by name)
Instrumenting third-party classes
Use instrument_method() when you can't modify source code:
from trulens.core.otel.instrument import instrument_method
from somepackage import CustomRetriever
instrument_method(
cls=CustomRetriever,
method_name="retrieve",
span_type=SpanAttributes.SpanType.RETRIEVAL,
attributes={
SpanAttributes.RETRIEVAL.QUERY_TEXT: "query",
SpanAttributes.RETRIEVAL.RETRIEVED_CONTEXTS: "return",
},
)Evaluation
Feedback functions evaluate LLM app quality. Must return float in [0.0, 1.0] or dict[str, float].
Basic usage with shortcuts
from trulens.core import Feedback
from trulens.providers.openai import OpenAI
provider = OpenAI()
f_relevance = (
Feedback(provider.relevance_with_cot_reasons).on_input().on_output()
)Shortcuts:
on_input()- selectsRECORD_ROOT.INPUTon_output()- selectsRECORD_ROOT.OUTPUTon_context()- selectsRETRIEVAL.RETRIEVED_CONTEXTS
Selecting span attributes with Selector
Use Selector to explicitly select instrumented span attributes for evaluation:
from trulens.core import Feedback
from trulens.core.feedback.selector import Selector
from trulens.otel.semconv.trace import SpanAttributes
f_answer_relevance = (
Feedback(provider.relevance_with_cot_reasons, name="Answer Relevance")
.on({
"prompt": Selector(
span_type=SpanAttributes.SpanType.RECORD_ROOT,
span_attribute=SpanAttributes.RECORD_ROOT.INPUT,
),
})
.on({
"response": Selector(
span_type=SpanAttributes.SpanType.RECORD_ROOT,
span_attribute=SpanAttributes.RECORD_ROOT.OUTPUT,
),
})
)Using collect_list for retrieved contexts
collect_list=False- evaluate each context individually (for context relevance)collect_list=True- concatenate all contexts for single evaluation (for groundedness)
# Evaluate each retrieved context individually
f_context_relevance = (
Feedback(
provider.context_relevance_with_cot_reasons, name="Context Relevance"
)
.on_input()
.on({
"context": Selector(
span_type=SpanAttributes.SpanType.RETRIEVAL,
span_attribute=SpanAttributes.RETRIEVAL.RETRIEVED_CONTEXTS,
collect_list=False,
),
})
)
# Evaluate groundedness against all contexts combined
f_groundedness = (
Feedback(
provider.groundedness_measure_with_cot_reasons, name="Groundedness"
)
.on({
"context": Selector(
span_type=SpanAttributes.SpanType.RETRIEVAL,
span_attribute=SpanAttributes.RETRIEVAL.RETRIEVED_CONTEXTS,
collect_list=True,
),
})
.on_output()
)Adding new components
New provider
- Create
src/providers/<name>/withpyproject.toml - Extend
trulens.feedback.LLMProvider - Implement
_create_chat_completion(self, prompt, messages, **kwargs) - Add endpoint class for API interactions
New app integration
- Create
src/apps/<name>/withpyproject.toml - Extend
trulens.core.app.App - Define
Default.CLASSESandDefault.METHODSfor instrumentation - Implement
main_input()andmain_output()methods
New feedback function
- Add a prompt template class to the appropriate
templates/domain file (e.g.rag.py,safety.py)- Extend the relevant base (e.g.
Semantics,WithPrompt,CriteriaOutputSpaceMixin) - Define
system_prompt,user_prompt,criteria_template, andoutput_space
- Extend the relevant base (e.g.
- Add the evaluation method to the provider class or
LLMProvider - Return float [0, 1] or dict of floats
- Add Google-style docstring with example
- Add re-exports to
templates/__init__.py, and toprompts.py/v2/feedback.pyshims if needed for backward compat - Add tests
Troubleshooting
- Circular imports: Use
from __future__ import annotationsandTYPE_CHECKINGblocks - OTEL tests failing in batch: Install pytest-xdist (
poetry install --with dev) and usemake test-unit - No spans recorded / evaluations find nothing: check for a leftover
TRULENS_OTEL_TRACING=0in the shell or.env; tracing is on by default and disabling it logs a warning - Missing optional deps: TruLens uses lazy imports - install specific packages as needed
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

