File tree Expand file tree Collapse file tree
src/main/java/io/github/easy4j/codex/appserver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -344,11 +344,19 @@ private void onTurnCompleted(JsonNode params) {
344344 .threadId (threadId )
345345 .turnId (turnId )
346346 .content (finalContent )
347- .finishReason ("stop" )
347+ .finishReason (extractFinishReason ( params ) )
348348 .build ());
349349 close ();
350350 }
351351
352+ private String extractFinishReason (JsonNode params ) {
353+ String status = firstText (params .path ("turn" ), "status" );
354+ if (!hasText (status )) {
355+ status = firstText (params , "status" , "reason" );
356+ }
357+ return hasText (status ) ? status : "completed" ;
358+ }
359+
352360 private CompletableFuture <JsonNode > newRpc (String method , Map <String , Object > params ) {
353361 long id = rpcIds .incrementAndGet ();
354362 Map <String , Object > payload = new LinkedHashMap <>();
You can’t perform that action at this time.
0 commit comments