@skip

The @skip attribute in BAML is used to exclude certain fields or values from being included in prompts or parsed responses. This can be useful when certain data is not relevant for the LLM’s processing.

In the case of class fields, the field type must be nullable if @skip is used in order to allow parsing LLM responses that will not include the field.

This is valid:

OK
1class MyClass {
2 field1 string
3 field2 string? @skip // OK because field2 is nullable
4}

This is not:

NOT OK
1class MyClass {
2 field1 string
3 field2 string @skip // Error: Field with @skip attribute must be optional.
4}

Prompt Impact

Without @skip

BAML
1enum MyEnum {
2 Value1
3 Value2
4}
5
6class MyClass {
7 field1 string
8 field2 string?
9}

ctx.output_format:

  • MyEnum
MyEnum
---
Value1
Value2
  • MyClass
{
field1: string,
field2: string or null,
}

With @skip

BAML
1enum MyEnum {
2 Value1
3 Value2 @skip
4}
5
6class MyClass {
7 field1 string
8 field2 string? @skip
9}

ctx.output_format:

  • MyEnum
MyEnum
---
Value1
  • MyClass
{
field1: string,
}