fix(prompt): preserve nested media interpolation - #4290
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (2)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughPrompt tagged-template assembly now runs in the BEX VM, preserving roles and nested media while applying ChangesPrompt AST media assembly
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Binary size checks passed✅ 7 passed
Generated by |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
baml_language/crates/bex_vm/src/package_baml/llm.rs (1)
16-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd unit tests for
PromptContentSink::push_text's merge logic.This adjacent-string-merging logic (and the
Arc::try_unwrapfallback path) is pure, VM-independent, and easy to unit-test in isolation, but no#[cfg(test)]coverage was added here — coverage is deferred to the integration-stylebaml_testscrate (layer 4). As per coding guidelines,**/*.rschanges should prefer unit tests over integration tests where possible.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@baml_language/crates/bex_vm/src/package_baml/llm.rs` around lines 16 - 59, Add focused unit tests in the module containing PromptContentSink, under a #[cfg(test)] section, covering push_text merging consecutive string parts, preserving non-string parts while appending text, and handling shared Arc values through the Arc::try_unwrap fallback. Keep the tests VM-independent and assert the resulting PromptAstSimple structure after into_content.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/crates/bex_vm/src/package_baml/llm.rs`:
- Around line 61-79: Update prompt_role_name and the role-marker handling in
finish() to extract and propagate both Role.name and Role.metadata, returning
metadata converted with the existing json::value_to_serde helper. Use the
extracted metadata in both PromptAst::Message constructions instead of
serde_json::Value::Null, while preserving null metadata for non-role messages.
---
Nitpick comments:
In `@baml_language/crates/bex_vm/src/package_baml/llm.rs`:
- Around line 16-59: Add focused unit tests in the module containing
PromptContentSink, under a #[cfg(test)] section, covering push_text merging
consecutive string parts, preserving non-string parts while appending text, and
handling shared Arc values through the Arc::try_unwrap fallback. Keep the tests
VM-independent and assert the resulting PromptAstSimple structure after
into_content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d1b07f3a-2a3b-47fe-b0f6-ae01efa3ce35
⛔ Files ignored due to path filters (9)
baml_language/Cargo.lockis excluded by!**/*.lockbaml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_namespace_llm.snapis excluded by!**/*.snapbaml_language/crates/baml_cli/src/snapshots/baml_cli__describe_command_tests__render_builtin_package_listing.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/baml_src/prompt_tag_runtime.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_ppir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_tir.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snapis excluded by!**/*.snapbaml_language/crates/baml_tests/src/compiler2_tir/snapshots/baml_tests__compiler2_tir__phase5__snapshot_baml_package_items.snapis excluded by!**/*.snap
📒 Files selected for processing (9)
baml_language/crates/baml_builtins2/baml_std/baml/ns_llm/llm_types.bamlbaml_language/crates/baml_tests/Cargo.tomlbaml_language/crates/baml_tests/baml_src/ns_prompt_tag_runtime/prompt_tag_runtime.bamlbaml_language/crates/baml_tests/tests/prompt_tag_runtime.rsbaml_language/crates/bex_vm/src/package_baml/json.rsbaml_language/crates/bex_vm/src/package_baml/llm.rsbaml_language/crates/bex_vm/src/package_baml/mod.rsbaml_language/crates/bex_vm/src/package_baml/root.rsbaml_language/crates/sys_ops/src/lib.rs
💤 Files with no reviewable changes (1)
- baml_language/crates/sys_ops/src/lib.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@baml_language/crates/bex_vm/src/package_baml/llm.rs`:
- Around line 37-41: Run the required Rust validation for the changes around the
prompt-part mutation logic, including cargo test --lib, and ensure the tests
complete successfully before finalizing the PR.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5e10b1b1-3038-4d9e-a4a0-850731b107d5
📒 Files selected for processing (2)
baml_language/crates/baml_tests/tests/prompt_tag_runtime.rsbaml_language/crates/bex_vm/src/package_baml/llm.rs
Summary
Addresses B-1039.
Tests
Summary by CodeRabbit
ToStringconversions and redaction overrides correctly apply to media-containing values.ToStringoverrides/redaction, and role/metadata preservation, with assertions based on rendered prompt text and JSON metadata.