| from typing import List, Optional | |
| from pmcp.agents.agent_base import AgentBlueprint | |
| from langchain_core.tools import BaseTool | |
| from langchain_core.messages import HumanMessage | |
| from langchain_openai import ChatOpenAI | |
| from langgraph.types import Command | |
| from pmcp.models.resume_trigger import ResumeTrigger | |
| from loguru import logger | |
| SYSTEM_PROMPT = """ | |
| You are a Human Resumer Agent responsible for understading the user indication on whether to procede or not with an action. | |
| You have to identify: | |
| - if the user express some changes or confirm directly | |
| - which changes the user wants to apply | |
| """ | |
| class HumanResumeNode: | |
| def __init__(self, llm: ChatOpenAI, tools: Optional[List[BaseTool]] = None): | |
| self.agent = AgentBlueprint( | |
| agent_name="HUMAN_REVIEWER_AGENT", | |
| description="The agent asks for human confirmation", | |
| tools=tools, | |
| system_prompt=SYSTEM_PROMPT.strip(), | |
| llm=llm, | |
| ) | |
| def call_human_interrupt_agent(self, user_message: str): | |
| logger.info("Human resumer agent...") | |
| response = self.agent.call_agent_structured( | |
| [ | |
| HumanMessage(content=user_message), | |
| ], | |
| clazz=ResumeTrigger, | |
| ) | |
| return Command(resume=response) | |