Skip to content

fix: load trace threads for Mustache sections - #276

Open
anticipate218 wants to merge 3 commits into
braintrustdata:mainfrom
anticipate218:fix/js-mustache-thread-tags
Open

anticipate218 wants to merge 3 commits into
braintrustdata:mainfrom
anticipate218:fix/js-mustache-thread-tags

Conversation

@anticipate218

@anticipate218 anticipate218 commented Nov 18, 2026 •

Copy link
Copy Markdown

The JavaScript LLMClassifierFromTemplate and Python LLMClassifier can skip loading a trace when the prompt only references a thread variable through a Mustache section, inverted section, or unescaped tag. For example, {{#user_messages}}{{content}}{{/user_messages}} can render an empty conversation, and an inverted section can incorrectly report that no users are present.

Recognize the #, ^, and & prefixes, including whitespace after the prefix, in the existing thread-variable heuristic. Tests inspect the outgoing model request, exercise both Python sync and async calls, and preserve ordinary/triple-brace references, comment-only templates, and explicit render overrides. Python uses the override handling already merged in #271.

Validation against main b4d93fad00437818797d0c1ed757160a3f062fd2 on Windows, with Python 3.13.5, Node 24.22.1, and pnpm 10.33.0:

  • Python regression file: original implementation 20 failed / 8 passed; fixed implementation 28 passed. Full Python suite: 106 passed / 17 failed; all 17 remaining failures are the same missing-provider-credentials failures on the original implementation.
  • JavaScript regression file: original implementation 5 failed / 5 passed; fixed implementation 10 passed. Full JavaScript suite: 86 passed / 9 failed; the same eight missing-credentials failures and one Windows multiline CJS subprocess failure occur on the original implementation. A direct call to the built CJS ListContains succeeds.
  • Python sdist/wheel and Twine metadata checks pass. The wheel contains the tested Python implementation and templates. CJS, ESM, and TypeScript declaration builds pass.
  • tsc --noEmit reports the same pre-existing js/render-messages.test.ts:227 index-signature error before and after the change.
  • Pinned Black 24.10.0, Ruff 0.12.7, codespell 2.2.1, Prettier 3.3.2, EOF/trailing-whitespace checks, and git diff --check pass. The aggregate pre-commit entry could not initialize its Node environment because nodeenv cannot parse the current prerelease version it selects; its applicable checks were run separately. Local line-ending normalization was verified to preserve Git blob hashes.

The locked development, scipy, and litellm dependencies were installed from the existing package cache after the initial download timed out. The optional documentation extra was not installed. No authenticated live-model evaluation, Linux/macOS run, or full Python-version matrix is claimed.

AI assistance: OpenAI Codex investigated the issue, prepared the changes and tests, and executed these checks. No independent human review is claimed.

@anticipate218 anticipate218 changed the title fix(js): load trace threads for Mustache sections fix: load trace threads for Mustache sections Nov 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant