|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +"""CI Analysis coordinator: provide root cause analysis for CI failures""" |
| 16 | + |
1 | 17 | from google.adk.agents import LlmAgent |
2 | | -from google.adk.models.lite_llm import LiteLlm |
3 | | -from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters |
| 18 | +from google.adk.tools.agent_tool import AgentTool |
| 19 | + |
| 20 | +from . import prompt |
| 21 | +from .sub_agents.installation_analyst import installation_analyst_agent |
| 22 | +from .sub_agents.mustgather_analyst import mustgather_analyst_agent |
| 23 | +MODEL = "gemini-2.0-flash" |
4 | 24 |
|
5 | 25 |
|
6 | | -# TARGET_FOLDER_PATH = os.path.dirname(os.path.abspath(__file__)) |
7 | | - |
8 | | -root_agent = LlmAgent( |
9 | | - name="root_agent_v1", |
10 | | - # model="gemini-2.5-pro-preview-05-06", |
11 | | - model="gemini-2.0-flash", |
12 | | - # model=LiteLlm(model="ollama/qwen3:4b"), |
13 | | - description="Provides analysis of CI jobs, and determines if the cluster installation was successful or not.", |
14 | | - global_instruction="You are a helpful Kubernetes and Prow expert assistant. " |
15 | | - "You are specialized in Openshift installation." |
16 | | - "Your main goal is to analyze the Prow job's installation logs and diagnose possible failures of the cluster installation for the Prow job." |
17 | | - "You provide root cause analysis for installation failures and propose solutions if possible." |
18 | | - "You are truthful, concise, and helpful." |
19 | | - "You never speculate about clusters being installed or fabricate information." |
20 | | - "If you do not know the answer, you acknowledge the fact and end your response." |
21 | | - "Your responses must be as short as possible." |
22 | | - "CI JOB ANALYSIS WORKFLOW:" |
23 | | - "-------------------------" |
24 | | - "When analyzing a job failure, follow this recommended workflow:" |
25 | | - "1. First, get a job's metadata (including test_name) and status by using 'get_job_metadata' tool." |
26 | | - "2. Then, once you have the metadata, you can get install logs by using the 'get_install_logs' tool." |
27 | | - "3. Check that the installation was successful by looking at the install logs." |
28 | | - "4. Only if installation is successful, use 'get_build_logs' to get the job logs." |
29 | | - "5. Analyze the job build logs to determine the root cause of the failure.", |
30 | | - |
31 | | - tools=[ |
32 | | - MCPToolset( |
33 | | - connection_params=StdioServerParameters( |
34 | | - command='podman', |
35 | | - args=["run", "-i", "-p", "9000:8000", "--rm", "-e", "MCP_TRANSPORT=stdio", "localhost/mcp-server-template:latest"], |
36 | | - tool_filter=['get_build_logs','get_install_logs', 'get_job_metadata'], |
37 | | - ) |
38 | | - ), |
39 | | - ], |
| 26 | +ci_analysis_advisor = LlmAgent( |
| 27 | + name="ci_analysis_advisor", |
| 28 | + model=MODEL, |
| 29 | + description=( |
| 30 | + "Analyzes of CI jobs, and provide root cause analysis for failures." |
| 31 | + ), |
| 32 | + instruction=prompt.CI_ANALYSIS_COORDINATOR_PROMPT, |
| 33 | + output_key="ci_analysis_advisor_output", |
| 34 | + tools=[ |
| 35 | + AgentTool(agent=installation_analyst_agent), |
| 36 | + AgentTool(agent=mustgather_analyst_agent), |
| 37 | + ], |
40 | 38 | ) |
41 | 39 |
|
| 40 | +root_agent = ci_analysis_advisor |
0 commit comments