symfonic.core.streaming¶
streaming ¶
symfonic.core.streaming -- Stream event processing and adapters.
ActivationEvent ¶
Bases: BaseModel
A single memory node activated during spreading activation.
ConsolidationScheduledEvent ¶
Bases: BaseModel
Emitted after consolidation is scheduled (background task, not yet complete).
EventTranspiler ¶
Converts raw LangGraph astream_events(v2) into typed StreamEvents.
Usage::
transpiler = EventTranspiler()
async for event in transpiler.transpile(runtime.astream_events("v2")):
# event is a TimestampedEvent with ms precision
Source code in src/symfonic/core/streaming/transpiler.py
transpile
async
¶
Transform raw LangGraph events into typed TimestampedEvents.
Source code in src/symfonic/core/streaming/transpiler.py
ExtensionEvent ¶
Bases: BaseModel
Vendor-specific or custom event. Never dropped, never raises.
ExtractionFilter ¶
Stateful streaming filter that strips extraction blocks from text.
Usage::
filt = ExtractionFilter()
for chunk in text_chunks:
clean = filt.feed(chunk)
if clean:
yield TextDeltaEvent(text=clean)
# After the loop ends:
remainder = filt.flush()
if remainder:
yield TextDeltaEvent(text=remainder)
ops = filt.get_extracted_ops()
Source code in src/symfonic/core/streaming/extraction_filter.py
feed ¶
Accept the next text chunk and return the clean portion.
The returned string is guaranteed to contain no extraction block
content. It may be shorter than text, or empty if the chunk
is (or partially is) an extraction block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Raw text chunk from the LLM stream. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Clean text safe to emit as a TextDeltaEvent. May be empty. |
Source code in src/symfonic/core/streaming/extraction_filter.py
flush ¶
Return any remaining buffered text that is not part of a tag.
Call this after the stream ends. If the buffer contains a partial tag that never completed, the partial tag text is returned as-is (it is not a real extraction block).
Returns:
| Type | Description |
|---|---|
str
|
Any remaining clean text. May be empty. |
Source code in src/symfonic/core/streaming/extraction_filter.py
get_extracted_ops ¶
Return all ops parsed from extraction blocks encountered so far.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of op dicts (may be empty). |
GraphEdgeCreatedEvent ¶
Bases: BaseModel
Emitted when a new edge is written during consolidation.
GraphNodeCreatedEvent ¶
Bases: BaseModel
Emitted when a new node is written to the graph during consolidation.
MemoryExtractedEvent ¶
Bases: BaseModel
Emitted when an extraction block is parsed from the stream.
MessageEndEvent ¶
Bases: BaseModel
End of message.
MessageStartEvent ¶
Bases: BaseModel
Start of a new message.
ResponseCompleteEvent ¶
Bases: BaseModel
Final clean response text — equivalent of AgentResponse.final_response.
TextDeltaEvent ¶
Bases: BaseModel
Incremental text chunk from LLM.
ThinkingDeltaEvent ¶
Bases: BaseModel
Incremental thinking/reasoning chunk.
TimestampedEvent
dataclass
¶
StreamEvent wrapped with elapsed milliseconds from stream start.
to_dict ¶
Serialize for SSE transmission.
ToolCallDeltaEvent ¶
Bases: BaseModel
Incremental tool call arguments.
ToolCallStartEvent ¶
Bases: BaseModel
Tool call initiated by LLM.
ToolResultEvent ¶
Bases: BaseModel
Result returned from tool execution.
UsageEvent ¶
Bases: BaseModel
Token usage report.