Skip to content

Agent and Model Observation Principles

The application owns the observation boundary. Langfuse exports evidence about actual agent/model operations; it does not decide trading actions or change the model protocol. All model generation remains ordinary OpenAI-compatible text generation, and domain agents retain their own validation, budgets and textual ReAct tools.

Observation identity

A workflow or agent observation contains role/step observations and logical model generations. A generation contains actual network attempts. This separates a user-visible generation from retries without multiplying token/cost counts. Existing GenericAgent wrappers reuse the active generation when the shared model adapter is entered.

Agent and tool scopes describe work the application actually performs. Native provider wrappers record the enclosing CLI invocation. Unknown internal calls, token totals and prices are kept unknown. Model-provided usage is retained as evidence, not reconstructed from character counts or a guessed tokenizer.

Context is explicitly copied into strategy thread-pool submissions. A streamed workflow runs its generator in an independent context on each resume/close, so alternating streams cannot inherit each other's active parent. Exceptions and cancellation end the appropriate observations and release the caller's context.

Export boundary

The optional SDK loads only after explicit enablement and complete endpoint/project configuration. Each application exporter owns a tracer provider and applies the configured sampling rate. Only the application's Langfuse SDK observations are selected for export; unrelated framework and database telemetry is not enabled globally.

Metadata passes an allowlist. Sensitive content is disabled by default. Optional content is filtered and bounded before it reaches SDK attributes. Error status records the exception type without automatically exporting local stack traces or raw provider error bodies. Credentials and local paths are filtered independently of the content option.

Telemetry is best effort. Failure to initialize, begin, update, end or export an observation must preserve the business result and original exception. Batch export avoids a remote round trip at every model return. A lifecycle hook performs bounded shutdown, and configuration status identifies SDK readiness without pretending to validate a live server.

Validation

Real-SDK tests decode actual OTLP/protobuf export messages from a controlled local receiver. They compare the logical generation count with model endpoint requests and network attempt count, examine parent identifiers and usage attributes, and search exported payloads for content/credential/path canaries. Separate regression checks verify that disabled/failing monitoring preserves existing model and agent behavior.

The SDK is pinned to version 4.17.0. Current upstream documentation may discuss later versions, so implemented signatures are verified against the installed package. Live dashboard functionality depends on the configured Langfuse deployment and is a distinct acceptance step.

Sources: Langfuse instrumentation, v4 observation/export semantics, masking and the pinned package.