fix(service): enhance message filtering to drop empty chat messages while retaining tool requests
Some checks failed
CI / lint (push) Has been cancelled
CI / unit tests (push) Has been cancelled
CI / integration tests (push) Has been cancelled
CI / package build (push) Has been cancelled
Commit lint / pull request title (push) Has been cancelled
Commit lint / commit messages (push) Has been cancelled
Docs / links (push) Has been cancelled

This commit is contained in:
2026-06-16 16:18:24 +08:00
parent 0910affc78
commit b243018aff
14 changed files with 248 additions and 38 deletions

View File

@ -74,6 +74,26 @@ def test_filter_agent_keeps_everything() -> None:
assert [m.message_id for m in out] == ["m1", "m2"]
def test_filter_drops_empty_plain_chat_messages_but_keeps_tool_requests() -> None:
msgs = [
_msg("m1", "user", text=""),
_msg("m2", "assistant", text=" "),
_msg(
"m3",
"assistant",
text="",
tool_calls=[ToolCall(id="tc1", function={"name": "f", "arguments": "{}"})],
),
_msg("m4", "user", text="ok"),
]
chat_out = _filter_for_mode(msgs, "chat")
agent_out = _filter_for_mode(msgs, "agent")
assert [m.message_id for m in chat_out] == ["m4"]
assert [m.message_id for m in agent_out] == ["m3", "m4"]
# ── _to_conversation_item dispatch ────────────────────────────────────────