Skip to content

[bot] Add Outlines integration for structured-generation execution instrumentation #598

Description

@braintrust-bot

Summary

outlines (dottxt-ai) is a widely used structured-generation library: it wraps a model object and constrains decoding so the output matches a requested type (JSON schema, Pydantic model, regex, CFG, Literal, function signature, etc.) via model(prompt, output_type). It supports many backends (OpenAI, Ollama, vLLM, transformers, llama.cpp) and is actively released (latest 1.3.2, July 20, 2026; PyPI: https://pypi.org/project/outlines/). This repository has zero instrumentation for it — no integration directory, no wrapper, no nox session, no matrix entry.

This is a distinct execution surface from the instructor package this repo already instruments (py/src/braintrust/integrations/instructor/): Instructor layers structured output on top of a provider client (e.g. instructor.from_openai(...)), whereas Outlines is itself the model-calling layer and controls token-level decoding directly against local/self-hosted backends (transformers, vLLM, llama.cpp) in addition to hosted APIs — a meaningfully different, provider-agnostic generation call site that Instructor-style patching does not cover.

What needs to be instrumented

  • Model.__call__(prompt, output_type, **kwargs) (or generate(...) in the current API) — the core structured-generation execution entrypoint; should log the prompt, the requested output type/schema, and the returned (parsed) value.
  • Streaming variants (model.stream(...)) where supported by the backend.
  • The output_type used (JSON schema / Pydantic model / regex / CFG / Literal) is worth capturing in span metadata since it materially changes what "correct" output means for eval purposes.
  • Backend/model identification (which underlying model class — outlines.models.openai, outlines.models.transformers, outlines.models.vllm, etc. — is in use) so spans carry accurate provider/model metadata.

Braintrust docs status

not_foundhttps://www.braintrust.dev/docs/guides/tracing/integrations lists tracing integrations (OpenTelemetry, Temporal, Vercel AI SDK, OpenRouter SDK, LangChain, LangSmith, LlamaIndex, Agno, Apollo GraphQL, Cloudflare Workers AI, DSPy, Instructor, LiteLLM, Ruby LLM, Traceloop, TrueFoundry) and agent frameworks — Outlines is not present in either list.

Upstream sources

Local repo files inspected

  • py/src/braintrust/integrations/ — no outlines/ directory (only instructor/, a distinct package/surface)
  • py/src/braintrust/wrappers/ — no Outlines wrapper
  • py/pyproject.toml [tool.braintrust.matrix] — no outlines entry
  • py/noxfile.py — no test_outlines session
  • Repo-wide case-insensitive grep for outlines under py/ — zero matches

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions