fix: add null check for finish reason in completion handling in BaseAgent

This commit is contained in:
extio-de
2026-05-10 10:14:45 +02:00
parent b5a43ef7ac
commit 2028d9bea5

View File

@@ -202,21 +202,23 @@ public interface BaseAgent {
split.context().getGraph().add("(" + durationMs + " ms)"); split.context().getGraph().add("(" + durationMs + " ms)");
split.context().setLastCompletion(completion); split.context().setLastCompletion(completion);
split.context().getRequestStatistic().add(completion); split.context().getRequestStatistic().add(completion);
switch (completion.finishReason()) { if (completion.finishReason() != null) {
case TOKEN_LIMIT_REACHED: switch (completion.finishReason()) {
split.context().getGraph().add("⏹"); case TOKEN_LIMIT_REACHED:
break; split.context().getGraph().add("⏹");
case CONTENT_FILTERED: break;
split.context().getGraph().add("⛔"); case CONTENT_FILTERED:
break; split.context().getGraph().add("⛔");
case TOOL_CALLS: break;
split.context().getGraph().add("🔧"); case TOOL_CALLS:
break; split.context().getGraph().add("🔧");
case ERROR: break;
split.context().getGraph().add("❌"); case ERROR:
continue; split.context().getGraph().add("❌");
default: continue;
break; default:
break;
}
} }
if (!completion.toolCalls().isEmpty() && responseHandler instanceof final ToolCallingAgentResponseHandler toolCallingAgentResponseHandler) { if (!completion.toolCalls().isEmpty() && responseHandler instanceof final ToolCallingAgentResponseHandler toolCallingAgentResponseHandler) {