Skip to content

fix(agent): retain webhook completion across incremental polls - #20697

Merged
JinHai-CN merged 5 commits into
infiniflow:mainfrom
T1mn:fix/webhook-trace-terminal-state
Oct 16, 2026
Merged

JinHai-CN merged 5 commits into
infiniflow:mainfrom
T1mn:fix/webhook-trace-terminal-state

Conversation

@T1mn

@T1mn T1mn commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Polling a completed webhook run with its returned next_since_ts skips the stored finished event and reports finished: false. It can also return events recorded after that terminal event.

Determine completion from the stored event independently of cursor filtering. Repeated polls remain finished, preserve the cursor, and return no replayed or post-terminal events. Tests cover successful and unsuccessful outcomes, active runs, and the HTTP polling flow.

This follows #20619's handling of expired webhook traces.

Validation

  • Standalone Go polling tests passed with the race detector; the new completion regressions fail against the previous implementation.
  • All seven existing frontend webhook status tests passed.
  • git diff --check passed.
  • Package-scoped bash build.sh --test ./internal/handler/... -run 'TestPollWebhookTrace|TestGetAgentWebhookLogs' -count=1 is blocked by the unsupported macOS native DeepDoc build. The HTTP handler tests remain unverified locally.

Thank you for reviewing.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3d0dcd1c-efcb-497c-a642-9c1dd66f162b
📥 Commits

Reviewing files that changed from the base of the PR and between eeb2960 and 997f17f.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: daccdaf2-d634-492d-8b0b-1b383726bfcc
📥 Commits

Reviewing files that changed from the base of the PR and between 67cbeca and 689b30c.

📒 Files selected for processing (3)
  • internal/handler/agent_webhook_trace.go
  • internal/handler/agent_webhook_trace_poll_test.go
  • internal/handler/agent_webhook_trace_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Walkthrough

Webhook trace polling now marks a run finished when it encounters a finished event, even if that event is at or before the polling cursor. It appends only newer events and advances the cursor only for those events. Tests cover repeated polls after completion and active runs with no new events.

Changes

Webhook trace polling

Layer / File(s) Summary
Cursor filtering and terminal-state polling
internal/handler/agent_webhook_trace.go, internal/handler/agent_webhook_trace_poll_test.go, internal/handler/agent_webhook_trace_test.go
The collector detects finished events independently of the cursor and appends only newer events. Tests check successful and failed terminal outcomes, repeated polls, cursor preservation, and active runs with no new events.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 689b3

No actionable merge-blocking issue is established. The HTTP handler tests remain unverified locally because the package-scoped build was blocked.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving webhook completion across incremental polls.
Description check Passed The description includes the required Summary section, explains the problem and solution, provides relevant test coverage, and records validation results and limitations.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • 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

I’m a rabbit, hopping past the trace,
A finished event keeps its place.
New events follow the cursor’s cue,
Old ones do not replay anew.
Active runs wait for more to show,
Then off through the logs I go.

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN JinHai-CN assigned JinHai-CN and 6ba3i and unassigned JinHai-CN Oct 13, 2026

@6ba3i 6ba3i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@6ba3i 6ba3i added the ci Continue Integration label Oct 13, 2026
@JinHai-CN
JinHai-CN merged commit d6bfce4 into infiniflow:main Oct 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants