kodeagent.kutils.validate_chat_history#

kodeagent.kutils.validate_chat_history(history: list[dict], tool_names: set[str] | None = None) None[source]#

Validate that a provided chat history is OpenAI-compliant.

Performs stringent structural and semantic checks on each message. Raises ValueError with a precise description on the first problem found.

Parameters:
  • history – The chat history to validate. Must be a non-empty list[dict].

  • tool_names – Optional set of tool names registered on the agent. When provided, tool call names not in this set emit a logger.warning.

Raises:

ValueError – If the history fails any structural or compliance check.