populateInvocationAgentStates
Populates agent states for the current invocation if it is resumable.
For history events that contain agent state information, set the agentState and endOfAgent of the agent that generated the event.
For non-workflow agents, also set an initial agentState if it has already generated some contents.