79721508

Date: 2025-07-31 15:19:21
Score: 0.5
Natty:
Report link

So you want access to first human message all the time? Why not modify your AgentState and add a node to your graph, so the subsequent nodes can also access it.

Something like:

def get_initial_human_content(state):
    for msg in state['messages']:
        if isinstance(msg, HumanMessage):
            return msg.content
    return None

class AgentState(TypedDict):
    # The add_messages function defines how an update should be processed
    # Default is to replace. add_messages says "append"
    messages: Annotated[Sequence[BaseMessage], add_messages]
    initial_human_content: str
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Rinato Fenice