Keep [SPEAKER] provenance model-only: strip echoed tags from replies and history
The descriptive speaker.note let the model imitate the tag into its visible reply; the echoed tag was then stored and re-tagged by build_request next turn, stacking duplicates. Fix: speaker.note now forbids writing/repeating the tag; strip_speaker_tags removes leading echoed [SPEAKER: name - YYYY-MM-DD HH:MM] runs at persist, at the agent Final content, in get_messages (display+HTML) and before re-tagging history, so the tag stays prompt-only and never stacks. Frontend strips it from the live preview too. Legacy tagged rows heal on reload without migration. +2 tests (138 green), clippy/fmt clean; live two-turn verify shows no tag in browser-facing content.
This commit is contained in:
1 parent
7dd66ea138
commit
77bfa72689
4 files changed
+121
-11
No files matched your search
+8
-2
@@ -104,6 +104,12 @@ function usageText(u) {
|
||||
}
|
||||
|
||||
// Compact locale-aware date+time for a message bubble (epoch seconds).
|
||||
// The [SPEAKER] tag is model-context metadata; hide any echoed copy in the live
|
||||
// preview (the backend also strips it from stored / final / history content).
|
||||
function stripSpeaker(s) {
|
||||
return s.replace(/^(\s*\[SPEAKER:[^\]]*-\s*\d{4}-\d{2}-\d{2} \d{2}:\d{2}\]\s*)+/, "");
|
||||
}
|
||||
|
||||
function stampLabel(secs) {
|
||||
const d = new Date(secs * 1000);
|
||||
const date = d.toLocaleDateString(I18N.lang, { day: "2-digit", month: "2-digit" });
|
||||
@@ -413,7 +419,7 @@ async function agentTurn(content, t, attachments) {
|
||||
if (ev.content) {
|
||||
if (!L.text) L.det.open = false;
|
||||
L.text += ev.content;
|
||||
L.contentNode.textContent = L.text;
|
||||
L.contentNode.textContent = stripSpeaker(L.text);
|
||||
}
|
||||
} else if (ev.type === "tool_call") {
|
||||
closeLive();
|
||||
@@ -426,7 +432,7 @@ async function agentTurn(content, t, attachments) {
|
||||
} else if (ev.type === "final") {
|
||||
const L = ensureLive();
|
||||
const m = ev.response.choices[0].message;
|
||||
if (!L.text && m.content) { L.text = m.content; L.contentNode.textContent = m.content; }
|
||||
if (!L.text && m.content) { L.text = m.content; L.contentNode.textContent = stripSpeaker(m.content); }
|
||||
if (!L.reasoning && m.reasoning_content) {
|
||||
L.reasoning = m.reasoning_content;
|
||||
L.reasoningNode.textContent = L.reasoning;
|
||||
|
||||
Reference in new issue
Block a user