Build a {"messages": [...]} LangGraph input from resolved items.
Prepends a SystemMessage when instructions is non-empty. Empty
item lists yield an empty messages list — callers should typically have
at least one user message before invoking the graph.
Incomplete tool-call sequences are filtered out: any AIMessage with
unanswered tool_calls and any orphan ToolMessage (whose
tool_call_id has no matching preceding AIMessage.tool_calls
entry) are dropped. This prevents poisoned conversation history —
e.g. one containing a function_call_output from a prior failed
request — from producing a message list the chat model would reject
("messages with role 'tool' must be a response to a preceding message
with 'tool_calls'").
Forwarded to :func:items_to_messages. Used by the
HITL resume path to filter out the resume function_call_output.