← Back to Pull requests

An included block can continue its caller's agent session #6480

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 29, 2026 04:55 UTC
Author

Problem and outcome

A step inside an include: block couldn't continue a session its caller started, because context.resume in a block could name only the block's own steps. So a workflow where many steps continue one agent's session couldn't be split into blocks.

  • Outcome: a block declares inputs.<name>.session: true, the caller passes one of its steps through with:, and block steps continue it with context.resume: $INPUTS.<name>. A workflow built from blocks makes the same provider calls, continuing the same sessions, as the same workflow written inline.

  • Invariant: includes are still expanded before the run. A session input is a step name filled in at load; it never exists at run time. Continuing the session uses the existing named-resume behavior.

  • Scope boundary: how a named resume continues a session doesn't change (see #6470 and #6471). Fan-out includes don't take session inputs. Workflows without session inputs load and run as before.
  • Review guidance

  • Feedback requested: which sessions a block can reach, the provider checks once includes are expanded, and refusing to start a block on its own.

  • Start here: packages/workflows/src/include/inputs-macro.ts, where the step a caller passes in with: becomes the block step's context.resume.

  • Review order: include/inputs-macro.ts → include-expander.ts and include/inline.ts (nested includes and loop bodies) → loader/session-inputs.ts, loader/dag-structure.ts and loader/provider-checks.ts (checks once includes are expanded) → utils/workflow-requirements.ts and run-dispatch.ts (starting a block on its own) → exec-input-validation.ts and include/command-prompts.ts (a session input used as a value).

  • Lower-attention areas: the regenerated packages/web/src/lib/api.generated.d.ts (one field: the input's session flag), the reference doc and the row added to .archon/workflow-language-constitution.md.

  • Known risk or uncertainty: a block step that continues a session from a step on a different provider, when both providers are known at load, now fails at load instead of when the step starts. When a provider isn't known at load, the existing run-time check in selectNamedSession still applies.
  • Solution

    When includes are expanded, each block step whose context.resume names a session input gets what the caller passed instead: one of the caller's steps, an include's result, or the caller's own session input, which is filled in again one level up. That works through nested includes and loop_group bodies. Each step records which include and with: entry chose its session, so errors name the caller's entry rather than a generated id. The existing checks then run on the expanded workflow: the step being continued must run first, must produce a session, and must use a compatible provider when both are known.

    A session input is refused anywhere it would be used as a value: prompts, command files, include when: conditions, nested with: values and script environments. A workflow that declares one runs only when included, so every attempt to start it on its own is refused before any step runs. A session input that nothing uses or passes on loads with a warning.

    Two smaller fixes came with this. A block that fails to load is reported to its includer with the block's own error and file, instead of "not found". And an installed pack's load errors carry the pack's name, so they can't be mistaken for a project workflow of the same name.

    Behavior change

    | | Before | After |
    |---|---|---|
    | Observable behavior | A block could continue only its own steps' sessions. | A block can continue a session its caller passes in. |
    | Failure behavior | context.resume references unknown node '<caller node>'; a broken block showed as "not found" in its includer. | A bad session source or a session input used as a value is refused at load, and the error names the caller's with: entry. Starting such a block on its own is refused before it runs. A broken block shows its own error and file. |

    Validation

    On upstream dev at fdc50f6, without the other two changes:

  • CI passes on this branch in a fork, including the Windows suites and the pack tests: https://github.com/Codagent-AI/Archon/actions/runs/46224233286

  • The main test, sessions-composed-inputs.ts, runs a workflow built from blocks next to the same workflow written out by hand: session inputs passed directly, through a block that passes them on, two levels deep and inside nested loop_group bodies. It checks that both make the same provider calls, continue the same sessions and fork the same way, including after an interrupted run is resumed.

  • include-expander.session-inputs.test.ts covers each accepted source, each refusal, the error messages and the unused-input warning. Starting a block on its own (a top-level run, a workflow: child, a chat tool, a trigger binding, a direct engine call, a dry run or a fixture) is refused. Tests cover this from the CLI (workflow-run-inputs, workflow-dry-run, workflow-test-composed), chat tools, trigger bindings and the in-process engine.

  • Real use: the same code, merged in a fork, ran our implementation workflow, then split into 11 blocks, for two live review rounds. The deepest chain was the main workflow → finalize → review cycle, inside the main workflow's review loop. The review-cycle block was included four times, three of them inside a loop. The implementor's session carried through every step that continues it. The fork continues named sessions differently from upstream (#6470), so the comparison test, not the live run, shows upstream's behavior.
  • This doesn't depend on the changes for #6475 or #6476: each of the three applies to dev on its own. Where two add tests or doc lines in the same place, whichever merges second needs a small rebase.

    Closes #6477

    Size

    Counted with cloc --git --diff fdc50f6 b4732a7 (merge base to the PR head). Blank lines left out.

    | Language | Files | Code added | Code modified | Code removed | Comments added | Comments removed |
    | --- | ---: | ---: | ---: | ---: | ---: | ---: |
    | TypeScript | 71 | 1,436 | 94 | 4 | 31 | 1 |
    | Markdown | 2 | 40 | 1 | 0 | 0 | 0 |
    | Total | 73 | 1,476 | 95 | 4 | 31 | 1 |

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Workflows can now pass a caller’s AI session to a statically included workflow, which can resume that session while preserving provider and ancestry checks.
    Bug Fixes
    Workflows requiring a session input now fail early with a clear message if run directly or launched without the required include.
    Invalid included workflows now provide more specific load errors.
    Documentation
    * Added guidance on declaring and forwarding session inputs, compatibility requirements, and usage restrictions.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: coderabbitai[bot] Review duration: 9m
    All Vouch review confidence checks passed
    Residual risk 0.35 = Change Risk (0.52) × (1 − Review Confidence (0.33)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 61% · Reviewer familiarity: 35%
    33%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #6480"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 33.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 33.3% · Lower = rushed or shallow review
    33.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 34.7% · Safe to merge
    34.7%