feat: add finish reason indicators for completion statuses in BaseAgent

This commit is contained in:
extio-de
2026-05-10 09:48:04 +02:00
parent 640b075fe6
commit b5a43ef7ac
2 changed files with 21 additions and 0 deletions

View File

@@ -899,6 +899,10 @@ Each context accumulates a graph trace that documents the path through the flow.
| `M`, `S`, `L`, `HOT`, `COLD` | Model category short name | | `M`, `S`, `L`, `HOT`, `COLD` | Model category short name |
| agent name | Executed agent | | agent name | Executed agent |
| `○` | Completion skipped | | `○` | Completion skipped |
| `⏹` | Completion stopped because the token limit was reached |
| `⛔` | Completion stopped because the content was filtered |
| `🔧` | Completion stopped because the model returned tool calls |
| `❌` | Completion stopped because of an remote error |
| `⇉ x/n` | Branch split x of n | | `⇉ x/n` | Branch split x of n |
| `size↣merged` | Merge size summary | | `size↣merged` | Merge size summary |
| `→` | Next agent is a `COMPLETION` agent | | `→` | Next agent is a `COMPLETION` agent |

View File

@@ -202,6 +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()) {
case TOKEN_LIMIT_REACHED:
split.context().getGraph().add("⏹");
break;
case CONTENT_FILTERED:
split.context().getGraph().add("⛔");
break;
case TOOL_CALLS:
split.context().getGraph().add("🔧");
break;
case ERROR:
split.context().getGraph().add("❌");
continue;
default:
break;
}
if (!completion.toolCalls().isEmpty() && responseHandler instanceof final ToolCallingAgentResponseHandler toolCallingAgentResponseHandler) { if (!completion.toolCalls().isEmpty() && responseHandler instanceof final ToolCallingAgentResponseHandler toolCallingAgentResponseHandler) {
if (toolCallRounds >= 6) { if (toolCallRounds >= 6) {
parseException = new IllegalStateException("Too many tool call rounds"); parseException = new IllegalStateException("Too many tool call rounds");