mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-13 03:30:46 +08:00
fix(chat): always persist reasoning_content on assistant event_payload
Non-thinking profiles previously wrote model reasoning only as separate event_type=reasoning rows whose event_payload held chunk_index metadata, so JSON inspection showed tool payloads but no reasoning_content key. Store the full merged reasoning blob on the primary assistant row whenever present (same shape as thinking mode). Update instruction-leak filtering to scan event_payload.reasoning_content as well as legacy reasoning rows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
c938147fdb
commit
5efac74f87
3 changed files with 35 additions and 19 deletions
|
|
@ -21,6 +21,22 @@ def test_filter_internal_instruction_user_messages_hides_polluted_user_row() ->
|
|||
assert [str(getattr(x, "event_type", "")) for x in out] == ["reasoning", "assistant_text"]
|
||||
|
||||
|
||||
def test_filter_internal_instruction_user_messages_hides_from_assistant_event_payload() -> None:
|
||||
polluted_text = "请检查并修复网关启动失败。"
|
||||
rows = [
|
||||
SimpleNamespace(role="user", event_type="user_text", content=polluted_text),
|
||||
SimpleNamespace(
|
||||
role="assistant",
|
||||
event_type="assistant_text",
|
||||
content="已修复",
|
||||
event_payload={"reasoning_content": f"任务分配\nspecialist=ops\ninstruction:\n{polluted_text}"},
|
||||
),
|
||||
]
|
||||
out = _filter_internal_instruction_user_messages(rows)
|
||||
assert len(out) == 1
|
||||
assert str(getattr(out[0], "event_type", "")) == "assistant_text"
|
||||
|
||||
|
||||
def test_filter_internal_instruction_user_messages_keeps_normal_user_rows() -> None:
|
||||
rows = [
|
||||
SimpleNamespace(role="user", event_type="user_text", content="你好"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue