fix: close streaming fence before ending block on call/default events
The event handler was emitting [[[end]]] to close an assistant block without first closing an open streaming fence (code block). This left the log in a state where a [[[call:...]]] block appeared nested inside an unclosed assistant block, triggering a log structure violation. Now the call and default cases close streamingFence (like the tool case already did) before writing the [[[end]]] marker.
This commit is contained in:
parent
c7f1bec71c
commit
3d9eca97b2
|
|
@ -290,6 +290,10 @@ func NewEventHandler(as *AgentLog) agent.EventHandler {
|
|||
|
||||
case "call":
|
||||
if streamingRole != "" {
|
||||
if streamingFence != "" {
|
||||
as.AppendLog([]byte("\n" + streamingFence + "\n"))
|
||||
streamingFence = ""
|
||||
}
|
||||
as.AppendLog([]byte("\n" + format.EndTag + "\n"))
|
||||
streamingRole = ""
|
||||
}
|
||||
|
|
@ -297,6 +301,10 @@ func NewEventHandler(as *AgentLog) agent.EventHandler {
|
|||
|
||||
default:
|
||||
if streamingRole != "" {
|
||||
if streamingFence != "" {
|
||||
as.AppendLog([]byte("\n" + streamingFence + "\n"))
|
||||
streamingFence = ""
|
||||
}
|
||||
as.AppendLog([]byte("\n" + format.EndTag + "\n"))
|
||||
streamingRole = ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue