Skip to content

Commit cf70562

Browse files
Fix error log to show the right agent type (#2809) (#3131)
Signed-off-by: Heng Qian <[email protected]> (cherry picked from commit 1bbaddd) Co-authored-by: qianheng <[email protected]>
1 parent f5287e4 commit cf70562

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutor.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,12 @@ public void execute(Input input, ActionListener<Output> listener) {
135135
(ConversationIndexMemory.Factory) memoryFactoryMap.get(memorySpec.getType());
136136
conversationIndexMemoryFactory.create(question, memoryId, appType, ActionListener.wrap(memory -> {
137137
inputDataSet.getParameters().put(MEMORY_ID, memory.getConversationId());
138-
ActionListener<Object> agentActionListener = createAgentActionListener(listener, outputs, modelTensors);
138+
ActionListener<Object> agentActionListener = createAgentActionListener(
139+
listener,
140+
outputs,
141+
modelTensors,
142+
mlAgent.getType()
143+
);
139144
// get question for regenerate
140145
if (regenerateInteractionId != null) {
141146
log.info("Regenerate for existing interaction {}", regenerateInteractionId);
@@ -161,7 +166,12 @@ public void execute(Input input, ActionListener<Output> listener) {
161166
listener.onFailure(ex);
162167
}));
163168
} else {
164-
ActionListener<Object> agentActionListener = createAgentActionListener(listener, outputs, modelTensors);
169+
ActionListener<Object> agentActionListener = createAgentActionListener(
170+
listener,
171+
outputs,
172+
modelTensors,
173+
mlAgent.getType()
174+
);
165175
executeAgent(inputDataSet, mlAgent, agentActionListener);
166176
}
167177
}
@@ -235,7 +245,8 @@ private void executeAgent(RemoteInferenceInputDataSet inputDataSet, MLAgent mlAg
235245
private ActionListener<Object> createAgentActionListener(
236246
ActionListener<Output> listener,
237247
List<ModelTensors> outputs,
238-
List<ModelTensor> modelTensors
248+
List<ModelTensor> modelTensors,
249+
String agentType
239250
) {
240251
return ActionListener.wrap(output -> {
241252
if (output != null) {
@@ -275,7 +286,7 @@ private ActionListener<Object> createAgentActionListener(
275286
listener.onResponse(null);
276287
}
277288
}, ex -> {
278-
log.error("Failed to run flow agent", ex);
289+
log.error("Failed to run " + agentType + " agent", ex);
279290
listener.onFailure(ex);
280291
});
281292
}

0 commit comments

Comments
 (0)