Skip to content

fix(agent): a running action reports to the stream that delivered it last (closes #483) - #507

Merged
samuelmbabhazi merged 1 commit into
mainfrom
fix/483-reattach-in-flight
Nov 26, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
fix/483-reattach-in-flight

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

In agent/internal/actions, each running action now holds a mutable delivery and its last update, in a new inflight type:

  • The action's own updates go through publish, which keeps the update and sends it to the current delivery.
  • A delivery of the same action id while it runs calls attach. It becomes the action's delivery and gets the last update at once. Every later update goes to it, the final one included. The earlier delivery hears nothing more.
  • After the action ends, a delivery replays the journaled outcome, as before.
  • Cancel is unchanged.

SPEC 3.4 now describes the behavior.

Why

Closes #483. The control plane redelivers unfinished actions on a new stream. A redelivery of an action still running returned without subscribing, and the action kept sending to the stream it started on. When that stream had ended, its updates were dropped, and the outcome reached the control plane only after one more reconnection, or never before the action expired.

How it was tested

  • TestDispatcherReattachesARunningActionToItsLatestDelivery (production dispatcher and SQLite journal). A step blocks, and the action is delivered twice more while it runs.
    • Each new delivery gets RUNNING at once. The last one gets SUCCEEDED with its result, and the replaced one gets nothing after it was replaced.
    • A delivery after the end replays the outcome with its result.
    • The step ran once.
    • Before the fix, the attached delivery received no update.
  • TestRunnerReattachesARunningActionToTheReplacementStream (real gRPC through the test gateway, real Runner, Dispatcher and journal).
    • The gateway delivers the action, the step blocks, then the gateway ends the stream. The runner reconnects, and the gateway delivers the action again.
    • RUNNING arrives on connection 2, then SUCCEEDED with its result, also on connection 2, over exactly two connections. The step ran once.
    • With the previous dispatcher, the test times out waiting for any update on connection 2.
  • go test -race ./agent/... passes, and golangci-lint run ./agent/... reports 0 issues.

Security considerations

No new input or action. An update still goes only to a stream of the same node, through the same runner. Replacing the delivery drops the reference to the ended session's send function, so a long series of reconnections keeps nothing behind.

…last (closes #483)

A redelivery of an action still running returned without attaching, and the action kept sending to the stream it started on. When that stream had ended, the control plane never heard the outcome until another reconnection. Running actions now keep their last update and their current delivery: a new delivery gets the last update at once and every later one, the outcome included.

Signed-off-by: samuel mbabhazi <[email protected]>
@samuelmbabhazi samuelmbabhazi added bug Something isn't working track:agent labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4ef57df and bd694a2.

Files selected for processing: 5

  • agent/internal/actions/dispatcher.go
  • agent/internal/actions/dispatcher_test.go
  • agent/internal/gateway/client_test.go
  • agent/internal/gateway/runner_test.go
  • docs/SPEC.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@samuelmbabhazi
samuelmbabhazi merged commit 83119ef into main Nov 26, 2026
27 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/483-reattach-in-flight branch November 26, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working track:agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reattach in-flight action results to the replacement agent stream

1 participant