YAML-native Agent that executes YAML workflow definitions. This class is the main entry point for running YAML-defined workflows. It coordinates between the MCP client for tool execution, the LLM client for completions, and the Interpreter for step execution. Attributes: mc
| 48 | |
| 49 | |
| 50 | class AgentSPEX: |
| 51 | """YAML-native Agent that executes YAML workflow definitions. |
| 52 | |
| 53 | This class is the main entry point for running YAML-defined workflows. |
| 54 | It coordinates between the MCP client for tool execution, the LLM client |
| 55 | for completions, and the Interpreter for step execution. |
| 56 | |
| 57 | Attributes: |
| 58 | mcp_url: URL of the MCP server. |
| 59 | llm_client: LLMClient for LLM completions (supports multiple providers via LiteLLM). |
| 60 | mcp_client: MCP client for tool invocation. |
| 61 | tools: List of available tool definitions. |
| 62 | submodule_tools: List of submodule tool definitions. |
| 63 | submodule_registry: Registry of submodule specifications. |
| 64 | agent_interpreter: Interpreter for executing workflow steps. |
| 65 | usage_tracker: Dict tracking token usage across the workflow. |
| 66 | |
| 67 | Example: |
| 68 | agent = AgentSPEX( |
| 69 | mcp_url="http://localhost:8080", |
| 70 | tool_config_fp="tools.json", |
| 71 | ) |
| 72 | result = agent.run(args) |
| 73 | |
| 74 | # With custom LLM configuration (e.g., local vLLM server) |
| 75 | llm_config = LLMConfig(api_base="http://localhost:8000") |
| 76 | agent = AgentSPEX( |
| 77 | mcp_url="http://localhost:8080", |
| 78 | llm_config=llm_config, |
| 79 | ) |
| 80 | """ |
| 81 | |
| 82 | # Step execution methods delegated to agent_interpreter |
| 83 | _DELEGATED_METHODS: FrozenSet[str] = frozenset( |
| 84 | { |
| 85 | "execute_basic_step", |
| 86 | "execute_task_step", |
| 87 | "execute_for_each_step", |
| 88 | "execute_conditional_step", |
| 89 | "execute_parallel_step", |
| 90 | "execute_while_step", |
| 91 | "execute_switch_step", |
| 92 | "execute_increment_step", |
| 93 | "execute_set_variable_step", |
| 94 | "execute_return_step", |
| 95 | "execute_input_step", |
| 96 | "execute_call_step", |
| 97 | "execute_gather_step", |
| 98 | "execute_workflow_step", |
| 99 | } |
| 100 | ) |
| 101 | |
| 102 | def __init__( |
| 103 | self, |
| 104 | mcp_url: Optional[str] = None, |
| 105 | tool_config_fp: Optional[str] = None, |
| 106 | *, |
| 107 | session_id: Optional[str] = None, |
no outgoing calls