Skip to content

Implement dynamic versions of the resumable code #246

Closed

Description

@abelbraaksma

In rare scenarios, for instance, where the resumable code is invoked in a top-level function, the compiler may not be able to compile the resumable code statically. For these cases, we need a dynamic version of the resumable code (which exists, but currently simply raises an exception).

This issues serves as a placeholder for this.

Activity

  1. added this to the vNext milestone on Mar 18, 2024
  2. added
    enhancement
    performance
    on Mar 7, 2026
  3. github-actions commented on Mar 8, 2026

    @github-actions
  4. dsyme commented on Mar 14, 2026

    @dsyme
    Contributor

    /repo-assist Have a crack at implementing the dynamic versions of resumable code, including very extensive tests.

  5. added a commit that references this issue on Apr 7, 2026
    c603878
  6. github-actions commented on Apr 7, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I've implemented the dynamic resumable code path for this issue. A draft PR has been submitted:

    Branch: repo-assist/feat-dynamic-246-2026-04-07

    What was implemented

    • TaskSeqDynamicInfo<'T> — a concrete ResumptionDynamicInfo subclass that drives the resumption function and handles yield/await/completion via MoveNext, mirroring the logic in the static MoveNextMethodImpl.
    • TaskSeqDynamic<'T> — a reference-type IAsyncEnumerable<'T> that stores the initial ResumptionFunc instead of a compiler-generated struct, with proper clone-on-re-enumerate support.
    • TaskSeqBuilder.Run else branch — now creates a TaskSeqDynamic<'T> instead of raising NotImplementedException.
    • taskSeqDynamic CE builder — inherits TaskSeqBuilder with no overrides; in compiled code it is identical to taskSeq, in FSI it takes the dynamic path automatically.

    Root cause insight

    Storing the compiler-generated machine struct in a base-type field (as was attempted in the commented-out code) loses the specialized IAsyncStateMachine.MoveNext implementation, causing a NullReferenceException. The correct FSI approach is to set ResumptionDynamicInfo on the ResumableStateMachine struct field and let moveNextRef call through to MoveNextDynamic — which the ResumableStateMachine's IAsyncStateMachine.MoveNext handles automatically.

    Test results

    5093 tests pass (24 new + 5069 existing), 0 failures.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@7ee2b60744abf71b985bead4599640f165edcd93
    
  7. added a commit that references this issue on Apr 7, 2026
    4873e88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementperformance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions