Repository navigation
fix: stop semantic ingestion retry loop on context_length_exceeded - #1259
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the semantic ingestion pipeline to avoid infinite retries for messages that exceed an LLM’s context window, by detecting context_length_exceeded (including wrapped exception chains) and marking such messages as ingested so they don’t remain “dirty” forever.
Changes:
- Add
_is_context_length_exceeded_error()helper to detect context-length failures across exception chains. - Treat
context_length_exceededas non-retryable during ingestion: skip the message and mark it ingested. - Add a regression unit test covering wrapped external API errors with an underlying
context_length_exceeded.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/server/src/memmachine_server/semantic_memory/semantic_ingestion.py |
Detects context-length errors and skips/marks messages ingested instead of repeatedly retrying. |
packages/server/server_tests/memmachine_server/semantic_memory/test_semantic_ingestion.py |
Adds a regression test ensuring wrapped context_length_exceeded errors result in the message being marked ingested. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
malatewang
approved these changes
Mar 27, 2026
o-love
force-pushed
the
fix/1252-context-length-ingestion
branch
from
March 27, 2026 17:57
d5a02c0 to
31f042c
Compare
o-love
force-pushed
the
fix/1252-context-length-ingestion
branch
from
March 27, 2026 17:57
31f042c to
c3aa294
Compare
edwinyyyu
reviewed
Mar 27, 2026
| ): | ||
| return True | ||
|
|
||
| current = current.__cause__ or current.__context__ |
Contributor
There was a problem hiding this comment.
Can both of these be truthy simultaneously?
edwinyyyu
approved these changes
Mar 27, 2026
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.
Purpose of the change
Prevent semantic ingestion from retrying indefinitely on messages that can never be processed because they exceed the model context window.
Description
This change treats
context_length_exceededfailures as non-retryable during semantic ingestion. When that error is detected (including wrapped exception chains), the message is skipped and marked ingested so it does not remain in the dirty set forever.It also adds a regression test that reproduces a wrapped external API error with underlying
context_length_exceededand verifies the message is marked ingested.Fixes/Closes
Fixes #1252
Type of change
How Has This Been Tested?
Test Results:
uv run ruff check packages/server/src/memmachine_server/semantic_memory/semantic_ingestion.py packages/server/server_tests/memmachine_server/semantic_memory/test_semantic_ingestion.pyuv run pytest packages/server/server_tests/memmachine_server/semantic_memory/test_semantic_ingestion.py packages/server/server_tests/memmachine_server/semantic_memory/test_semantic_memory_background.py -qChecklist
Screenshots/Gifs
N/A
Further comments
None