Status: done
Reject provider-invalid API message roles and malformed tool replies before runtime work or network calls.
The UI no longer exposes tool pre-messages, and the OpenAI client rejects tool messages without tool_call_id. API callers can still send arbitrary role values in pre_messages, which can fail later at the provider boundary. The request contract should fail fast.
This todo covers:
ChatMessage.role to Chat Completions-compatible roles.pre_messages with role="tool" in DebugRunRequest, because request pre-messages cannot provide a matching assistant tool_calls context safely.This todo does not cover:
src/agent_lab/domain/messages.pysrc/agent_lab/application/contracts.pytests/test_websocket_api.py or add focused contract tests.DebugRunRequest.model_validate();pre_messages with role="tool" is rejected before runtime;ChatMessage(role="tool", tool_call_id="...") remains valid.Literal role type in ChatMessage.DebugRunRequest validator that rejects tool pre-messages.Run:
uv run pytest tests/test_websocket_api.py tests/test_event_agent.py
uv run pytest
Update this plan and docs/plans/todos.md, then commit.
Result:
uv run pytest tests/test_websocket_api.py tests/test_event_agent.py passed: 21 tests, 1 existing Starlette deprecation warning.uv run pytest passed: 34 tests, 1 existing Starlette deprecation warning.ChatMessage.role now accepts only system, user, assistant, or tool.DebugRunRequest rejects tool entries in pre_messages, so API callers cannot send orphan tool replies as front-loaded context.