AIStudio2API icon indicating copy to clipboard operation
AIStudio2API copied to clipboard

[Bug] streamInteraction buffers trailing thought_signature in pendingSignature and never flushes it before closeStep(), silently dropping it from SSE output

Open photobrand opened this issue 1 week ago • 1 comments

发生了什么 / What happened

Summary

In internal/api/interaction_output.go:479-510, when a text step is open (text != nil) during a streaming POST /v1/interactions or POST /v1beta/interactions response, EventThoughtSignature (or an empty EventText with ThoughtSignature != "") is buffered into pendingSignature:

		if text != nil && (event.Kind == aistudio.EventThoughtSignature || event.Kind == aistudio.EventText && event.Text == "" && event.ThoughtSignature != "") {
			pendingSignature = event.ThoughtSignature
			return nil
		}
		return emit(event)
	})
	...
	if err := closeStep(); err != nil {
		return nil
	}

Consequence

flushSignature() is only invoked when a subsequent non-citation event arrives (line 475), and is never called after consumeStreamEvents finishes. Any trailing thought_signature at the end of a streaming Interaction is silently lost from SSE events (while storeInteraction preserves it on the stored object).

Suggested Fix

Flush pendingSignature after consumeStreamEvents completes (if err == nil { err = flushSignature() }) before calling closeStep().

版本 / Version

v0.3.14

photobrand avatar Nov 22 '26 15:11 photobrand

每人最多同时打开 3 个 Issue,这个 Issue 已自动关闭。请等已有的 Issue 处理完再提,或把内容补充到已有的 Issue 里。

Each user can have at most 3 open issues at a time, so this one was closed automatically. Please wait until your existing issues are resolved, or add this to one of them.

github-actions[bot] avatar Nov 22 '26 15:11 github-actions[bot]