mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-14 04:02:26 +00:00
fix(tui): address Copilot review on #14045
Four real issues Copilot flagged:
1. delegate_tool: `_build_child_agent` never passed `toolsets` to the
progress callback, so the event payload's `toolsets` field (wired
through every layer) was always empty and the overlay's toolsets
row never populated. Thread `child_toolsets` through.
2. event handler: the race-protection on subagent.spawn_requested /
subagent.start only preserved `completed`, so a late-arriving queued
event could clobber `failed` / `interrupted` too. Preserve any
terminal status (`completed | failed | interrupted`).
3. SpawnHud: comment claimed concurrency was approximated by "widest
level in the tree" but code used `totals.activeCount` (total across
all parents). `max_concurrent_children` is a per-parent cap, so
activeCount over-warns for multi-orchestrator runs. Switch to
`max(widthByDepth(tree))`; the label now reads `⚡W/cap+extra` where
W is the widest level (drives the ratio) and `+extra` is the rest.
4. spawn_tree.list: comment said "peek header without parsing full list"
but the code json.loads()'d every snapshot. Adds a per-session
`_index.jsonl` sidecar written on save; list() reads only the index
(with a full-scan fallback for pre-index sessions). O(1) per
snapshot now vs O(file-size).
This commit is contained in:
parent
f06adcc1ae
commit
dee51c1607
4 changed files with 84 additions and 15 deletions
|
|
@ -8,7 +8,7 @@ import { FACES } from '../content/faces.js'
|
|||
import { VERBS } from '../content/verbs.js'
|
||||
import { fmtDuration } from '../domain/messages.js'
|
||||
import { stickyPromptFromViewport } from '../domain/viewport.js'
|
||||
import { buildSubagentTree, treeTotals } from '../lib/subagentTree.js'
|
||||
import { buildSubagentTree, treeTotals, widthByDepth } from '../lib/subagentTree.js'
|
||||
import { fmtK } from '../lib/text.js'
|
||||
import type { Theme } from '../theme.js'
|
||||
import type { Msg, Usage } from '../types.js'
|
||||
|
|
@ -82,10 +82,14 @@ function SpawnHud({ t }: { t: Theme }) {
|
|||
const depth = Math.max(0, totals.maxDepthFromHere)
|
||||
const active = totals.activeCount
|
||||
|
||||
// Concurrency here is "concurrent top-level spawns per parent at the
|
||||
// tightest branch" — approximated by the widest level in the tree.
|
||||
// `max_concurrent_children` is a per-parent cap, not a global one.
|
||||
// `activeCount` sums every running agent across the tree and would
|
||||
// over-warn for multi-orchestrator runs. The widest level of the tree
|
||||
// is a closer proxy to "most concurrent spawns that could be hitting a
|
||||
// single parent's slot budget".
|
||||
const widestLevel = widthByDepth(tree).reduce((a, b) => Math.max(a, b), 0)
|
||||
const depthRatio = maxDepth ? depth / maxDepth : 0
|
||||
const concRatio = maxConc ? active / maxConc : 0
|
||||
const concRatio = maxConc ? widestLevel / maxConc : 0
|
||||
const ratio = Math.max(depthRatio, concRatio)
|
||||
|
||||
const color = delegation.paused || ratio >= 1 ? t.color.error : ratio >= 0.66 ? t.color.warn : t.color.dim
|
||||
|
|
@ -101,8 +105,13 @@ function SpawnHud({ t }: { t: Theme }) {
|
|||
pieces.push(`d${depthLabel}`)
|
||||
|
||||
if (active > 0) {
|
||||
const concLabel = maxConc ? `${active}/${maxConc}` : `${active}`
|
||||
pieces.push(`⚡${concLabel}`)
|
||||
// Label pairs the widest-level count (drives concRatio above) with
|
||||
// the total active count for context. `W/cap` triggers the warn,
|
||||
// `+N` is everything else currently running across the tree.
|
||||
const extra = Math.max(0, active - widestLevel)
|
||||
const widthLabel = maxConc ? `${widestLevel}/${maxConc}` : `${widestLevel}`
|
||||
const suffix = extra > 0 ? `+${extra}` : ''
|
||||
pieces.push(`⚡${widthLabel}${suffix}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue