Skip to content

fix(memory): defer required-intake SDK import faults without quality retry - #23728

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/memreq2
Oct 26, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/memreq2

Conversation

@Git-on-my-level

Copy link
Copy Markdown
Member

Summary

Luna r4's nonblocking P2 on #23710: the lazy provider-SDK imports in
normalize() sit outside the model setup try, so an ImportError escapes
as a raw exception and the shared processor books it as a quality failure,
spending a retry attempt even though no model call ever ran.

This moves both imports (utils.llm.clients, utils.llm.usage_tracker)
inside the existing setup try, so import faults raise
RequiredProcessingDeferred('required_intake_model_unavailable') — the same
transport/setup classification as every other model-unavailability fault —
and the lease is released with attempt_count unchanged. The supported image
locks these dependencies, so this is defense-in-depth for degraded images.

Per lead ruling 2bf926 this lands as a small follow-up from main after
#23710 (merged 61deb06); the identical patch was validated by the memreq
lane (60 intake tests, 11 clock-ratchet tests, full-tree Pyright) and is
applied here unchanged on top of current main.

Test evidence

  • New parametrized regression test_model_dependency_import_failure_defers_without_quality_retry:
    a synthetic ImportError for either dependency must defer retryable-but-unprocessed,
    keep the capture pending, and leave exactly one retry receipt with
    attempt_count == 0 and no lease owner (transport deferral, not a quality retry).
  • Local backend unit shard via backend/test.sh with
    BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_required_memory_intake.py:
    60 passed (58 existing + 2 new), omi-heavy + nice -n 19.

Product invariants affected

  • INV-MEM-4 — unchanged. Import faults now defer through the existing
    RequiredProcessingDeferred transport path; the item keeps its single
    consolidation route and no promotion/admission authority changes.
  • INV-MEM-1 — unchanged. No tier, collection, or access-surface change;
    the capture stays pending Short-term exactly as before.

Failure-Class: none

…retry

The lazy provider-SDK imports in normalize() sat outside the model setup
try introduced with #23710's cold-import fix, so an ImportError escaped
as a raw exception and the shared processor booked it as a quality
failure, spending a retry attempt. Move both imports inside the setup
try so import faults raise RequiredProcessingDeferred
('required_intake_model_unavailable') and release the lease with
attempt_count unchanged, like every other transport/setup fault.

Regression: synthetic ImportError for either dependency must defer
retryable-but-unprocessed, keep the capture pending, and leave exactly
one zero-attempt retry receipt with no lease owner.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T14:22:22.369674Z e09cae6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e09cae6335

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


@pytest.mark.parametrize('dependency', ['utils.llm.clients', 'utils.llm.usage_tracker'])
def test_model_dependency_import_failure_defers_without_quality_retry(db, monkeypatch, dependency):
import builtins

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the builtins import to module scope

The new test imports builtins inside its function, violating the explicit rule in backend/AGENTS.md: “All imports at module top level — never inside functions.” Move this standard-library import alongside the existing module-level imports; the import-failure simulation can still patch builtins.__import__ within the test.

AGENTS.md reference: backend/AGENTS.md:L168-L168

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit cf029fb into main Oct 26, 2026
59 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/memreq2 branch October 26, 2026 14:32
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.

1 participant