把当前预算/耗时/HITL 状态推送给 renderer 状态栏。
(AgentBudget budget, long startNanos, String phase)
| 552 | |
| 553 | /** 把当前预算/耗时/HITL 状态推送给 renderer 状态栏。 */ |
| 554 | private void pushStatus(AgentBudget budget, long startNanos, String phase) { |
| 555 | try { |
| 556 | String model = llmClient == null ? "—" : llmClient.getModelName(); |
| 557 | long totalTokens = budget == null ? 0L |
| 558 | : (long) (budget.totalInputTokens() + budget.totalOutputTokens()); |
| 559 | long contextWindow = llmClient == null ? 0L : llmClient.maxContextWindow(); |
| 560 | boolean hitl = Boolean.TRUE.equals(hitlEnabledSupplier.get()); |
| 561 | long elapsed = (System.nanoTime() - startNanos) / 1_000_000L; |
| 562 | String cost = budget == null ? null : TokenUsageFormatter.estimatedCostCny( |
| 563 | llmClient, |
| 564 | budget.totalInputTokens(), |
| 565 | budget.totalOutputTokens(), |
| 566 | budget.totalCachedInputTokens()); |
| 567 | renderer().updateStatus(StatusInfo.tokens( |
| 568 | model, |
| 569 | contextWindow, |
| 570 | budget == null ? 0L : budget.totalInputTokens(), |
| 571 | budget == null ? 0L : budget.totalOutputTokens(), |
| 572 | budget == null ? 0L : budget.totalCachedInputTokens(), |
| 573 | cost, |
| 574 | hitl, |
| 575 | elapsed, |
| 576 | phase == null || phase.isBlank() |
| 577 | ? (totalTokens > 0 || elapsed > 0 ? "running" : "idle") |
| 578 | : phase)); |
| 579 | } catch (Exception e) { |
| 580 | log.debug("status push failed", e); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | private void appendReasoning(StringBuilder reasoningTranscript, String reasoningContent) { |
| 585 | if (reasoningContent == null || reasoningContent.isBlank()) { |
no test coverage detected