Make NodeRunStreamChunkEvent immutable
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
Direzione di ricerca
Start with the NodeRunStreamChunkEvent definition in the graphon engine_events node module, then read how ResponseStreamFilter buffers and forwards events in src/graphon/engine/filter/builtin/response_stream/template_stream.py. Run the reproduction script against tests/engine/test_response_stream_filter.py helpers to confirm the shared-reference checkpoint. Done when assigning to event.chunk fails, the downstream copy pattern still works, and the existing response-filter tests pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
AI disclosure — I discussed this behavior with Codex (gpt-6.2-astra), which verified the example and helped draft this report. I am responsible for the report.
Description
ResponseStreamFilter can yield a NodeRunStreamChunkEvent while keeping a reference to that same object in its root stream buffer. A later filter can assign a new string to event.chunk. The next checkpoint of the earlier filter then contains the downstream edit. Python strings are immutable, but the event allows its chunk field to be reassigned. Buffer insertion · Forwarding the event · Serializing the buffer
Minimal reproduction
Run from the Graphon repository root. The example uses the existing response-filter test graph and one non-final source chunk. EscapeText is a custom filter added for this reproduction. It consumes the same public filter API a host can use.
PYTHONPATH=.:src uv run python - <<'PY'
import json
from html import escape
from graphon.engine.filter import ResponseStreamFilter, filter_engine_events
from graphon.engine_events.graph import GraphRunStartedEvent
from graphon.engine_events.node import NodeRunStreamChunkEvent
from tests.engine.test_response_stream_filter import (
_context, _stream_chunk, _variable_response_graph,
)
class EscapeText:
def initialize(self, context):
pass
def on_event(self, event):
if isinstance(event, NodeRunStreamChunkEvent):
event.chunk = escape(event.chunk)
return [event]
def flush(self):
return []
selector = ["source", "text"]
response = ResponseStreamFilter()
events = filter_engine_events(
[GraphRunStartedEvent(), _stream_chunk("&", selector=selector, is_final=False)],
context=_context(_variable_response_graph(selector=selector)),
filters=[response, EscapeText()],
)
print("display:", [e.chunk for e in events if isinstance(e, NodeRunStreamChunkEvent)])
buffer = json.loads(response.dumps())["stream_buffers"][0]
print("checkpoint:", buffer["events"][0]["chunk"])
PY
Expected and actual behavior
The source emits &. A display filter should be able to produce & while the upstream response filter retains the & it observed. For a control, change just the assignment in EscapeText.on_event to event = event.model_copy(update={"chunk": escape(event.chunk)}).
| Downstream transformation | Displayed chunk | Chunk in the upstream checkpoint |
|---|---|---|
Assign to event.chunk |
& |
& |
| Return an updated copy | & |
& |
Verified both rows on Python 3.12.12 at main (b79228b) and on #395 (d4032bf). The checkpoint example works with a single reference on main. Replaying a reference makes the same effect visible in the reply on #395: for source text &a and template {{#llm.text#}}/{{#llm.text#}}, the custom in-place filter produced &a/&amp;a. Returning a copy produced &a/&a.
Proposed change
I propose making NodeRunStreamChunkEvent immutable from construction. A filter can forward the event it received or return a new event when it transforms the text, for example event.model_copy(update={"chunk": escape(event.chunk)}). An attempt to assign to event.chunk should fail at the point of assignment.
With this contract, ResponseStreamFilter can retain the source event for checkpointing and replay. In the example above, the downstream consumer receives & and the upstream checkpoint still contains &. This proposal can be handled independently of #395.
- Lingua principale
- Python
- Stelle
- 90
- Fork
- 47
- Merge medio
- 3g 23h
- PR unite (30g)
- 19
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di langgenius/graphon
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
langgenius/graphon#443 ·
I maintainer di solito rispondono entro 2 giorni
-
Complete LLM results disappear from streamed answersForse già presa @WH-2099 l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
langgenius/graphon#389 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
bug(utils): parse_json_markdown drops a valid payload when the text contains a backtickForse già presa @WH-2099 l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
langgenius/graphon#380 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
project#graphon
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
langgenius/graphon#442 ·
I maintainer di solito rispondono entro 2 giorni
-
project#graphon
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
langgenius/graphon#436 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di langgenius/graphon
Issue simili
-
app: scripts status: backlog type: housekeeping
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
netbox-community/netbox-scripts#239 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
LmeSzinc/AzurLaneAutoScript#6194 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
micronaut-projects/micronaut-core#14585 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100