You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are utilizing our Message class both as a regular component and as a way to serialize our components into chat messages inference engines understand.
We need to
Fix our backend serialization pipeline so that we aren't printing Messages twice due to document handling
Add infrastructure for better message serialization (either from components directly or utilizing an intermediate message representation). This will allow use to write custom serialization when required (ie for tool results, etc...).
Related is allowing components to specify roles: #377. Presumably anything else that can be serialized as a chat message to an inference provider might be worth allowing components to expose (ie images?).
We should also investigate serializing mots as the initial incoming message.
I hacked around on this a little bit this morning. Came up with one possible way that this could work, although I didn't go too far on it, so there's probably a number of holes that need plugging.
Step 1 — Widen the API + add a role override
Let session.act/act/aact accept a ModelOutputThunk, and add a role override to the mot→Message conversion so a computed mot can be the initial incoming message with an explicit role.
The downstream path already works (parsed_repr → message_to_openai_message, including reasoning replay and tool_calls).
Guard that the incoming mot is computed abovegenerate_walk (backend.py:362) — otherwise an uncomputed head mot triggers a spurious self-generation.
Confirm behavior under the default RejectionSamplingStrategy (a mot-action does not take the strategy is None fast path).
Step 2 — Make Message._parse the canonical mot serializer
Use provider-native raw.response recovery instead of the lossy string fallback.
Also change the base.py:1169 dispatch so a mot-action gets a real parse path — this is not free; without it the follow-on turn's parsed_repr degrades to a raw string.
Step 3 — Generalize: let any component declare its role
Add role to format_for_llm/TemplateRepresentation so components (not just mots) declare their role, retiring the positional guess.
Activity
jakelorocco commentedon Jul 17, 2026
Related to: #1405 and #1201
jakelorocco commentedon Jul 17, 2026
We should also investigate serializing mots as the initial incoming message.
psschwei commentedon Jul 20, 2026
I hacked around on this a little bit this morning. Came up with one possible way that this could work, although I didn't go too far on it, so there's probably a number of holes that need plugging.
Step 1 — Widen the API + add a role override
Let
session.act/act/aactaccept aModelOutputThunk, and add a role override to the mot→Messageconversion so a computed mot can be the initial incoming message with an explicit role.parsed_repr→message_to_openai_message, including reasoning replay and tool_calls).generate_walk(backend.py:362) — otherwise an uncomputed head mot triggers a spurious self-generation.RejectionSamplingStrategy(a mot-action does not take thestrategy is Nonefast path).Step 2 — Make
Message._parsethe canonical mot serializerUse provider-native
raw.responserecovery instead of the lossy string fallback.base.py:1169dispatch so a mot-action gets a real parse path — this is not free; without it the follow-on turn'sparsed_reprdegrades to a raw string.Step 3 — Generalize: let any component declare its role
Add
roletoformat_for_llm/TemplateRepresentationso components (not just mots) declare their role, retiring the positional guess.