Skip to content

Framework Auto-Instrumentation

Install

Install only the framework you use:

Terminal window
pip install "briefcase-ai[langchain]==4.4.0"

Extras also exist for crewai, llamaindex, autogen, ag2, pageindex, and openai-agents.

Instrument and undo

from briefcase.auto import auto, undo
from briefcase.exporters import JSONLFileExporter
handler = auto(
"langchain",
exporter=JSONLFileExporter("decisions.jsonl"),
context_version="release-2026-08",
)
# Framework calls now emit the shared 10-field decision-record schema.
undo("langchain")

Calling auto() twice for the same framework returns the existing handler and does not patch again. undo(framework) removes one integration; undo() restores every active patch.

Supported frameworks

NameIntegration point
langchainInjects a callback through runnable configuration
llamaindexAdds a handler to the global callback manager
crewaiRegisters a CrewAI event listener
autogen and ag2Instruments agent creation and event hooks
openai-agentsInstalls the OpenAI Agents trace processor
pageindexWraps PageIndex chat completions

Limits

  • Instrumentation is process-global. Install it during startup and undo it in tests that share an interpreter.
  • A missing framework package raises ImportError; an unknown name raises ValueError with the supported values.
  • Records follow the common wire schema, but each framework exposes different event detail.

API reference

briefcase.auto has the full auto() and undo() signatures and the supported framework names.

Where this fits

Auto-instrumentation is an entry point into the Capture act for applications that build framework callbacks somewhere you cannot reach.