fix: JobHandle resolves the manifest job id from the submission id

db.job(id) gets the submission id the refresh/backfill endpoints return,
but list_jobs / cancel report the agent's manifest id
(<table>-<type>-<first 8 of submission id>). JobHandle now matches that
(exact id or submission prefix) so wait()/progress() truly track, and
cancel() cancels by the resolved canonical id instead of the unusable
submission uuid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wyatt Alt
2026-06-13 10:01:37 -07:00
committed by Jack Ye
parent ad37f87387
commit 396d68e490

View File

@@ -439,9 +439,19 @@ class JobHandle:
self._created = time.monotonic()
self._seen = False
def _matches(self, listed_id: str) -> bool:
# The refresh/backfill endpoints return the submission id (a uuid),
# but the agent names the manifest job "<table>-<type>-<first 8 of
# the submission id>" -- which is what list_jobs and cancel report.
# Match the canonical id directly, or by that submission prefix.
if listed_id == self.id:
return True
prefix = self.id[:8]
return len(prefix) >= 4 and prefix in listed_id
def _job(self):
for j in self.conn.list_jobs():
if j.job_id == self.id:
if self._matches(j.job_id):
return j
return None
@@ -479,4 +489,7 @@ class JobHandle:
raise TimeoutError(f"job {self.id} still {self.status()} after {timeout}s")
def cancel(self) -> None:
self.conn.cancel_job(self.id)
# Cancel by the canonical manifest id (what cancel matches), found
# via the submission prefix; fall back to the raw id.
job = self._job()
self.conn.cancel_job(job.job_id if job is not None else self.id)