YourTechBud
01/13/2026, 2:40 AMaaronv (BAML)
01/13/2026, 2:42 AMaaronv (BAML)
01/13/2026, 2:43 AMYourTechBud
01/13/2026, 2:48 AMvEth
01/13/2026, 2:48 AMYourTechBud
01/13/2026, 2:49 AMvEth
01/13/2026, 2:50 AMconst { BamlRuntime } = require('@boundaryml/baml')
const env = Object.fromEntries(
Object.entries(process.env).filter(([, v]) => typeof v === 'string')
)
const rt = BamlRuntime.fromDirectory('baml_src', env)
const ctx = rt.createContextManager()
const req = rt.buildRequestSync(
'Orchestrator',
{ messages, current_time: '2025-12-18 10:00' },
ctx,
tb ?? null, // Key: whether to pass TypeBuilder
null,
false,
env
)
const body = req.body.json()
console.log(body.messages[0].role) // system
console.log(body.messages[0].content) // complete system prompt text (including ctx.output_format)prashanth
01/13/2026, 3:08 AMprashanth
01/13/2026, 3:09 AMprashanth
01/13/2026, 3:09 AMYourTechBud
01/13/2026, 3:10 AMYourTechBud
01/13/2026, 3:12 AM### BAML Integration
- **Source files**: `baml_src/*.baml` (edit these)
- **Generated client**: `src/lib/baml_client/` (DO NOT EDIT - auto-generated)
- Run `pnpm build:baml` after modifying BAML files
- **For BAML documentation**: Use Context7 with library ID `/boundaryml/baml`
### BAML Development Rules
**Function Signature Pattern:**
- Use flat Input class: `{FunctionName}Input` - contains all data needed for the function
- Use Options class for modifiers: `{FunctionName}Options` - contains boolean flags/settings that modify behavior (e.g., `isFollowUp`)
- Signature: `function Foo(input: FooInput, options: FooOptions) -> FooResponse`
- NO nested context objects - flatten everything into Input
**Naming Conventions:**
- Input/Response/Options classes: `{FunctionName}Input`, `{FunctionName}Response`, `{FunctionName}Options`
- Action classes: `{Action}Action` (e.g., `SpeakAction`, `WriteCodeAction`)
- Use camelCase for fields
- Use SCREAMING_SNAKE_CASE for XML tags in prompts
**Code Organization:**
- Shared types go in `narrative.baml` (speakers, summaries) or `actions.baml` (action types)
- Shared prompt logic goes in `common.baml` as `template_string`
- Before creating a new type, check if one already exists
- Extract to `template_string` when prompt logic appears in 2+ functions
- Template strings should take a `header` parameter instead of hardcoding rule numbers
**Tests:**
- Test files live beside source files: `foo.baml` → `foo.test.baml`
- Tests MUST match actual input schema - verify field names and structure match
- Update tests whenever you modify function signatures or input types
- Run `pnpm build:baml` after changes to verify compilation
- Never run the baml test command. We don't like it.
**XML Tags in Prompts:**
- Use plural for collections: `<SPEAKERS>`, `<PREVIOUS_ACTIONS>`, `<COMPLETED_UNITS>`
- Use singular for single items: `<DIRECTIVE>`, `<QUESTION>`, `<CURRENT_UNIT>`
- Be consistent across files - same concept should use same tag nameYourTechBud
01/13/2026, 3:13 AMprashanth
01/13/2026, 3:14 AMYourTechBud
01/13/2026, 3:14 AMprashanth
01/13/2026, 3:15 AMprashanth
01/13/2026, 3:15 AMprashanth
01/13/2026, 3:15 AMYourTechBud
01/13/2026, 3:16 AMprashanth
01/13/2026, 3:16 AMprashanth
01/13/2026, 3:16 AMprashanth
01/13/2026, 3:17 AMYourTechBud
01/13/2026, 3:17 AMYourTechBud
01/13/2026, 3:18 AMprashanth
01/13/2026, 3:18 AMYourTechBud
01/13/2026, 3:18 AMprashanth
01/13/2026, 3:19 AMprashanth
01/13/2026, 3:19 AMprashanth
01/13/2026, 3:20 AMprashanth
01/13/2026, 3:21 AM