A buffered Messages reply that ended on a stop sequence reports `end_turn`
magpie 0.1.4094, Windows 11. Models served by a provider plugin on the Anthropic Messages API (npm: "@ai-sdk/anthropic"). magpie always streams to the plugin and folds the stream itself when the agent asked for a buffered reply.
What I did
The same Anthropic Messages request streamed and buffered, to claude-haiku-5.5 and claude-opus-4.8:
{"model": "bedrock-profile/claude-opus-4.8", "max_tokens": 1024, "stop_sequences": ["STOP"],
"messages": [{"role": "user", "content": "Repeat exactly, with nothing else: one two STOP three"}]}
What happened
Streamed: text one two , stop_reason: "stop_sequence", stop_sequence: "STOP". Correct.
Buffered: the same text one two , but stop_reason: "end_turn". The upstream stopped on the sequence in both cases, as the streamed reply shows; the fold reports the stop as a natural end.
What I expected
The folded reply to carry the stream's message_delta stop fields unchanged: stop_reason: "stop_sequence" and stop_sequence: "STOP". An agent reading end_turn cannot tell that the model was cut off by its own stop word, which is what the field exists for.
补上了流式转完整响应时丢掉的停止原因,stop_sequence 和原始停止词现在会保留,空字符串和 null 也区分处理;pause_turn、上下文到顶这两种结束方式一并保留,Chat 等其他协议继续使用各自的结束标记
从插件账号的实际转发入口复现了原来的 end_turn/null,修复后 10 项测试、含子案例共 40 项通过,同组选例的 race 也通过,覆盖直接流式、缓冲输出、重新编码、工具调用结束和后续停止事件覆盖旧值,使用内存 HTTP 模拟,没有连接真实 Bedrock
Fixed in v0.1.5078 by 49346c5c2: gateway: a stream-only plugin's Messages reply keeps its stop_sequence and stop word (#6595)
A Messages client asking a stream-only Anthropic plugin account (roeseth's case) got the buffered reply with stop_reason end_turn and stop_sequence null when the model had stopped on a stop sequence: the shared Stop vocabulary folds stop_sequence into "stop", and both renderAnthropic and the rebuilt stream wrote stopToAnthropic of that. pause_turn and model_context_window_exceeded were folded the same way.
Ported from Q呀's (qq01-hub) branch fix/r4-6595-buffered-stop-sequence. Thanks!
Leaving this open: please update to v0.1.5078 or later and say here whether your case works now.