https://www.boundaryml.com logo
Understanding BAML logging
# help
s
I'm trying to understand the BAML terminal logging ouptut a bit more. The screenshot shows the message conversation part of the prompt as output to the terminal. What's confusing me is the "system" role (right?), which per my code, should just be "tool". I definitely don't explicitly set it, because my roles are "user", "assistant" and "tool". The "system" role is defined at the top of the prompt in my BAML function, but I don't expect it to show up again. Is there something about the terminal logging that I'm missing? https://cdn.discordapp.com/attachments/1448465493525790781/1448465494330835076/Screenshot_2025-12-10_at_4.02.58_PM.png?ex=693b5c1d&is=693a0a9d&hm=44fff553d95adeba7b803a07f56cc3445c8c5edc2bca0366ce5926d5882ed685&
Oh what I'm gathering from https://docs.boundaryml.com/ref/prompt-syntax/role is that BAML could change the role based on the LLM provider? It might be my misunderstanding then about the important of the role value.
g
You're right that BAML sometimes changes the role. That's to provide a uniform BAML-side interface, that allows you to change providers, without having to change your roles in your code.
s
Hm so if I wanted a custom tool role to store tool results, cause I'm not sure if I'd call them "user" or "assistant" or "system". Is that possible? Or if you know of best practices when it comes to adding tool results to a conversation state
a
you could try to use _.role("tool") if the provider supports it. When you serialize your messages you could check the type of the message and use 'tool' for tool call results. We usually just tell people to use assistant / user and it works well. Have you run into issues?
s
Well I'm still debugging my prompts to figure out why sometimes tool call isn't working, or steering the model to return output in expected format. In that process, I checked the raw logs and noticed the role replacement. I don't think it's high impacting, I found some other issues with my prompt
a
if you are struggling you can inject assistant messages like 'I will now answer in the json schema'
s
Hm okay. I've had a couple learnings from the last few days' debugging - different models are optimized for different outputs when doing "function calling". I found that Sonnet 4.5 likes XML tags while GPT likes JSON. Also, starting off with round robin client between Sonnet and GPT isn't the best idea, especially when the prompt isn't full optimized. I did it so I could reduce 429 throttling, but now I'm just focusing on one model with a fallback.