Conversation
Replace `ConversationEvent` inside `Event::Part` with a purpose-built
`EventPart` enum (`Message`, `Reasoning`, `Structured`,
`ToolCall(ToolCallPart)`), implementing RFD 012. This decouples the
streaming transport layer from the persistence layer.
Previously, every streaming chunk allocated a full `ConversationEvent`
with a timestamp and metadata map, even though most of the type went
unused during streaming. The `EventBuilder` also had to silently ignore
five `EventKind` variants (`ChatRequest`, `TurnStart`, etc.) that are
invalid in a streaming context.
`EventBuilder` moves from `jp_conversation` into `jp_llm`, where it
belongs — translating streaming `EventPart`s into persistence
`ConversationEvent`s on `Flush`. Its `handle_part` signature changes to
`(usize, EventPart, Map<String, Value>)`. The persistence layer
(`ConversationEvent`, `ConversationStream`) is unchanged.
`ToolCallRequestAggregator` is removed. Providers now emit
`ToolCallPart::Start { id, name }` when a tool call begins, and
`ToolCallPart::ArgumentChunk(json)` for each argument delta. The
`EventBuilder` accumulates these into a complete `ToolCallRequest` on
`Flush`. `AggregationError` is removed from the public `jp_llm` API.
Factory methods on `Event` (`message`, `reasoning`, `structured`,
`tool_call_start`, `tool_call_args`) reduce construction boilerplate
across all providers and tests. Flush metadata is changed from
`IndexMap<String, Value>` to `Map<String, Value>` for consistency.
RFD 012 is marked as Implemented.
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace
ConversationEventinsideEvent::Partwith a purpose-builtEventPartenum (Message,Reasoning,Structured,ToolCall(ToolCallPart)), implementing RFD 012. This decouples the streaming transport layer from the persistence layer.Previously, every streaming chunk allocated a full
ConversationEventwith a timestamp and metadata map, even though most of the type went unused during streaming. TheEventBuilderalso had to silently ignore fiveEventKindvariants (ChatRequest,TurnStart, etc.) that are invalid in a streaming context.EventBuildermoves fromjp_conversationintojp_llm, where it belongs — translating streamingEventParts into persistenceConversationEvents onFlush. Itshandle_partsignature changes to(usize, EventPart, Map<String, Value>). The persistence layer (ConversationEvent,ConversationStream) is unchanged.ToolCallRequestAggregatoris removed. Providers now emitToolCallPart::Start { id, name }when a tool call begins, andToolCallPart::ArgumentChunk(json)for each argument delta. TheEventBuilderaccumulates these into a completeToolCallRequestonFlush.AggregationErroris removed from the publicjp_llmAPI.Factory methods on
Event(message,reasoning,structured,tool_call_start,tool_call_args) reduce construction boilerplate across all providers and tests. Flush metadata is changed fromIndexMap<String, Value>toMap<String, Value>for consistency.RFD 012 is marked as Implemented.