Repository navigation
fix(gateway): keep harness reminders out of turn selection #2771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d7529c1
89f6c5c
4860812
2dde665
fe96b98
7bea753
682d759
ff51d5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,15 +14,16 @@ | |
|
|
||
| //! 一个用户回合的规范化记录,供网关在回合结束时沉淀。 | ||
| //! | ||
| //! 回合从最后一条用户消息开始,到不再调用工具的响应(终止响应)结束。记录完整保留这一回合里模型读到的内容: | ||
| //! 回合从最后一条非独立宿主提醒的用户消息开始,到不再调用工具的响应(终止响应)结束。记录保留这一回合里的: | ||
| //! 用户文本、其后的其他消息、工具调用的全部参数字段、工具输出与错误、推理的可见摘要、无法识别的条目,以及助手 | ||
| //! 文本;字段不截断,步骤不省略。只有推理密文、各类 ID、状态、用量等传输元数据不进入记录,二进制数据(截图、 | ||
| //! 文本;字段不截断,步骤不省略。独立的宿主提醒、推理密文、各类 ID、状态、用量等传输元数据不进入记录,二进制数据(截图、 | ||
| //! 图片、文件)记为带字节数的占位文本。用户文本取自注入前的请求,不含准备结果。 | ||
| //! | ||
| //! 一段 Source 的估算规模不超过 Core 生效的 Atomic Memory 输入上限,也不超过 [`MAX_SOURCE_TOKENS`];超过时记录 | ||
| //! 按顺序拆成几段,每段都是独立的 Source。 | ||
|
|
||
| use crate::capture_coverage::declaration; | ||
| use crate::turn_message::last_user_index; | ||
| use pc_gateway_protocol::{CanonicalMessage, CanonicalRequest, Role}; | ||
| use serde::Serialize; | ||
| use serde_json::{Map, Value}; | ||
|
|
@@ -121,13 +122,12 @@ pub(crate) fn turn_transcript( | |
| } else { | ||
| (Vec::new(), chat_final_text(&response)?) | ||
| }; | ||
| let start = request | ||
| .messages | ||
| .iter() | ||
| .rposition(|m| matches!(m.role, Role::User))?; | ||
| let start = last_user_index(request)?; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Align prefix extraction with the selected prompt When prefix extraction processes a captured Responses request ending in a standalone reminder, the Source now starts at the earlier prompt, but the retained prefix includes the reminder and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for flagging this. I pushed ff51d5b. When a trailing reminder makes the raw last-user boundary differ from the selected prompt, the Gateway now omits the prefix handle and Core uses the normal captured Source. The provider request is unchanged, and turns with matching boundaries still use prefix extraction. The Responses regression now runs with prefix extraction enabled and checks both paths, including the original prompt and tool output. All 146 targeted Gateway tests passed locally. |
||
| let user = parts_text(&request.messages[start].content); | ||
| let mut steps: Vec<Step> = request.messages[start + 1..] | ||
| .iter() | ||
| // Any user messages after the selected prompt are standalone reminders. | ||
| .filter(|m| m.role != Role::User) | ||
| .flat_map(|m| { | ||
| if is_responses(list_key) { | ||
| m.content.iter().flat_map(item_steps).collect() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Preserve per-preparation responses in the shared fixture
headerless_requests_replay_preparation_within_each_turnstill expectsreuse-1/reuse-2bindings andPrepared context 1/Prepared context 2, but this shared handler now returns fixed values, making that existing test fail at its first binding assertion. Preserve distinct preparation responses for that test and configure the reminder tests separately.CI: View the failed check.