sekai.ni.itamio
01/29/2026, 8:36 AMpython
async def _astream()
...
stream = self.b.stream.ChooseTool(baml_state, {"tb": tb}) # tb for @@dynamic usage in baml_src/
async for partial in stream:
...
Right now partial.model_dump() is accumulated, e.g.:
- 1st emit: {"selected_tool": None}
- 2nd emit: {"selected_tool": {"name": None}}
- 3rd emit: {"selected_tool": {"name": "rep"}}
- 4th emit: {"selected_tool": {"name": "reply_to_user"}}
For LangChain streaming, I’d prefer delta-style updates (only the changed field/value per emit).
Is there a configuration to make partial emit delta-style updates instead of accumulated state?sekai.ni.itamio
01/29/2026, 9:33 AMb.stream.Function() emit delta-style, is there a function similar to tb.DynamicSchema.model_dump_with_all_optional() that can return an initial “partial” dictionary with all fields set to optional/None? This would allow me to handle the delta-extraction logic on my side more easily.
https://cdn.discordapp.com/attachments/1466351374764871762/1466365633418625105/image.png?ex=697c7aea&is=697b296a&hm=c76c8db8193ee23318559d2eb149955e4aceb31b72376f8fcd366eb11eb1e734&Vaibhav (BAML 🐑)
01/29/2026, 1:16 PMVaibhav (BAML 🐑)
01/29/2026, 1:17 PMVaibhav (BAML 🐑)
01/29/2026, 1:17 PMsekai.ni.itamio
01/29/2026, 3:05 PMDynamicSchema is already defined using TypeBuilder, I was expecting the delta to be a fully shaped dictionary with all fields present but set to None, for example:
python
{
selected_tool: {
name: None, # could be a delta or accumulated value; mainly need the full schema shape
arguments: {
a: None,
b: None,
},
} or {
name: None,
arguments: {
x: None,
y: None,
},
} or {
name: None,
arguments: {
role: "assistant", # constant
content: None,
},
},
}
instead of:
python
{"selected_tool": None}
This would make it easier for me to compute delta-style updates on the LangChain side.
That said, please feel free to ignore this if it doesn’t align with the intended design.
Also, thanks for pointing out on_tick — that’s new to me, and I’ll take a look at the documentation.sekai.ni.itamio
01/29/2026, 4:53 PM