Repository navigation
fix: reduce backend 504 read amplification - #10440
Merged
Git-on-my-level merged 3 commits intoJul 23, 2026
Merged
Git-on-my-level merged 3 commits into
Git-on-my-level merged 3 commits into
Conversation
Use a one-row lookahead in the existing database invocation so pagination no longer triggers a second full collection scan. Verified: 47 focused backend tests; async blocker scan; backend test preflight. Failure-Class: none
Disable automatic retries for Action Items and Knowledge Graph GETs so one backend failure does not repeat the same expensive request. Verified: call-site loopback tests pass; focused analyzer has no new diagnostics. Failure-Class: none
Member
Author
|
CI triage note: |
Thread one optional read instant through the agent-tools memory list path so hermetic fixtures do not mix a fixed clock with wall time. Verified: 56 focused memory tests; pyright clean; async blocker scan clean. The macOS hermetic runner hit its existing 120-second startup timeout, so Linux CI remains the full harness authority. Failure-Class: none
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Production was still returning 30-second 504s on the expensive Action Items and Knowledge Graph GETs. This PR removes the second Action Items database invocation used only to compute
has_more, and disables all automatic retries for those two mobile GET call sites so one failed read does not immediately repeat the same work.This is a scoped read/retry-amplification mitigation. The remaining Action Items database invocation still streams and sorts the full matching collection, Knowledge Graph still returns the full graph, and the Memories route is unchanged. It does not claim a proven root cause or bounded Firestore reads.
The PR also repairs a date-dependent hermetic memory test exposed by CI. Canonical list reads now accept one optional explicit read instant, threaded through the real agent-tools call path; production callers omit it and retain UTC wall-clock behavior.
Product invariants affected
INV-MEM-1 — the three-tier/default-access behavior is unchanged; the hermetic default-access matrix now evaluates its fixed fixtures against the same fixed instant.
How it was verified
backend/.venv/bin/python -m pytest -q tests/unit/test_action_items_router_pagination.py tests/unit/test_action_items_pagination_order.py tests/unit/test_action_item_canonical_contract.py tests/unit/test_timeout_middleware.py— 47 passed.backend/.venv/bin/python scripts/scan_async_blockers.py --dirs routers utils— 0 selected blocking findings.backend/test-preflight.sh— 17 checks passed, 0 failed, 9 optional environment warnings./Users/dazheng/fvm/versions/3.44.6/bin/flutter test test/unit/http_pool_manager_retry_test.dart— 2 passed against a loopback 504 server through the real API call sites.avoid_printinfo on an untouched line inknowledge_graph_api.dart.backend/.venv/bin/python -m pytest -q tests/unit/test_memory_service_parity.py tests/unit/test_ws_b_short_term_lifecycle.py— 56 passed, including exact-expiry and canonical/legacy clock propagation.pyrighton the three changed production memory modules — 0 errors, 0 warnings.backend/test.shrunner was attempted but did not complete cleanly: three untouched tests exceeded the 0.12-second CPU guard under the broad parallel run, and one untouched memory-runtime adapter test remained stuck for about 11 minutes before the runner was interrupted. The affected-path suites above are green.Tests
backend/tests/unit/test_action_items_router_pagination.pyfails on the old two-call pagination implementation and covers full, exact, and underfilled pages plus trimming before locked-item redaction.app/test/unit/http_pool_manager_retry_test.dartexercisestryGetActionItemsandKnowledgeGraphApi.getKnowledgeGraphthrough a loopback 504 server. It observes one request now; the old call sites would make two and three requests respectively.backend/tests/unit/test_ws_b_short_term_lifecycle.pyproves a short-term item is visible before its supplied expiry and hidden exactly at expiry.backend/tests/unit/test_memory_service_parity.pyproves the selected canonical or legacy backend receives the same explicit read instant.backend/testing/e2e/test_canonical_memory_pipeline.pypasses its fixture clock through the real agent-tools list surface instead of mixing it with wall time.Failure class (fixes)
Failure-Class: none
No existing registered class describes duplicated expensive reads after an application timeout; failure-class lifecycle work belongs in a separate PR.