Skip to main content
Applies to:
  • Plan - Any
  • Deployment - Braintrust-hosted
  • LLM calls missing beneath hosted code scorers

Summary

To nest a Gateway LLM call beneath a scorer, export the active span with await currentSpan().export() and pass it as x-bt-parent. If the export is empty, check the scorer’s deployment method before adding the header.

Check the deployment method

A custom script can combine code and dependencies, then upload the result through the REST API as an inline function. This differs from bt functions push, which uploads a bundle referenced by the function definition. Scorers uploaded inline via the REST API return empty span context. Deploying the same scorers with bt functions push provides non-empty context and enables LLM nesting.

Resolution

  1. Define your scorer using the Braintrust SDK.
  2. Push the source file with bt functions push. The CLI handles bundling.
  3. Inside the scorer, export the active span and pass it on the request.
The following snippet belongs inside an existing scorer. It assumes judgePrompt is already defined and uses the hosted runtime’s Gateway configuration.
This is a request snippet, not a complete file to push. See Custom code scorers for a complete scorer definition.

Verify

Run the uploaded scorer through your online scoring rule and check that:
  • The exported context is non-empty.
  • The model request succeeds.
  • The LLM span appears within the scorer’s trace hierarchy. A hosted runtime span may appear between them.
If no scorer span appears, check the automation separately. If the scorer runs but context remains empty, inspect the saved function type (inline or bundle), SDK version, and deployment method. For more information, see Advanced tracing and Gateway logging.