Skip to content

refactor(runtime): remove the dead second Agent Graph drive loop #3086

Closed

Description

@Astro-Han

Problem

packages/runtime contains a second, independently-written drive-to-quiescence scheduling loop that production never runs:

  • runAgentGraphToQuiescence + its helpers (observeGraph, dispatchIntent, orderedRunnableIntents, graphResult, …) in stream-graph-dispatch.ts are called only by tests; the live loop is reconcileAgentGraphSchedule in stream-graph-schedule-reconcile.ts, and the two already drift (limit_reached vs graph_closed/agent_topology_required).
  • resolvePolicies is provided only in tests, so production readiness snapshots are always empty; the host protocol even validates a policyKind value that can never occur.
  • The stream-graph-trace.ts snapshot builder (~390 lines) is kept alive only by the readiness path.

This is a synchronized parallel path: two scheduling state machines that must agree by discipline and are already diverging. Scope boundary: the map/all_settled readiness primitives are NOT in scope — the Desktop topology view (#2596) depends on the read model's readiness, so they must stay.

Desired outcome

One Agent Graph scheduling authority: reconcileAgentGraphSchedule only. Remove the test-only second loop, the dead readiness wiring, the never-produced policyKind protocol validation, and the trace cascade, while keeping the readiness primitives and their client surface intact.

Alternatives or workarounds

Keep the second loop and its tests; it is already drifting from what runs.

Acceptance

  • runAgentGraphToQuiescence and its production-unreachable helpers are removed
  • resolvePolicies / policyKind wiring reduced to what the live readiness surface needs
  • stream-graph-trace.ts trimmed or removed where only the dead path used it
  • Host protocol agent-graph.ts no longer validates an unproducible policyKind
  • Readiness primitives (map/all_settled) retained and pinned by the feat(desktop): add an operational topology view for Agent Graph #2596 consumer
  • Focused runtime tests, typecheck, and Biome pass

Related

Activity

  1. added
    enhancement
    help wanted
    on Aug 15, 2026
  2. 1625567290 commented on Aug 16, 2026

    @1625567290
    Contributor

    I'm working on this. I'll remove the test-only runAgentGraphToQuiescence loop and its helpers so reconcileAgentGraphSchedule is the only Agent Graph scheduling authority. The unused resolvePolicies hook goes with it. map/all_settled readiness primitives and stream-graph-trace stay for the live snapshot / Desktop topology surface (#2596).

    Grok is assisting with the implementation; I will review the change and remain the human contributor of record.

    简体中文对照

    我来处理。删除仅测试路径使用的 runAgentGraphToQuiescence 及其辅助函数,让 reconcileAgentGraphSchedule 成为唯一调度权威。一并去掉生产从未接入的 resolvePolicies。map/all_settled 就绪原语和 stream-graph-trace 保留,供 live snapshot 与 Desktop topology(#2596)使用。

    Grok 协助实现;我会审阅改动,并作为 human contributor of record。

  3. added a commit that references this issue on Aug 16, 2026
    f6bee6d
  4. added a commit that references this issue on Aug 16, 2026
    8a11c9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions