Skip to content

refactor(runtime): remove the unused AgentRun.execute execution path #3034

Closed

Description

@Astro-Han

Problem

AgentRun currently exposes two ways to execute a run:

  1. AgentRun.execute() constructs and drives AiSdkFlow itself.
  2. The production path uses RuntimeKernel, which calls AgentRun.begin() and owns flow execution, lifecycle, cancellation, steering, and finalization.

The first path has no production caller and is not exported through the Runtime package entry point. Only four direct calls in session-manager-terminal-ledger.test.ts exercise it.

Keeping both paths creates two execution authorities inside Runtime. AgentRun.execute() also reconstructs invocation state and hard-codes source: 'desktop', so future lifecycle changes can drift from the Runtime Kernel path without affecting production tests.

Proposed change

  • Remove AgentRun.execute().
  • Keep AgentRun.begin(), event acceptance, persistence, failure recording, and finalization as the lifecycle seam consumed by RuntimeKernel.
  • Rewrite the affected tests against the production execution path or narrower AgentRun lifecycle methods.
  • Remove imports and helpers used only by execute().

Acceptance criteria

  • AgentRun.execute() no longer exists.
  • Runtime has one production execution path through RuntimeKernel.
  • The affected terminal-ledger behavior remains covered without a test-only execution authority.
  • No externally observable Runtime behavior changes.
  • Focused Runtime tests, type checking, and formatting pass.

Non-goals

  • Changing AiSdkFlow behavior.
  • Changing RuntimeEvent or SessionEvent semantics.
  • Moving persistence or terminal-state ownership out of AgentRun.
  • Exporting AgentRun as a public API.

Context

Verified on main at 1a71db5c0fa85771330354360388ecf47ba95c2e.

Relevant code:

  • packages/runtime/src/agent-run.ts
  • packages/runtime/src/runtime-kernel.ts
  • packages/runtime/src/__tests__/session-manager-terminal-ledger.test.ts

This issue was identified and prepared with AI assistance (Codex). A human contributor reviewed the analysis and owns the submission.

Activity

  1. self-assigned this
    on Aug 15, 2026
  2. Astro-Han commented on Aug 15, 2026

    @Astro-Han
    ContributorAuthor

    I’d like to work on this. I’ll remove AgentRun.execute(), migrate the four direct tests to the production Runtime Kernel / AgentRun lifecycle seam, and keep observable behavior unchanged. I’ll open a draft PR with focused Runtime validation.

    This comment will be posted by Codex with @Astro-Han’s approval.

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions