Skip to content

fix(agents): keep facets out of root-owned host job sync (#2299) - #2398

Merged
threepointone merged 2 commits into
mainfrom
fix/2299-facet-host-jobs
Sep 28, 2026
Merged

threepointone merged 2 commits into
mainfrom
fix/2299-facet-host-jobs

Conversation

@threepointone

@threepointone threepointone commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2299.

Problem

A facet has no alarm slot, but _syncHostJobs() ran on facets anyway. On every wake it opened a schedule_agent_alarm span for nothing. It also failed outright when a facet's startup fiber recovery left a row behind (for example, a throwing onFiberRecovered). It then pushed a housekeeping job whose setAlarm() threw, which failed the facet's first call after every restart.

Fix

_syncHostJobs() returns early on a facet. The root's facet-run lease already drives the retry that the housekeeping job was trying to schedule.

Edge case: earlier releases could persist a host job (destroy, keep-alive or housekeeping) in a facet's queue before the re-arm threw. The facet path cancels any such job on the next wake, so a job left over from an upgrade cannot re-arm again.

Tests

Two sub-agent tests:

  • Host jobs are left to the root while a sub-agent's fiber recovery is pending.
  • Host jobs that an earlier release left in a sub-agent's queue are dropped.

@changeset-bot

changeset-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59cad8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Patch
@cloudflare/agent-think Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@threepointone
threepointone added this pull request to stack #2407 September 28, 2026 14:47
@agent-think

agent-think Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (14f7c6a4 → 59cad8a5, workflow run)

@threepointone
threepointone marked this pull request as ready for review September 28, 2026 14:49

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2398

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2398

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2398

hono-agents

npm i https://pkg.pr.new/hono-agents@2398

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2398

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2398

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2398

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2398

commit: 59cad8a

@threepointone
threepointone force-pushed the fix/2299-facet-host-jobs branch from ef729c6 to c7f95c1 Compare September 28, 2026 15:46
threepointone and others added 2 commits September 28, 2026 17:50
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@threepointone
threepointone force-pushed the fix/2299-facet-host-jobs branch from c7f95c1 to 59cad8a Compare September 28, 2026 16:54
@threepointone
threepointone merged commit d44b67d into main Sep 28, 2026
16 checks passed
@threepointone
threepointone deleted the fix/2299-facet-host-jobs branch September 28, 2026 18:04
@github-actions github-actions Bot mentioned this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_syncHostJobs runs on facet instances even though the root owns the alarm

1 participant