Skip to content

fix(jobs): block create only on live duplicate id (#11)#24

Merged
mattmezza merged 2 commits into
mainfrom
fix/issue-11-job-guard
Jun 25, 2026
Merged

fix(jobs): block create only on live duplicate id (#11)#24
mattmezza merged 2 commits into
mainfrom
fix/issue-11-job-guard

Conversation

@mattmezza

Copy link
Copy Markdown
Owner

Problem

Agent job creation was sometimes refused with "Request already fulfilled; not repeating write actions" — even for a brand-new job id (e.g. flight-monitor-lx1272). The job was never created, so recurring/one-shot monitors could not be scheduled reliably.

Root cause

Two issues, both off the job id:

  1. core/agent._execute_tool ran every write through a per-turn dedup guard keyed on tool + params. A manage_jobs create that ran earlier in the same turn blocked any later create, regardless of id.
  2. _tool_manage_jobs create never checked id existence at all — it silently upserted over a live job; there was no correct id-based guard to take the generic one's place.
  3. tools/jobs.py CLI blocked recreation of any existing id, including done/cancelled ones.

Fix

Match the issue's expected behavior exactly — block a create only when a job with the same id already exists and is active/paused:

  • Exempt manage_jobs from the generic per-turn write-dedup guard.
  • Guard _tool_manage_jobs create on job_id + status: explicit live id → blocked with an id-based message; done/cancelled ids and auto-generated ids are free to (re)create.
  • Same active/paused-only rule in the jobs.py CLI.

Tests

tests/test_tools.py:

  • brand-new id creates even after another job was made the same turn (the repro);
  • recreating a live id is blocked with an id-based message, not the generic guard;
  • a cancelled id can be recreated;
  • the generic dedup guard still suppresses an identical repeated send_email.

Full suite: 326 passed.

Closes #11

Job creation was gated by the generic per-turn write-dedup guard, which
refused brand-new job ids with 'already fulfilled'. Exempt manage_jobs
from that guard and instead block a create only when the same job id is
already active/paused, both in the agent tool and the jobs.py CLI.
Done/cancelled ids and auto-generated ids are free to (re)create.

Fixes #11
Repoint the generic write-dedup test to send_email (manage_jobs is now
exempt) and add cases: brand-new id never blocked after a prior create,
recreating a live id is blocked with an id-based message (not the generic
guard), and a cancelled id can be recreated.
@mattmezza mattmezza merged commit 5269820 into main Jun 25, 2026
1 check passed
@mattmezza mattmezza deleted the fix/issue-11-job-guard branch June 25, 2026 12:29
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.

Agent job creation incorrectly blocked by Request already fulfilled guard

1 participant