idanrokach
12/08/2025, 9:13 AM@@assert expressions repeatedly. For example:
baml
@@assert(should_call_get_allowed_countries_tool, {{ this.tool_calls|selectattr('name', 'equalto', 'get_allowed_countries')|list|length > 0 }})
This exact assertion appears in many of my test cases. It would be great to have a way to define reusable assertion templates that can be referenced by name across tests.
Something like:
baml
// Define once
assertion should_call_tool(tool_name: string) {{
this.tool_calls|selectattr('name', 'equalto', tool_name)|list|length > 0
}}
// Reuse in tests
test MyTest1 {
functions [MyFunction]
args { ... }
@@assert(should_call_tool("get_allowed_countries"))
}
test MyTest2 {
functions [MyFunction]
args { ... }
@@assert(should_call_tool("get_allowed_countries"))
}
This would reduce duplication and make tests more maintainable. Is this something that's on the roadmap, or is there an existing pattern I'm missing?idanrokach
12/08/2025, 9:16 AM