Skip to content

The platform for continuously improving AI agents.

Use NOT EXISTS in the inference request reconcile query (#346)

Freyam Mehta580f970c3871
diff --git a/.agents/skills/pr-etiquette/SKILL.md b/.agents/skills/pr-etiquette/SKILL.md
index 68b08cf9..a8e005b3 100644
--- a/.agents/skills/pr-etiquette/SKILL.md
+++ b/.agents/skills/pr-etiquette/SKILL.md
@@ -122,4 +122,4 @@ Always re-read the PR afterwards (`gh pr view <n>`) to confirm the edit landed.
- Never push directly to `main`; land work via a PR from a feature branch. A hook blocks a push that names `main` or `master`, and any `git push` while `main` or `master` is checked out.
- Verify the actual current branch with `git status -sb` before pushing — the session-start banner can be stale.
- Commit messages: short subject + at most one body line. No co-author trailers.
-- For fix-sweep PRs, a before/after table in the body is the house style.
+- The body opens with the template's Summary: one line for the whole change, then the What / Before / After / Why table (one row per change, short phrases, measured numbers where they exist). The Decisions and Assumptions sections follow, one bullet each.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index eb166917..de8f5a84 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,10 +1,25 @@
-## What
+## Summary
-<!-- The change, in a sentence or two. -->
+<!-- One line: the whole change and its context. -->
-## Why
+<!-- One row per change. Short phrases, not sentences. Put measured numbers in
+ Before and After when you have them. Link the issue in Why if there is one. -->
-<!-- The problem it solves. Link the issue if there is one. -->
+| What | Before | After | Why |
+| ---- | ------ | ----- | --- |
+| | | | |
+
+## Decisions
+
+<!-- Every choice a reviewer could question. One bullet each. -->
+
+-
+
+## Assumptions
+
+<!-- Every fact the change rests on that you did not verify. One bullet each. -->
+
+-
## Verification
diff --git a/overbae/tasks/inference_requests.py b/overbae/tasks/inference_requests.py
index c15d430c..d4b78b46 100644
--- a/overbae/tasks/inference_requests.py
+++ b/overbae/tasks/inference_requests.py
@@ -1,5 +1,5 @@
from celery import shared_task
-from django.db.models import Q
+from django.db.models import Exists, OuterRef, Q
from django.utils import timezone
from overbae.models import DeployedModel, InferenceCall, InferenceRequest, OperationalRun
@@ -16,7 +16,7 @@ def inspect_inference_request(request_id):
def reconcile_inference_requests():
for request_id in InferenceRequest.objects.filter(
Q(state__in=ACTIVE, next_poll_at__lte=timezone.now())
- | (Q(state__in=FINISHED) & ~Q(pk__in=InferenceCall.objects.values("pk")))
+ | Q(~Exists(InferenceCall.objects.filter(pk=OuterRef("pk"))), state__in=FINISHED)
).values_list("id", flat=True)[:100]:
inspect_inference_request.delay(str(request_id))
for operation_id in OperationalRun.objects.filter(