Skip to content

feat(agent): add MOA progress indicator (#59546) - #59646

Closed
SquabbyZ wants to merge 1 commit into
NousResearch:mainfrom
SquabbyZ:fix/easy-02-issue-59546
Closed

feat(agent): add MOA progress indicator (#59546)#59646
SquabbyZ wants to merge 1 commit into
NousResearch:mainfrom
SquabbyZ:fix/easy-02-issue-59546

Conversation

@SquabbyZ

@SquabbyZ SquabbyZ commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #59546

Summary

Adds a minimal MOA progress indicator to the existing display pipeline so TUI / CLI / desktop surfaces can render a status bar like MOA: 2/3 refs done and surface which phase of the MoA pipeline is currently active (reference fan-out vs aggregator synthesis). The MoA flow is no longer a black box while it runs.

Changes

  • agent/moa_loop.py — emits two new events on the existing reference_callback surface:
    • moa.progress — fired once per reference completion with refs_done, refs_total, and the source-model label (drives the status-bar counter).
    • moa.phase — fired on phase transitions, currently phase="aggregator" once the fan-out finishes and the aggregator is about to act.
    • The legacy moa.reference / moa.aggregating events are unchanged for backwards compatibility.
  • agent/agent_init.py — relays the two new events through the existing tool_progress_callback so every surface that already consumes MoA events (CLI scrollback, TUI, desktop, gateway) sees them automatically.
  • tui_gateway/server.py — emits moa.progress and moa.phase to the TUI / Ink client with a typed payload.
  • tests/agent/test_moa_progress.py — five new unit tests covering per-reference progress emission, phase-transition marker, counter monotonicity, event ordering, and the no-callback safety path.

The fan-out itself is unchanged — this is purely a display-layer addition plumbed into the existing trace mechanism. No re-architecture.

How to test

  1. Pull the branch and run the new unit tests:
    python -m pytest tests/agent/test_moa_progress.py -v
    
    All five tests should pass.
  2. Run the full MOA suite to confirm no regression:
    python -m pytest tests/agent/test_moa_aggregator_cost_slot.py tests/agent/test_moa_aggregator_cache_control.py tests/agent/test_moa_slot_api_mode.py tests/agent/test_moa_switch_api_mode.py tests/agent/test_moa_trace_streamed_capture.py tests/tui_gateway/test_moa_reference_emit.py
    
  3. In the live CLI, configure a MoA preset with ≥ 2 references and watch the status bar / scrollback. Each reference completion now advances a refs_done/refs_total counter and a moa.phase=aggregator marker fires right before the aggregator acts.

Platforms tested

  • Windows 11 (Python 3.11.15, pytest 9.1.1)
  • Unit tests run green; existing MOA regression suite still green.

AI-assisted fix by https://github.com/SquabbyZ/peaks-loop

Adds per-reference progress events and a phase-transition marker to the
MoA display pipeline so TUI / CLI / desktop surfaces can render a status
bar like `MOA: 2/3 refs done` and surface which phase (reference vs
aggregator) is currently active.

  - `moa.progress`  — fired once per reference completion with
                       `refs_done`, `refs_total`, and the source label
  - `moa.phase`     — fired on phase transitions (currently the single
                       `phase="aggregator"` transition once the fan-out
                       finishes)

Plumbed through the existing `reference_callback` →
`tool_progress_callback` → gateway path; no new UI surface. The legacy
`moa.reference` / `moa.aggregating` events are unchanged for backwards
compatibility.

AI-assisted fix by https://github.com/SquabbyZ/peaks-loop
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jul 6, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for exposing the MoA execution path. The backend event idea matches issue #59546, but this version does not yet reach a visible UI.

Problems

  • The diff changes only agent/agent_init.py, agent/moa_loop.py, tui_gateway/server.py, and a Python test. Current TUI protocol/dispatch recognizes only moa.reference and moa.aggregating (ui-tui/src/gatewayTypes.ts:662-668, ui-tui/src/app/createGatewayEventHandler.ts:691-704), and StatusRule has no MoA progress input (ui-tui/src/components/appChrome.tsx:405-425). moa.progress and moa.phase will therefore be dropped rather than render the requested status bar.
  • The new loop iterates futures.items() and waits with future.result(). That is submission order, not completion order, so the advertised completion counter can lag behind already-finished references.
  • The new ordering test says progress follows its matching reference, but it never asserts that relationship. The proposed flow emits progress during fan-out; reference events are emitted only afterward (agent/moa_loop.py:1040-1059 on current main).

Suggested changes

  • Wire the events into the TUI state/StatusRule and add client rendering tests.
  • Use as_completed for progress emission while retaining stable result ordering.
  • Assert the full event ordering with delayed reference stubs.

Automated hermes-sweeper review.

Comment thread agent/moa_loop.py
@@ -381,6 +390,13 @@ def _run_references_parallel(
# complete set, so there is no early-exit / first-completed path here.
for future, idx in futures.items():
results[idx] = future.result()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

futures.items() preserves submission order, and future.result() blocks on each earlier future. A later, already-completed reference cannot advance this counter until every earlier submission resolves, so this is not completion-order progress. Please use as_completed with a future-to-index map.

Comment thread tui_gateway/server.py
if event_type == "moa.aggregating":
_emit("moa.aggregating", sid, {"aggregator": str(name or "")})
return
if event_type == "moa.progress":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a gateway event, but the PR does not update ui-tui/src/gatewayTypes.ts, createGatewayEventHandler.ts, or StatusRule state/rendering. Current clients will not consume this event, so the requested visible progress indicator is not implemented.

)

# Walk the events; every progress event must be preceded by its reference
# text event (matching ``index``). The full sequence ends with the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test description says each progress event must be preceded by its matching moa.reference, but the loop only checks independent counter bounds. Please assert the captured event sequence; the proposed implementation emits progress during fan-out before its later reference-emission loop.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 15, 2026
teknium1 added a commit that referenced this pull request Jul 24, 2026
….phase

Frontend consumers for the events added by PR #59646: the TUI shows a
replace-in-place 'MoA: refs k/n' activity line (swapped for 'MoA:
aggregating…' on the aggregator phase), and desktop streams '◇ MoA refs
k/n' lines into the reasoning disclosure, self-cleaned by the first
moa.reference block.
teknium1 added a commit that referenced this pull request Jul 24, 2026
….phase

Frontend consumers for the events added by PR #59646: the TUI shows a
replace-in-place 'MoA: refs k/n' activity line (swapped for 'MoA:
aggregating…' on the aggregator phase), and desktop streams '◇ MoA refs
k/n' lines into the reasoning disclosure, self-cleaned by the first
moa.reference block.
teknium1 added a commit that referenced this pull request Jul 24, 2026
….phase

Frontend consumers for the events added by PR #59646: the TUI shows a
replace-in-place 'MoA: refs k/n' activity line (swapped for 'MoA:
aggregating…' on the aggregator phase), and desktop streams '◇ MoA refs
k/n' lines into the reasoning disclosure, self-cleaned by the first
moa.reference block.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via cluster PR #70283 (commit 385a065) — your commit cherry-picked with authorship preserved, plus frontend consumers we added on top (TUI 'MoA: refs k/n' + desktop event registration) so #59546's indicator is user-visible, not plumbing-only. Your event design (moa.progress/moa.phase) is unchanged. Thanks!

@teknium1 teknium1 closed this Jul 24, 2026
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
….phase

Frontend consumers for the events added by PR NousResearch#59646: the TUI shows a
replace-in-place 'MoA: refs k/n' activity line (swapped for 'MoA:
aggregating…' on the aggregator phase), and desktop streams '◇ MoA refs
k/n' lines into the reasoning disclosure, self-cleaned by the first
moa.reference block.
prmartinow pushed a commit to prmartinow/hermes-agent that referenced this pull request Aug 26, 2026
….phase

Frontend consumers for the events added by PR NousResearch#59646: the TUI shows a
replace-in-place 'MoA: refs k/n' activity line (swapped for 'MoA:
aggregating…' on the aggregator phase), and desktop streams '◇ MoA refs
k/n' lines into the reasoning disclosure, self-cleaned by the first
moa.reference block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: MOA 建议加上进度提示

3 participants