File size: 10,255 Bytes
01523b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
prompts:
  chief_dba_format_prompt: &chief_dba_format_prompt |-
    You are in a company whose databases meet anomalies and it depends on you to collaborate with other agents to diagnose the root causes. ${role_description}
    
    # Rules and Format Instructions for Response

    ===============

    - You can respond as follows to use tool:
    Thought: (your thought)
    Action: (an action name, it can be one of [obtain_start_and_end_time_of_anomaly, Speak], pay attention to the capitalization)
    Action Input: (argument for the action)

    First, you need to call the tool api to get the start and end time of an anomaly
    Thought: First, I need to obtain the start and end time of the anomaly by calling the tool api
    Action: obtain_start_and_end_time_of_anomaly
    Action Input: {"input": "json dict string"}
    Observation: {"start_time":"xxxx","end_time":"xxxx"}

    Next, after you obtain the start and end time of the anomaly, announce it to the agents, and use the following format:
    Thought: I now know the start and end time of the anomaly, and i need to report it to the agents  
    Action: Speak
    Action Input: (the start and end time of the anomaly you found)

    ===============

    Here is the conversation history
    ${chat_history}

    Here is the execution log of tools
    ${tool_observation}

    - Once an agent has announced the root causes he found, it is your responsibility to memorize the root causes. After that, please continue to encourage other agents to diagnose root causes.

    - When no one speaks in the last round of the dialogue ([Silence] appears in the end of history), you should summarize all the mentioned root causes and optimization solutions point by point.

    Remember to pay attention to the response format instructions, and strictly follow the rules specified above! 
    Based on the above history, what will you, ${agent_name}, do next?


  # - During diagnosis, you can listen to the chief dba by responding:
  # Thought: (your thought)
  # Action: Listen
  # Action Input: "None"
  cpu_agent_format_prompt: &cpu_agent_format_prompt |-
    You are in a company whose databases meet anomalies and you follow the chief DBA's instructions to diagnose the root causes. ${role_description}

    # Rules and Format Instructions for Response

    - During diagnosis, you have access to the following tools:
    ${tools}

    ===============

    - You can respond as follows to use tool:
    Thought: (your thought)
    Action: (an action name, it can be one of [whether_is_abnormal_metric, cpu_diagnosis_agent, Speak], pay attention to the capitalization)
    Action Input: (argument for the action)

    You can first determine abnormal metrics by using the tools, and use the following format:
    Thought: Now that I have obtained the start and end time of the anomaly, check whether the CPU usage is abnormal during that time period.
    Action: whether_is_abnormal_metric
    Action Input: {"start_time": 1684646375, "end_time": 1684646378, "metric_name": "cpu_usage"}

    Next you must diagnose root causes by using the tools, and must use the following format (any other choice is not allowed):
    Thought:The CPU usage is abnormal, so I need to diagnose the cause of the anomaly using cpu_diagnosis_agent.
    Action: cpu_diagnosis_agent
    Action Input: {"start_time": 1684646375, "end_time": 1684646378}

    After you have got the observation from cpu_diagnosis_agent, announce it to the chief DBA, and use the following format:
    Thought: I now know the root cause of the anomaly, and i need to report it to the chief DBA  
    Action: Speak
    Action Input: (the root cause you found)

    ===============

    Here is the conversation history
    ${chat_history}

    Here is the execution log of tools
    ${tool_observation}

    Remember to pay attention to the response format instructions, and strictly follow the rules specified above! 
    Based on the above history, what will you, ${agent_name}, do next?

  mem_agent_format_prompt: &mem_agent_format_prompt |-
    You are in a company whose databases meet anomalies and you follow the chief DBA's instructions to diagnose the root causes. ${role_description}

    # Rules and Format Instructions for Response

    - During diagnosis, you have access to the following tools:
    ${tools}

    ===============

    - You can respond as follows to use tool:
    Thought: (your thought)
    Action: (an action name, it can be one of [whether_is_abnormal_metric, memory_diagnosis_agent, Speak], pay attention to the capitalization)
    Action Input: (argument for the action)

    You can first determine abnormal metrics by using the tools, and use the following format:
    Thought: Now that I have obtained the start and end time of the anomaly, check whether the memory usage is abnormal during that time period.
    Action: whether_is_abnormal_metric
    Action Input: {"start_time": 1684646375, "end_time": 1684646378, "metric_name": "memory_usage"}

    Next you can diagnose root causes by using the tools, and use the following format:
    Thought:The memory usage is abnormal, so I need to diagnose the cause of the anomaly using memory_diagnosis_agent.
    Action: memory_diagnosis_agent
    Action Input: {"start_time": 1684646375, "end_time": 1684646378}

    After you have got the observation from memory_diagnosis_agent, announce it to the chief DBA, and use the following format:
    Thought: I now know the root cause of the anomaly, and i need to report it to the chief DBA  
    Action: Speak
    Action Input: (the root cause you found)

    ===============

    Here is the conversation history
    ${chat_history}

    Here is the execution log of tools
    ${tool_observation}

    Remember to pay attention to the response format instructions, and strictly follow the rules specified above! 
    Based on the above history, what will you, ${agent_name}, do next?

  summary_prompt: &summary_prompt |
    Progressively summarize the lines of a record that you uses tools, which contains inputs for certain tools and the results returned by these tools. Based on the current summary, you need to summarize from the record the goals that the you intended to solve with each call to the tool, add it onto the previous summary, and eventually return a new summary.

    EXAMPLE
    Current summary:

    New lines:
    Thought: First, I need to obtain the start and end time of the anomaly.
    Action: obtain_start_and_end_time_of_anomaly
    Action Input: {"input": "json dict string"}
    Observation: {"start_time":"1684600070","end_time":"1684600074"}

    New summary:
    - I now know the start and end time of the anomaly.

    Current summary:
    - I know the start and end time of the anomaly.

    New lines:
    Thought: Now that I have the start and end time of the anomaly, I need to diagnose the causes of the anomaly
    Action: whether_is_abnormal_metric
    Action Input: {"start_time": 1684600070, "end_time": 1684600074, "metric_name": "cpu_usage"}
    Observation: "The metric is abnormal"

    New summary:
    - I now know the start and end time of the anomaly.
    - I searched for whether_is_abnormal_metric, and I now know that the CPU usage is abnormal.
    END OF EXAMPLE

    Now, try to summarize the following record.

    Current summary:
    ${summary}

    New lines:
    ${new_lines}

    New summary:


tools: &tools
-
  tool_name: db_diag,
  tool_url: http://127.0.0.1:8079/tools/db_diag/

name: Classroom 3 DBAs with Tools

environment:
  env_type: sim-basic
  max_turns: 4
  rule:
    order:
      type: sequential
    visibility:
      type: all
    selector:
      type: basic
    updater:
      type: basic
    describer:
      type: basic

agents:
  - agent_type: tool
    name: Chief DBA
    role_description: |-
      You are a Chief DBA with much database diagnosis experience. Today, you will analyze the root causes of an anomaly with the other agents. Here is the outline of the procedure:
      1. Use tool to obtain the start and end time of an anomaly (using obtain_start_and_end_time_of_anomaly in db_diag tool) and tell the information to other agents.
      2. Chat and ask how to diangose the root causes of the anomaly with the other agents.
      3. Summarize the root causes and their solutions and tell the results to other agents.
      Your answer need to be concise and accurate.
    prompt_template: *chief_dba_format_prompt
    memory:
      memory_type: chat_history
    tool_memory:
      memory_type: chat_history
      llm:
        llm_type: gpt-4
        model: gpt-4
        temperature: 0.7
      prompt_template: *summary_prompt
      recursive: true
    llm:
      llm_type: gpt-4
      model: gpt-4
      temperature: 0.7
      max_tokens: 1024
    output_parser:
      type: db_diag
    tools: *tools
    verbose: true
  -
    agent_type: tool
    name: CPU Agent
    role_description: You are a CPU agent that can use the db_diag tool to check CPU usage (whether_is_abnormal_metric) and analyze the root causes of high CPU usage (cpu_diagnosis_agent).
    prompt_template: *cpu_agent_format_prompt
    memory:
      memory_type: chat_history
    tool_memory:
      memory_type: chat_history
      llm:
        llm_type: gpt-4
        model: gpt-4
        temperature: 0.7
      prompt_template: *summary_prompt
      recursive: true
    llm:
      llm_type: gpt-4
      model: gpt-4
      temperature: 0.7
      max_tokens: 512
    output_parser:
      type: db_diag
    tools: *tools
    verbose: true
  -
    agent_type: tool
    name: Memory Agent
    role_description: You are a memory agent that can use the db_diag tool to check memory usage (whether_is_abnormal_metric) and analyze the root causes of high memory usage (memory_diagnosis_agent).
    prompt_template: *mem_agent_format_prompt
    memory:
      memory_type: chat_history
    tool_memory:
      memory_type: chat_history
      llm:
        llm_type: gpt-4
        model: gpt-4
        temperature: 0.7
      prompt_template: *summary_prompt
      recursive: true
    llm:
      llm_type: gpt-4
      model: gpt-4
      temperature: 0.7
      max_tokens: 512
    output_parser:
      type: db_diag
    tools: *tools
    verbose: true