What the agent does
The agent starts from the worker that runs more often than it should. In an Elixir app like thechangelog/changelog.com, Changelog.ObanWorkers.FeedUpdater rebuilds a whole RSS feed: ChangelogWeb.Feeds.refresh/1 generates the XML, uploads it to the bucket named by R2_FEEDS_BUCKET, then queues a ContentPurger job and an OvercastPinger job. It is declared with use Oban.Worker, queue: :feeds and no unique option, and config/prod.exs runs the feeds queue with five at once. The agent greps for FeedUpdater.queue and finds it called from the admin episode, podcast, post and feed controllers, the member feed controller, FeedBouncer, and NewsQueue.publish_item/1, which starts it in a Task for every published news item.
Then it works out how the duplicates happen. FeedUpdater.queue/1 fans out: a podcast with the slug news inserts jobs for news, podcast, master, feed and plusplus, plus one per custom feed that includes the podcast, and every podcast's clause includes master, feed and plusplus. In the admin episode controller, saving a published episode calls handle_feed_updates/1, which calls FeedUpdater.queue(episode) each time, so two quick edits, or edits to episodes of two different podcasts, rebuild the shared feeds twice within seconds; NewsPublisher runs every minute and queues the same feeds again for each item it publishes. With five slots on feeds, two copies can run at once and race to upload. The repository already solves this elsewhere: OvercastPinger has unique: [fields: [:args], period: {5, :minutes}], and MailDeliverer uses a 60 second window. The agent cites both so the change follows the house style.
The fix is a debounce, not a lock. Treating any unfinished job as a duplicate would drop a refresh requested while an earlier one is already running, and the feed would miss the second change. So the agent inserts each FeedUpdater job with a short schedule_in and sets unique with states: :scheduled, the state group Oban's documentation suggests for debouncing, and keys: [:slug, :id] so a news refresh never collapses into a master one. While a job waits to run, a second insert for the same feed returns the existing job with conflict?: true; once it starts, the next change gets a fresh job. The value of schedule_in is written as a module attribute with a comment, and the pull request explains how it was chosen.
To prove it, the agent installs PostgreSQL and the Erlang and Elixir versions from mise.toml, and adds test/changelog/oban_workers/feed_updater_test.exs using Oban.Testing. Because config/test.exs sets testing: :manual, inserts land in the real oban_jobs table without running, so the tests call FeedUpdater.queue/1 twice for the same podcast and assert with all_enqueued(worker: FeedUpdater) that each slug appears once, that two different slugs both stay, and that the second insert returns conflict?: true. It then runs mix test for the whole suite.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Stop duplicate FeedUpdater jobs. Read lib/changelog/oban_workers/feed_updater.ex, lib/changelog_web/feeds.ex, every caller of FeedUpdater.queue, the unique options already used by OvercastPinger and MailDeliverer, and the Oban queues in config/prod.exs and config/test.exs. Explain in the pull request how two jobs for the same feed get inserted. Debounce them with a short schedule_in and Oban unique options that consider only scheduled jobs and key on the slug or feed id, so a refresh requested while one runs is never dropped. Add tests with Oban.Testing that show one job per feed and conflict? on the repeat, run mix test, and open a pull request.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that changes lib/changelog/oban_workers/feed_updater.ex and adds test/changelog/oban_workers/feed_updater_test.exs. The description starts with the paths that insert duplicates, each with its file and line: handle_feed_updates/1 in the admin episode controller on every save of a published episode, NewsQueue.publish_item/1 for each item NewsPublisher releases, and the slug lists in each queue/1 clause that overlap on master, feed and plusplus.
It then shows the new options next to the existing ones in OvercastPinger and MailDeliverer, explains why only scheduled jobs count as duplicates, and includes the mix test output with the new tests passing. The repository's GitHub workflow runs the full suite on the branch.
A reviewer checks the delay against how quickly listeners expect a new episode in their feed, and confirms that other callers, such as the member feed controller, are fine with the same short wait. Nothing about ContentPurger or OvercastPinger changes, so their own uniqueness keeps working as before.
Run it on every Linear issue labelled jobs
In the Project that holds the repository, create an automation with a linear trigger on linear.issue.labeled and jobs in config.labels, and a prompt that says to read the worker named in the issue that follows, trace where it is enqueued, and add uniqueness or debouncing only if duplicates are real. The issue is added after the prompt; the trigger fills in nothing else.
An issue written after someone notices the same feed rebuilt twice in Oban Web becomes one run and one pull request with tests. Changes made by an app integration never fire the trigger, so the agent's own update to the issue does not start another run.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
Duplicate jobs are found by tracing callers across controllers, schemas and other workers, and fixed by choosing which job states count as a duplicate. Both are easy to get subtly wrong. The sandbox has a real Postgres, so the tests insert into the actual oban_jobs table and show the conflict happening, and every command and its output are kept in the run's record.
The pull request carries the trace that justifies the change, which is the part a reviewer would otherwise have to reconstruct. Runs for other workers with the same problem can start at the same time in their own sandboxes, each with its own tests.
Frequently asked questions
Why not treat every unfinished job as a duplicate?
Because a job that is already executing may have read the database before the latest change. If a new insert is ignored while it runs, the feed misses that change until something else triggers a refresh. Considering only scheduled jobs collapses repeats while still allowing one more run after the current one starts.
Does a duplicate insert return an error?
No. Oban.insert/1 returns {:ok, job} with the existing job and sets conflict?: true on it. Callers that ignore the result, as FeedUpdater.queue/1 does, keep working unchanged.
Why key on the slug or feed id instead of the whole args map?
The args are either a slug or an id, and keys makes the comparison explicit, so adding a field to the args later does not quietly turn two copies of the same refresh into two distinct jobs.
Can I see the duplicates before and after in production?
In the production release the router mounts Oban Web at /admin/oban for admins, which lists jobs by worker and state. Filtering by FeedUpdater after editing a published episode shows how many jobs each feed got, which is the check the pull request asks someone with access to run after deploy.
More Oban jobs
More jobs like this: Turn a Linear label into a PR
- Add JSON Output to a Rust CLI (Rust CLI)
- Add JWT Auth to a Hono API from a Linear Issue (Hono)
- Add JWT Authentication to a Vapor App from a Linear Issue (Vapor)
- Add Keyboard Shortcuts to a VS Code Extension (VS Code Extension)