Skip to content

[Bug]: KeyError in SqlAlchemyEpisodeStore when retrieving persisted episode IDs #943

@sscargal

Description

@sscargal

Describe the bug

Unit Tests are failing with a KeyError in the SqlAlchemyEpisodeStore.add_episodes method when attempting to return episodes by their IDs after insertion.

Here are the complete GitHub Action Logs of the failing Unit test from Python 3.12 on Mac OS X:

logs_53787664679.zip

Raw logs:

2026-01-07T20:50:02.7608790Z Current runner version: '2.330.0'
2026-01-07T20:50:02.7655130Z ##[group]Runner Image Provisioner
2026-01-07T20:50:02.7655950Z Hosted Compute Agent
2026-01-07T20:50:02.7656340Z Version: 20251211.462
2026-01-07T20:50:02.7656770Z Commit: 6cbad8c2bb55d58165063d031ccabf57e2d2db61
2026-01-07T20:50:02.7657350Z Build Date: 2025-12-11T16:28:49Z
2026-01-07T20:50:02.7657870Z Worker ID: {b0b27e5c-abec-4e77-b93e-a05d7867d169}
2026-01-07T20:50:02.7658350Z ##[endgroup]
2026-01-07T20:50:02.7659370Z ##[group]Operating System
2026-01-07T20:50:02.7661100Z macOS
2026-01-07T20:50:02.7661870Z 15.7.3
2026-01-07T20:50:02.7662620Z 24G419
2026-01-07T20:50:02.7663640Z ##[endgroup]
2026-01-07T20:50:02.7664510Z ##[group]Runner Image
2026-01-07T20:50:02.7665590Z Image: macos-15-arm64
2026-01-07T20:50:02.7666700Z Version: 20260105.0094.1
2026-01-07T20:50:02.7668880Z Included Software: https://github.com/actions/runner-images/blob/macos-15-arm64/20260105.0094/images/macos/macos-15-arm64-Readme.md
2026-01-07T20:50:02.7672200Z Image Release: https://github.com/actions/runner-images/releases/tag/macos-15-arm64%2F20260105.0094
2026-01-07T20:50:02.7674110Z ##[endgroup]
2026-01-07T20:50:02.7676290Z ##[group]GITHUB_TOKEN Permissions
2026-01-07T20:50:02.7681000Z Contents: read
2026-01-07T20:50:02.7682050Z Metadata: read
2026-01-07T20:50:02.7683210Z ##[endgroup]
2026-01-07T20:50:02.7688100Z Secret source: None
2026-01-07T20:50:02.7688690Z Prepare workflow directory
2026-01-07T20:50:02.7956260Z Prepare all required actions
2026-01-07T20:50:02.7984340Z Getting action download info
2026-01-07T20:50:03.2834420Z Download action repository 'actions/checkout@v5' (SHA:93cb6efe18208431cddfb8368fd83d5badbf9bfd)
2026-01-07T20:50:03.4828510Z Download action repository 'astral-sh/setup-uv@v6' (SHA:d0cc045d04ccac9d8b7881df0226f9e82c39688e)
2026-01-07T20:50:04.2776350Z Complete job name: Run Python unit tests (3.12, macos-latest)
2026-01-07T20:50:04.3159300Z ##[group]Run actions/checkout@v5
2026-01-07T20:50:04.3159790Z with:
2026-01-07T20:50:04.3160060Z   repository: MemMachine/MemMachine
2026-01-07T20:50:04.3160530Z   token: ***
2026-01-07T20:50:04.3160780Z   ssh-strict: true
2026-01-07T20:50:04.3161040Z   ssh-user: git
2026-01-07T20:50:04.3161320Z   persist-credentials: true
2026-01-07T20:50:04.3161610Z   clean: true
2026-01-07T20:50:04.3161890Z   sparse-checkout-cone-mode: true
2026-01-07T20:50:04.3162220Z   fetch-depth: 1
2026-01-07T20:50:04.3162480Z   fetch-tags: false
2026-01-07T20:50:04.3162750Z   show-progress: true
2026-01-07T20:50:04.3163030Z   lfs: false
2026-01-07T20:50:04.3163270Z   submodules: false
2026-01-07T20:50:04.3163540Z   set-safe-directory: true
2026-01-07T20:50:04.3163950Z ##[endgroup]
2026-01-07T20:50:04.6554170Z Syncing repository: MemMachine/MemMachine
2026-01-07T20:50:04.6558790Z ##[group]Getting Git version info
2026-01-07T20:50:04.6560980Z Working directory is '/Users/runner/work/MemMachine/MemMachine'
2026-01-07T20:50:04.6563060Z [command]/opt/homebrew/bin/git version
2026-01-07T20:50:04.6852640Z git version 2.52.0
2026-01-07T20:50:04.6869820Z ##[endgroup]
2026-01-07T20:50:04.6876520Z Copying '/Users/runner/.gitconfig' to '/Users/runner/work/_temp/1190c351-98f7-4c7c-945e-fc9358ebc86c/.gitconfig'
2026-01-07T20:50:04.6883010Z Temporarily overriding HOME='/Users/runner/work/_temp/1190c351-98f7-4c7c-945e-fc9358ebc86c' before making global git config changes
2026-01-07T20:50:04.6884270Z Adding repository directory to the temporary git global config as a safe directory
2026-01-07T20:50:04.6886470Z [command]/opt/homebrew/bin/git config --global --add safe.directory /Users/runner/work/MemMachine/MemMachine
2026-01-07T20:50:04.6981670Z Deleting the contents of '/Users/runner/work/MemMachine/MemMachine'
2026-01-07T20:50:04.6984730Z ##[group]Initializing the repository
2026-01-07T20:50:04.6988350Z [command]/opt/homebrew/bin/git init /Users/runner/work/MemMachine/MemMachine
2026-01-07T20:50:04.7138250Z hint: Using 'master' as the name for the initial branch. This default branch name
2026-01-07T20:50:04.7139350Z hint: will change to "main" in Git 3.0. To configure the initial branch name
2026-01-07T20:50:04.7142130Z hint: to use in all of your new repositories, which will suppress this warning,
2026-01-07T20:50:04.7142800Z hint: call:
2026-01-07T20:50:04.7143140Z hint:
2026-01-07T20:50:04.7143570Z hint: 	git config --global init.defaultBranch <name>
2026-01-07T20:50:04.7144100Z hint:
2026-01-07T20:50:04.7144590Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2026-01-07T20:50:04.7146200Z hint: 'development'. The just-created branch can be renamed via this command:
2026-01-07T20:50:04.7146930Z hint:
2026-01-07T20:50:04.7147520Z hint: 	git branch -m <name>
2026-01-07T20:50:04.7148030Z hint:
2026-01-07T20:50:04.7148620Z hint: Disable this message with "git config set advice.defaultBranchName false"
2026-01-07T20:50:04.7150830Z Initialized empty Git repository in /Users/runner/work/MemMachine/MemMachine/.git/
2026-01-07T20:50:04.7152860Z [command]/opt/homebrew/bin/git remote add origin https://github.com/MemMachine/MemMachine
2026-01-07T20:50:04.7215320Z ##[endgroup]
2026-01-07T20:50:04.7216190Z ##[group]Disabling automatic garbage collection
2026-01-07T20:50:04.7217740Z [command]/opt/homebrew/bin/git config --local gc.auto 0
2026-01-07T20:50:04.7277900Z ##[endgroup]
2026-01-07T20:50:04.7278410Z ##[group]Setting up auth
2026-01-07T20:50:04.7282050Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp core\.sshCommand
2026-01-07T20:50:04.7343260Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2026-01-07T20:50:04.8225140Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2026-01-07T20:50:04.8284430Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2026-01-07T20:50:04.9124390Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp ^includeIf\.gitdir:
2026-01-07T20:50:04.9219670Z [command]/opt/homebrew/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
2026-01-07T20:50:05.0420740Z [command]/opt/homebrew/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2026-01-07T20:50:05.0496610Z ##[endgroup]
2026-01-07T20:50:05.0497760Z ##[group]Fetching the repository
2026-01-07T20:50:05.0500670Z [command]/opt/homebrew/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +3ff70cc6eac16e7124864e49d97a1b11580d99a1:refs/remotes/pull/917/merge
2026-01-07T20:50:05.7349000Z From https://github.com/MemMachine/MemMachine
2026-01-07T20:50:05.7370960Z  * [new ref]         3ff70cc6eac16e7124864e49d97a1b11580d99a1 -> pull/917/merge
2026-01-07T20:50:05.7549650Z ##[endgroup]
2026-01-07T20:50:05.7563220Z ##[group]Determining the checkout info
2026-01-07T20:50:05.7582490Z ##[endgroup]
2026-01-07T20:50:05.7600750Z [command]/opt/homebrew/bin/git sparse-checkout disable
2026-01-07T20:50:05.7617380Z [command]/opt/homebrew/bin/git config --local --unset-all extensions.worktreeConfig
2026-01-07T20:50:05.7764960Z ##[group]Checking out the ref
2026-01-07T20:50:05.7874620Z [command]/opt/homebrew/bin/git checkout --progress --force refs/remotes/pull/917/merge
2026-01-07T20:50:05.9055690Z HEAD is now at 3ff70cc Merge cda6b58e607f2027187c8a73c739b592e6478aa9 into c5c5c5950270e9583e74dfb787f25029d5964d7d
2026-01-07T20:50:05.9072200Z ##[endgroup]
2026-01-07T20:50:05.9193480Z [command]/opt/homebrew/bin/git log -1 --format=%H
2026-01-07T20:50:05.9292180Z 3ff70cc6eac16e7124864e49d97a1b11580d99a1
2026-01-07T20:50:05.9618010Z ##[group]Run astral-sh/setup-uv@v6
2026-01-07T20:50:05.9618780Z with:
2026-01-07T20:50:05.9619360Z   python-version: 3.12
2026-01-07T20:50:05.9619990Z   activate-environment: false
2026-01-07T20:50:05.9620860Z   working-directory: /Users/runner/work/MemMachine/MemMachine
2026-01-07T20:50:05.9622180Z   server-url: https://github.com
2026-01-07T20:50:05.9623110Z   github-token: ***
2026-01-07T20:50:05.9623670Z   enable-cache: auto
2026-01-07T20:50:05.9625150Z   cache-dependency-glob: **/*requirements*.txt
**/*requirements*.in
**/*constraints*.txt
**/*constraints*.in
**/pyproject.toml
**/uv.lock
**/*.py.lock

2026-01-07T20:50:05.9626780Z   restore-cache: true
2026-01-07T20:50:05.9627340Z   save-cache: true
2026-01-07T20:50:05.9627910Z   prune-cache: true
2026-01-07T20:50:05.9628490Z   ignore-nothing-to-cache: false
2026-01-07T20:50:05.9629170Z   ignore-empty-workdir: false
2026-01-07T20:50:05.9629870Z   add-problem-matchers: true
2026-01-07T20:50:05.9630490Z ##[endgroup]
2026-01-07T20:50:06.4086460Z Trying to find version for uv in: /Users/runner/work/MemMachine/MemMachine/uv.toml
2026-01-07T20:50:06.4089240Z Could not find file: /Users/runner/work/MemMachine/MemMachine/uv.toml
2026-01-07T20:50:06.4093300Z Trying to find version for uv in: /Users/runner/work/MemMachine/MemMachine/pyproject.toml
2026-01-07T20:50:06.4110830Z Could not determine uv version from uv.toml or pyproject.toml. Falling back to latest.
2026-01-07T20:50:06.4120670Z Getting latest version from GitHub API...
2026-01-07T20:50:06.7544050Z manifest-file not provided, reading from local file.
2026-01-07T20:50:06.7583480Z manifest-file does not contain version 0.9.22, arch aarch64, platform apple-darwin. Falling back to GitHub releases.
2026-01-07T20:50:06.7585980Z Downloading uv from "https://github.com/astral-sh/uv/releases/download/0.9.22/uv-aarch64-apple-darwin.tar.gz" ...
2026-01-07T20:50:08.6291580Z [command]/usr/bin/tar xz -C /Users/runner/work/_temp/383fcd7a-80e1-4934-a085-a41c608b99f1 -f /Users/runner/work/_temp/d317a73f-714e-45b9-9686-960c744cd19b
2026-01-07T20:50:08.8323310Z Added /Users/runner/.local/bin to the path
2026-01-07T20:50:08.8329120Z Added /Users/runner/hostedtoolcache/uv/0.9.22/aarch64 to the path
2026-01-07T20:50:08.8331770Z Set UV_PYTHON to 3.12
2026-01-07T20:50:08.8348990Z Set UV_CACHE_DIR to /Users/runner/work/_temp/setup-uv-cache
2026-01-07T20:50:08.8349310Z Successfully installed uv version 0.9.22
2026-01-07T20:50:08.8364970Z Searching files using cache dependency glob: /Users/runner/work/MemMachine/MemMachine/**/*requirements*.txt,/Users/runner/work/MemMachine/MemMachine/**/*requirements*.in,/Users/runner/work/MemMachine/MemMachine/**/*constraints*.txt,/Users/runner/work/MemMachine/MemMachine/**/*constraints*.in,/Users/runner/work/MemMachine/MemMachine/**/pyproject.toml,/Users/runner/work/MemMachine/MemMachine/**/uv.lock,/Users/runner/work/MemMachine/MemMachine/**/*.py.lock
2026-01-07T20:50:08.8600440Z /Users/runner/work/MemMachine/MemMachine/examples/simple_chatbot/requirements.txt
2026-01-07T20:50:08.8664170Z /Users/runner/work/MemMachine/MemMachine/integrations/dify/plugin/requirements.txt
2026-01-07T20:50:08.8692990Z /Users/runner/work/MemMachine/MemMachine/packages/client/pyproject.toml
2026-01-07T20:50:08.8847720Z /Users/runner/work/MemMachine/MemMachine/packages/meta/pyproject.toml
2026-01-07T20:50:08.8863010Z /Users/runner/work/MemMachine/MemMachine/packages/server/pyproject.toml
2026-01-07T20:50:08.8965860Z /Users/runner/work/MemMachine/MemMachine/pyproject.toml
2026-01-07T20:50:08.9157500Z /Users/runner/work/MemMachine/MemMachine/tools/chatgpt2memmachine/requirements.txt
2026-01-07T20:50:08.9190610Z /Users/runner/work/MemMachine/MemMachine/uv.lock
2026-01-07T20:50:08.9199120Z Found 8 files to hash.
2026-01-07T20:50:08.9227980Z Trying to restore uv cache from GitHub Actions cache with key: setup-uv-1-aarch64-apple-darwin-3.12-pruned-8d16b87007209ca36741df23f67a9afb9c087645ef4f654ef7684455c5eb9199
2026-01-07T20:50:09.1549020Z Cache hit for: setup-uv-1-aarch64-apple-darwin-3.12-pruned-8d16b87007209ca36741df23f67a9afb9c087645ef4f654ef7684455c5eb9199
2026-01-07T20:50:09.9407280Z Received 365941 of 365941 (100.0%), 0.8 MBs/sec
2026-01-07T20:50:09.9411080Z Cache Size: ~0 MB (365941 B)
2026-01-07T20:50:09.9481760Z [command]/opt/homebrew/bin/gtar -xf /Users/runner/work/_temp/f96f27ed-0db5-4911-8f65-819c88fa880a/cache.tzst -P -C /Users/runner/work/MemMachine/MemMachine --delay-directory-restore --use-compress-program unzstd
2026-01-07T20:50:09.9812430Z Cache restored successfully
2026-01-07T20:50:09.9816510Z uv cache restored from GitHub Actions cache with key: setup-uv-1-aarch64-apple-darwin-3.12-pruned-8d16b87007209ca36741df23f67a9afb9c087645ef4f654ef7684455c5eb9199
2026-01-07T20:50:09.9905100Z ##[group]Run uv run --frozen --all-extras pytest -n auto --cov=memmachine
2026-01-07T20:50:09.9905560Z �[36;1muv run --frozen --all-extras pytest -n auto --cov=memmachine�[0m
2026-01-07T20:50:09.9943830Z shell: /bin/bash -e {0}
2026-01-07T20:50:09.9944030Z env:
2026-01-07T20:50:09.9944170Z   UV_PYTHON: 3.12
2026-01-07T20:50:09.9944380Z   UV_CACHE_DIR: /Users/runner/work/_temp/setup-uv-cache
2026-01-07T20:50:09.9944680Z ##[endgroup]
2026-01-07T20:50:10.4475140Z Using CPython 3.12.10 interpreter at: /usr/local/bin/python3.12
2026-01-07T20:50:10.4495700Z Creating virtual environment at: .venv
2026-01-07T20:50:10.4609080Z    Building memmachine @ file:///Users/runner/work/MemMachine/MemMachine
2026-01-07T20:50:10.4710640Z    Building memmachine-client @ file:///Users/runner/work/MemMachine/MemMachine/packages/client
2026-01-07T20:50:10.4817550Z    Building memmachine-server @ file:///Users/runner/work/MemMachine/MemMachine/packages/server
2026-01-07T20:50:10.5009540Z Downloading virtualenv (5.7MiB)
2026-01-07T20:50:10.5041290Z Downloading pygments (1.2MiB)
2026-01-07T20:50:10.5142190Z Downloading setuptools (1.1MiB)
2026-01-07T20:50:10.5216510Z Downloading openai (1.0MiB)
2026-01-07T20:50:10.5224760Z Downloading transformers (11.4MiB)
2026-01-07T20:50:10.5241740Z Downloading pydantic-core (1.8MiB)
2026-01-07T20:50:10.5246840Z Downloading nltk (1.4MiB)
2026-01-07T20:50:10.5247340Z Downloading sympy (6.0MiB)
2026-01-07T20:50:10.5248020Z Downloading ruff (12.2MiB)
2026-01-07T20:50:10.5248330Z Downloading complexipy (1.9MiB)
2026-01-07T20:50:10.5250280Z Downloading scipy (19.9MiB)
2026-01-07T20:50:10.5255160Z Downloading torch (71.0MiB)
2026-01-07T20:50:10.5256600Z Downloading sqlalchemy (2.0MiB)
2026-01-07T20:50:10.5256890Z Downloading numpy (4.9MiB)
2026-01-07T20:50:10.5257540Z Downloading hf-xet (2.6MiB)
2026-01-07T20:50:10.5258210Z Downloading networkx (2.0MiB)
2026-01-07T20:50:10.5286990Z Downloading tokenizers (2.8MiB)
2026-01-07T20:50:10.5287670Z Downloading ty (8.1MiB)
2026-01-07T20:50:10.5289060Z Downloading cryptography (6.9MiB)
2026-01-07T20:50:10.5332090Z Downloading mypy (11.6MiB)
2026-01-07T20:50:10.5360460Z Downloading scikit-learn (8.2MiB)
2026-01-07T20:50:10.5367370Z Downloading botocore (13.8MiB)
2026-01-07T20:50:10.5395810Z Downloading beartype (1.3MiB)
2026-01-07T20:50:12.7963670Z       Built memmachine @ file:///Users/runner/work/MemMachine/MemMachine
2026-01-07T20:50:12.9226300Z  Downloaded pydantic-core
2026-01-07T20:50:13.0051120Z  Downloaded complexipy
2026-01-07T20:50:13.0178670Z  Downloaded pygments
2026-01-07T20:50:13.0374340Z  Downloaded sqlalchemy
2026-01-07T20:50:13.2191050Z  Downloaded hf-xet
2026-01-07T20:50:13.3281470Z  Downloaded tokenizers
2026-01-07T20:50:13.3399800Z  Downloaded nltk
2026-01-07T20:50:13.3546220Z  Downloaded beartype
2026-01-07T20:50:13.5056780Z  Downloaded setuptools
2026-01-07T20:50:14.5119330Z       Built memmachine-client @ file:///Users/runner/work/MemMachine/MemMachine/packages/client
2026-01-07T20:50:14.5817460Z  Downloaded networkx
2026-01-07T20:50:14.6985440Z       Built memmachine-server @ file:///Users/runner/work/MemMachine/MemMachine/packages/server
2026-01-07T20:50:15.0821770Z  Downloaded numpy
2026-01-07T20:50:15.1673200Z  Downloaded virtualenv
2026-01-07T20:50:15.2132870Z  Downloaded openai
2026-01-07T20:50:15.3282420Z  Downloaded cryptography
2026-01-07T20:50:15.6479700Z  Downloaded ty
2026-01-07T20:50:15.8340350Z  Downloaded scikit-learn
2026-01-07T20:50:15.8601110Z  Downloaded sympy
2026-01-07T20:50:16.4481440Z  Downloaded ruff
2026-01-07T20:50:16.8264380Z  Downloaded botocore
2026-01-07T20:50:16.9310310Z  Downloaded transformers
2026-01-07T20:50:17.0028960Z  Downloaded scipy
2026-01-07T20:50:17.0494680Z  Downloaded mypy
2026-01-07T20:50:19.2104100Z  Downloaded torch
2026-01-07T20:50:19.9587090Z Installed 162 packages in 747ms
2026-01-07T20:50:52.6023900Z ============================= test session starts ==============================
2026-01-07T20:50:52.6122820Z platform darwin -- Python 3.12.10, pytest-9.0.1, pluggy-1.6.0
2026-01-07T20:50:52.6226880Z rootdir: /Users/runner/work/MemMachine/MemMachine
2026-01-07T20:50:52.6324710Z configfile: pyproject.toml
2026-01-07T20:50:52.6426090Z plugins: langsmith-0.4.53, anyio-4.12.0, xdist-3.8.0, asyncio-1.3.0, cov-7.0.0
2026-01-07T20:50:52.6527080Z asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=session, asyncio_default_test_loop_scope=session
2026-01-07T20:50:52.6630240Z created: 3/3 workers
2026-01-07T20:50:52.6731190Z 3 workers [1500 items]
2026-01-07T20:50:52.6866120Z 
2026-01-07T20:50:52.9148220Z ssss.s.s.s...............................................s...s....s..... [  4%]
2026-01-07T20:50:53.0565730Z ...........s....................................s.....ss..s.ss...ssss.s. [  9%]
2026-01-07T20:50:53.1731200Z sssssss.s.s..s.ss.ss.ss.s..ssssssssssssss.ssssssssssssssssssssssssssssss [ 14%]
2026-01-07T20:50:53.3654230Z .ss.s.......................s........................................... [ 19%]
2026-01-07T20:50:53.8710570Z .........................ssssssss..s..s..s...........s.........s.....s.. [ 24%]
2026-01-07T20:50:54.1023900Z ....sssssssssssssss.s.sssssssss.ssssssssss.ss.ssssssss.................. [ 28%]
2026-01-07T20:50:54.2328910Z ssss.sssss.....s.........s....s...............s..s..........s.ss.s.sss.s [ 33%]
2026-01-07T20:50:54.7000460Z .ss.s.sss.ss.sss.sss.ss..ssss.........s.s.s......s...s..s..s..s..s...... [ 38%]
2026-01-07T20:50:56.9562980Z ..............s.s.s.s.s.s..............................sssssssssssssssss [ 43%]
2026-01-07T20:50:57.0852910Z sssssssssssssssssssss.............................................ssss.s [ 48%]
2026-01-07T20:50:57.3164310Z s.ss.ss.ss.ss.ss.ss.ss.ssssssssssssss..s.sssssssss.s.sssssssss.s.sssssss [ 52%]
2026-01-07T20:50:57.7163320Z ss.s.sssssssss.s.sssssssss.s.sssssssss.s.sss.ss.ss.ss.ssssssss.s.sssssss [ 57%]
2026-01-07T20:50:58.5543850Z ss.s.sss.ss.ssssssss.s.sssssssss.s.sssssssss.s.sssssssss.s.sssssssss.s.s [ 62%]
2026-01-07T20:50:58.9659440Z ssssssss.s.s........ssssssssssssss.s.sssssssss.s.sssssssss.s.sssssssss.s [ 67%]
2026-01-07T20:50:59.2628540Z .sssssssss.s.sssssssss.s.sssssssss.s..ssss..sssss..........s....ssssssss [ 72%]
2026-01-07T20:51:01.4354360Z s.s.sssssssss.s.sssssssss.s.sssssssss.s.sssss.sssss..................... [ 76%]
2026-01-07T20:51:01.7315490Z ........ssssssssssssssss.ssssssssssssss...ssssss.s.ss........ssssssss..s [ 81%]
2026-01-07T20:51:02.1037870Z .sssssssss.s..ssssssssss.s.sssssssss.s.sss.ss.ss.ss.ss.ss.ss.ss..sssssss [ 86%]
2026-01-07T20:51:03.0227380Z ss..............................Fs...................................... [ 91%]
2026-01-07T20:51:43.2031630Z ....................................ssssssssss...................sssssss [ 96%]
2026-01-07T20:51:48.5913030Z ssssssssssssssssssss.......................................s             [100%]
2026-01-07T20:51:48.6014430Z =================================== FAILURES ===================================
2026-01-07T20:51:48.6119920Z _ test_multiple_sets_processed_independently[in_memory_semantic_storage-sql_db_episode_storage-sqlalchemy_sqlite_engine] _
2026-01-07T20:51:48.6227130Z [gw1] darwin -- Python 3.12.10 /Users/runner/work/MemMachine/MemMachine/.venv/bin/python
2026-01-07T20:51:48.6329160Z 
2026-01-07T20:51:48.6431920Z semantic_storage = <tests.memmachine.semantic_memory.storage.in_memory_semantic_storage.InMemorySemanticStorage object at 0x11ab7f8f0>
2026-01-07T20:51:48.6534840Z resource_retriever = <tests.memmachine.semantic_memory.mock_semantic_memory_objects.MockResourceRetriever object at 0x11ab7e090>
2026-01-07T20:51:48.6637100Z episode_storage = <memmachine.common.episode_store.episode_sqlalchemy_store.SqlAlchemyEpisodeStore object at 0x118e3d130>
2026-01-07T20:51:48.6741430Z semantic_type = SemanticCategory(id=None, name='Profile', prompt=RawSemanticPrompt(update_prompt='update-prompt', consolidation_prompt='consolidation-prompt'))
2026-01-07T20:51:48.6843510Z monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x118e3f530>
2026-01-07T20:51:48.6944680Z 
2026-01-07T20:51:48.7054150Z     async def test_multiple_sets_processed_independently(
2026-01-07T20:51:48.7148990Z         semantic_storage: SemanticStorage,
2026-01-07T20:51:48.7250550Z         resource_retriever: MockResourceRetriever,
2026-01-07T20:51:48.7351910Z         episode_storage: EpisodeStorage,
2026-01-07T20:51:48.7453510Z         semantic_type: SemanticCategory,
2026-01-07T20:51:48.7557470Z         monkeypatch,
2026-01-07T20:51:48.7927560Z     ):
2026-01-07T20:51:48.8029870Z         from memmachine.semantic_memory.semantic_model import SemanticCommand
2026-01-07T20:51:48.8133430Z     
2026-01-07T20:51:48.8237490Z         # Create service with message_limit=2
2026-01-07T20:51:48.8338820Z         params = SemanticService.Params(
2026-01-07T20:51:48.8441020Z             semantic_storage=semantic_storage,
2026-01-07T20:51:48.8543140Z             episode_storage=episode_storage,
2026-01-07T20:51:48.8646750Z             resource_retriever=resource_retriever,
2026-01-07T20:51:48.8748890Z             feature_update_interval_sec=0.05,
2026-01-07T20:51:48.8850700Z             uningested_message_limit=0,
2026-01-07T20:51:48.8952750Z         )
2026-01-07T20:51:48.9054610Z         service = SemanticService(params)
2026-01-07T20:51:48.9155590Z         await service.start()
2026-01-07T20:51:48.9256850Z     
2026-01-07T20:51:48.9365880Z         async def mock_llm_update(*args, **kwargs):
2026-01-07T20:51:48.9466790Z             # Return different commands based on message content
2026-01-07T20:51:48.9566930Z             message = kwargs.get("message_content", "")
2026-01-07T20:51:48.9667960Z             if "user-a" in str(message):
2026-01-07T20:51:48.9770780Z                 return [
2026-01-07T20:51:48.9871190Z                     SemanticCommand(
2026-01-07T20:51:48.9973150Z                         command=SemanticCommandType.ADD,
2026-01-07T20:51:49.0074630Z                         feature="trait_a",
2026-01-07T20:51:49.0177280Z                         tag="traits",
2026-01-07T20:51:49.0278850Z                         value="value_a",
2026-01-07T20:51:49.0381800Z                     ),
2026-01-07T20:51:49.0494440Z                 ]
2026-01-07T20:51:49.0608790Z             return [
2026-01-07T20:51:49.0709300Z                 SemanticCommand(
2026-01-07T20:51:49.0810820Z                     command=SemanticCommandType.ADD,
2026-01-07T20:51:49.0912250Z                     feature="trait_b",
2026-01-07T20:51:49.1013850Z                     tag="traits",
2026-01-07T20:51:49.1115730Z                     value="value_b",
2026-01-07T20:51:49.1218210Z                 ),
2026-01-07T20:51:49.1320210Z             ]
2026-01-07T20:51:49.1421510Z     
2026-01-07T20:51:49.1479530Z         monkeypatch.setattr(
2026-01-07T20:51:49.1480390Z             "memmachine.semantic_memory.semantic_ingestion.llm_feature_update",
2026-01-07T20:51:49.1481940Z             mock_llm_update,
2026-01-07T20:51:49.1482410Z         )
2026-01-07T20:51:49.1482650Z     
2026-01-07T20:51:49.1483140Z         # Add messages for two different sets
2026-01-07T20:51:49.1484000Z         # Need to add them separately so tracker counts each one
2026-01-07T20:51:49.1484970Z         msg_a1 = await add_history(
2026-01-07T20:51:49.1486050Z             history_storage=episode_storage,
2026-01-07T20:51:49.1525300Z             content="user-a message 1",
2026-01-07T20:51:49.1554380Z         )
2026-01-07T20:51:49.1555110Z         await service.add_messages(set_id="user-a", history_ids=[msg_a1])
2026-01-07T20:51:49.1555610Z         msg_a2 = await add_history(
2026-01-07T20:51:49.1556570Z             history_storage=episode_storage,
2026-01-07T20:51:49.1557030Z             content="user-a message 2",
2026-01-07T20:51:49.1558110Z         )
2026-01-07T20:51:49.1559160Z         await service.add_messages(set_id="user-a", history_ids=[msg_a2])
2026-01-07T20:51:49.1559580Z     
2026-01-07T20:51:49.1559850Z         msg_b1 = await add_history(
2026-01-07T20:51:49.1560240Z             history_storage=episode_storage,
2026-01-07T20:51:49.1560950Z             content="user-b message 1",
2026-01-07T20:51:49.1561530Z         )
2026-01-07T20:51:49.1562580Z         await service.add_messages(set_id="user-b", history_ids=[msg_b1])
2026-01-07T20:51:49.1563050Z >       msg_b2 = await add_history(
2026-01-07T20:51:49.1563410Z             history_storage=episode_storage,
2026-01-07T20:51:49.1563820Z             content="user-b message 2",
2026-01-07T20:51:49.1564150Z         )
2026-01-07T20:51:49.1565370Z 
2026-01-07T20:51:49.1566490Z tests/memmachine/semantic_memory/test_semantic_memory_background.py:363: 
2026-01-07T20:51:49.1567830Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2026-01-07T20:51:49.1568470Z tests/memmachine/semantic_memory/test_semantic_memory_background.py:61: in add_history
2026-01-07T20:51:49.1569140Z     episodes = await history_storage.add_episodes(
2026-01-07T20:51:49.1569680Z .venv/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py:34: in wrapper_function
2026-01-07T20:51:49.1571310Z     return await wrapper(*args, **kwargs)
2026-01-07T20:51:49.1571930Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-07T20:51:49.1572430Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2026-01-07T20:51:49.1572920Z 
2026-01-07T20:51:49.1573500Z self = <memmachine.common.episode_store.episode_sqlalchemy_store.SqlAlchemyEpisodeStore object at 0x118e3d130>
2026-01-07T20:51:49.1575000Z session_key = 'session_id'
2026-01-07T20:51:49.1575850Z episodes = [EpisodeEntry(content='user-b message 2', producer_id='profile_id', producer_role='dev', produced_for_id=None, episode_type=None, metadata=None, created_at=None)]
2026-01-07T20:51:49.1577390Z 
2026-01-07T20:51:49.1577720Z     @validate_call
2026-01-07T20:51:49.1578110Z     async def add_episodes(
2026-01-07T20:51:49.1578560Z         self,
2026-01-07T20:51:49.1579050Z         session_key: str,
2026-01-07T20:51:49.1579830Z         episodes: list[EpisodeEntry],
2026-01-07T20:51:49.1582780Z     ) -> list[EpisodeE]:
2026-01-07T20:51:49.1583240Z         if not episodes:
2026-01-07T20:51:49.1584460Z             return []
2026-01-07T20:51:49.1585500Z     
2026-01-07T20:51:49.1585920Z         values_to_insert: list[dict[str, Any]] = []
2026-01-07T20:51:49.1587250Z         for entry in episodes:
2026-01-07T20:51:49.1587880Z             entry_values: dict[str, Any] = {
2026-01-07T20:51:49.1588250Z                 "content": entry.content,
2026-01-07T20:51:49.1588990Z                 "session_key": session_key,
2026-01-07T20:51:49.1589760Z                 "producer_id": entry.producer_id,
2026-01-07T20:51:49.1590170Z                 "producer_role": entry.producer_role,
2026-01-07T20:51:49.1594160Z             }
2026-01-07T20:51:49.1596310Z     
2026-01-07T20:51:49.1596610Z             if entry.produced_for_id is not None:
2026-01-07T20:51:49.1597240Z                 entry_values["produced_for_id"] = entry.produced_for_id
2026-01-07T20:51:49.1598010Z     
2026-01-07T20:51:49.1599220Z             if entry.episode_type is not None:
2026-01-07T20:51:49.1604050Z                 entry_values["episode_type"] = entry.episode_type
2026-01-07T20:51:49.1604590Z     
2026-01-07T20:51:49.1604950Z             if entry.metadata is not None:
2026-01-07T20:51:49.1605510Z                 entry_values["json_metadata"] = entry.metadata
2026-01-07T20:51:49.1606790Z     
2026-01-07T20:51:49.1607070Z             if entry.created_at is not None:
2026-01-07T20:51:49.1607640Z                 entry_values["created_at"] = entry.created_at
2026-01-07T20:51:49.1607990Z     
2026-01-07T20:51:49.1608270Z             values_to_insert.append(entry_values)
2026-01-07T20:51:49.1609700Z     
2026-01-07T20:51:49.1610140Z         insert_stmt = insert(Episode).returning(Episode.id)
2026-01-07T20:51:49.1612570Z     
2026-01-07T20:51:49.1613060Z         async with self._create_session() as session:
2026-01-07T20:51:49.1613660Z             result = await session.execute(insert_stmt, values_to_insert)
2026-01-07T20:51:49.1615400Z             inserted_ids = result.scalars().all()
2026-01-07T20:51:49.1615850Z             await session.commit()
2026-01-07T20:51:49.1616260Z     
2026-01-07T20:51:49.1616860Z         int_episode_ids = [int(episode_id) for episode_id in inserted_ids]
2026-01-07T20:51:49.1617940Z         if not int_episode_ids:
2026-01-07T20:51:49.1618250Z             return []
2026-01-07T20:51:49.1618530Z     
2026-01-07T20:51:49.1618780Z         select_stmt = (
2026-01-07T20:51:49.1619070Z             select(Episode)
2026-01-07T20:51:49.1621170Z             .where(Episode.id.in_(int_episode_ids))
2026-01-07T20:51:49.1621620Z             .order_by(Episode.id.asc())
2026-01-07T20:51:49.1622060Z         )
2026-01-07T20:51:49.1622390Z     
2026-01-07T20:51:49.1622760Z         async with self._create_session() as session:
2026-01-07T20:51:49.1623920Z             result = await session.execute(select_stmt)
2026-01-07T20:51:49.1624330Z             persisted_episodes = result.scalars().all()
2026-01-07T20:51:49.1624870Z     
2026-01-07T20:51:49.1625140Z         episodes_by_id = {
2026-01-07T20:51:49.1631320Z             episode_row.id: episode_row.to_typed_model()
2026-01-07T20:51:49.1631730Z             for episode_row in persisted_episodes
2026-01-07T20:51:49.1632160Z         }
2026-01-07T20:51:49.1632540Z >       return [episodes_by_id[episode_id] for episode_id in int_episode_ids]
2026-01-07T20:51:49.1633800Z                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-07T20:51:49.1634210Z E       KeyError: 4
2026-01-07T20:51:49.1634430Z 
2026-01-07T20:51:49.1634740Z src/memmachine/common/episode_store/episode_sqlalchemy_store.py:208: KeyError
2026-01-07T20:51:49.1636100Z ---------------------------- Captured log teardown -----------------------------
2026-01-07T20:51:49.1637120Z ERROR    memmachine.semantic_memory.semantic_ingestion:semantic_ingestion.py:137 Failed to process message 3 for semantic type Profile
2026-01-07T20:51:49.1637850Z Traceback (most recent call last):
2026-01-07T20:51:49.1719620Z   File "/Users/runner/work/MemMachine/MemMachine/src/memmachine/semantic_memory/semantic_ingestion.py", line 130, in process_semantic_type
2026-01-07T20:51:49.1721230Z     commands = await llm_feature_update(
2026-01-07T20:51:49.1721800Z                ^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-07T20:51:49.1723510Z   File "/Users/runner/work/MemMachine/MemMachine/.venv/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py", line 34, in wrapper_function
2026-01-07T20:51:49.1724480Z     return await wrapper(*args, **kwargs)
2026-01-07T20:51:49.1725120Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-07T20:51:49.1726150Z   File "/Users/runner/work/MemMachine/MemMachine/src/memmachine/semantic_memory/semantic_llm.py", line 73, in llm_feature_update
2026-01-07T20:51:49.1727400Z     validated_output = TypeAdapter(_SemanticFeatureUpdateRes).validate_python(
2026-01-07T20:51:49.1728230Z                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-07T20:51:49.1729280Z   File "/Users/runner/work/MemMachine/MemMachine/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 441, in validate_python
2026-01-07T20:51:49.1730260Z     return self.validator.validate_python(
2026-01-07T20:51:49.1731070Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-07T20:51:49.1732100Z pydantic_core._pydantic_core.ValidationError: 1 validation error for _SemanticFeatureUpdateRes
2026-01-07T20:51:49.1733740Z   Input should be a valid dictionary or instance of _SemanticFeatureUpdateRes [type=model_type, input_value=<AsyncMock name='mock.gen...onse()' id='4743217424'>, input_type=AsyncMock]
2026-01-07T20:51:49.1735210Z     For further information visit https://errors.pydantic.dev/2.12/v/model_type
2026-01-07T20:51:49.1735960Z =============================== warnings summary ===============================
2026-01-07T20:51:49.1737240Z .venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215
2026-01-07T20:51:49.1737840Z .venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215
2026-01-07T20:51:49.1738300Z .venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215
2026-01-07T20:51:49.1740860Z   /Users/runner/work/MemMachine/MemMachine/.venv/lib/python3.12/site-packages/testcontainers/core/waiting_utils.py:215: DeprecationWarning: The @wait_container_is_ready decorator is deprecated and will be removed in a future version. Use structured wait strategies instead: container.waiting_for(HttpWaitStrategy(8080).for_status_code(200)) or container.waiting_for(LogMessageWaitStrategy('ready'))
2026-01-07T20:51:49.1742780Z     @wait_container_is_ready()
2026-01-07T20:51:49.1742930Z 
2026-01-07T20:51:49.1743090Z .venv/lib/python3.12/site-packages/testcontainers/neo4j/__init__.py:63
2026-01-07T20:51:49.1745270Z .venv/lib/python3.12/site-packages/testcontainers/neo4j/__init__.py:63
2026-01-07T20:51:49.1745790Z .venv/lib/python3.12/site-packages/testcontainers/neo4j/__init__.py:63
2026-01-07T20:51:49.1747120Z   /Users/runner/work/MemMachine/MemMachine/.venv/lib/python3.12/site-packages/testcontainers/neo4j/__init__.py:63: DeprecationWarning: The @wait_container_is_ready decorator is deprecated and will be removed in a future version. Use structured wait strategies instead: container.waiting_for(HttpWaitStrategy(8080).for_status_code(200)) or container.waiting_for(LogMessageWaitStrategy('ready'))
2026-01-07T20:51:49.1748630Z     @wait_container_is_ready()
2026-01-07T20:51:49.1748790Z 
2026-01-07T20:51:49.1748960Z .venv/lib/python3.12/site-packages/testcontainers/postgres/__init__.py:90
2026-01-07T20:51:49.1749420Z .venv/lib/python3.12/site-packages/testcontainers/postgres/__init__.py:90
2026-01-07T20:51:49.1749850Z .venv/lib/python3.12/site-packages/testcontainers/postgres/__init__.py:90
2026-01-07T20:51:49.1751510Z   /Users/runner/work/MemMachine/MemMachine/.venv/lib/python3.12/site-packages/testcontainers/postgres/__init__.py:90: DeprecationWarning: The @wait_container_is_ready decorator is deprecated and will be removed in a future version. Use structured wait strategies instead: container.waiting_for(HttpWaitStrategy(8080).for_status_code(200)) or container.waiting_for(LogMessageWaitStrategy('ready'))
2026-01-07T20:51:49.1752950Z     @wait_container_is_ready()
2026-01-07T20:51:49.1753120Z 
2026-01-07T20:51:49.1753530Z tests/memmachine/common/resource_manager/test_language_model_manager.py::test_build_open_ai_model
2026-01-07T20:51:49.1754420Z tests/memmachine/common/resource_manager/test_language_model_manager.py::test_build_aws_bedrock_model
2026-01-07T20:51:49.1755190Z tests/memmachine/common/resource_manager/test_language_model_manager.py::test_build_openai_chat_completions_model
2026-01-07T20:51:49.1756990Z   /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py:88: RuntimeWarning: coroutine 'LanguageModelManager.get_language_model' was never awaited
2026-01-07T20:51:49.1757920Z     self._context.run(self._callback, *self._args)
2026-01-07T20:51:49.1758580Z   Enable tracemalloc to get traceback where the object was allocated.
2026-01-07T20:51:49.1759270Z   See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
2026-01-07T20:51:49.1759710Z 
2026-01-07T20:51:49.1760070Z tests/memmachine/common/resource_manager/test_reranker_manager.py::test_build_bm25_rerankers
2026-01-07T20:51:49.1760750Z tests/memmachine/common/resource_manager/test_reranker_manager.py::test_build_cohere_rerankers
2026-01-07T20:51:49.1761790Z tests/memmachine/common/resource_manager/test_reranker_manager.py::test_build_cross_encoder_rerankers
2026-01-07T20:51:49.1762410Z tests/memmachine/common/resource_manager/test_reranker_manager.py::test_amazon_bedrock_rerankers
2026-01-07T20:51:49.1763080Z tests/memmachine/common/resource_manager/test_reranker_manager.py::test_identity_rerankers
2026-01-07T20:51:49.1763830Z tests/memmachine/common/resource_manager/test_reranker_manager.py::test_build_rrf_hybrid_rerankers
2026-01-07T20:51:49.1765030Z   /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py:88: RuntimeWarning: coroutine 'RerankerManager.get_reranker' was never awaited
2026-01-07T20:51:49.1765730Z     self._context.run(self._callback, *self._args)
2026-01-07T20:51:49.1766650Z   Enable tracemalloc to get traceback where the object was allocated.
2026-01-07T20:51:49.1767270Z   See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
2026-01-07T20:51:49.1767700Z 
2026-01-07T20:51:49.1767870Z -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
2026-01-07T20:51:49.1768300Z ================================ tests coverage ================================
2026-01-07T20:51:49.1769070Z ______________ coverage: platform darwin, python 3.12.10-final-0 _______________
2026-01-07T20:51:49.1769400Z 
2026-01-07T20:51:49.1769720Z Name                                                                                                           Stmts   Miss  Cover
2026-01-07T20:51:49.1771570Z ----------------------------------------------------------------------------------------------------------------------------------
2026-01-07T20:51:49.1772520Z src/memmachine/semantic_memory/storage/alembic_pg/env.py                                                          45     45     0%
2026-01-07T20:51:49.1773770Z src/memmachine/semantic_memory/storage/alembic_pg/versions/001_initial_migration.py                               23     23     0%
2026-01-07T20:51:49.1774660Z src/memmachine/semantic_memory/storage/alembic_pg/versions/3d6aaebdc526_sync_sqlalchemy_schema.py                 89     89     0%
2026-01-07T20:51:49.1775520Z src/memmachine/semantic_memory/storage/alembic_pg/versions/62dff1150a46_add_created_at_to_history_add.py          11     11     0%
2026-01-07T20:51:49.1776330Z src/memmachine/semantic_memory/storage/alembic_pg/versions/79f00a9f2409_change_history_id_to_string.py            13     13     0%
2026-01-07T20:51:49.1777150Z src/memmachine/semantic_memory/storage/alembic_pg/versions/843f6d216d10_rename_semantic_type_to_semantic_.py      48     48     0%
2026-01-07T20:51:49.1778090Z src/memmachine/semantic_memory/storage/alembic_pg/versions/adb5618bd4ee_remove_history_table.py                   16     16     0%
2026-01-07T20:51:49.1778840Z src/memmachine/server/mcp_http.py                                                                                 37     37     0%
2026-01-07T20:51:49.1779550Z src/memmachine/semantic_memory/storage/neo4j_semantic_storage.py                                                 605    494    18%
2026-01-07T20:51:49.1780710Z src/memmachine/common/vector_graph_store/neo4j_vector_graph_store.py                                             472    350    26%
2026-01-07T20:51:49.1781590Z src/memmachine/semantic_memory/storage/sqlalchemy_pgvector_semantic.py                                           297    220    26%
2026-01-07T20:51:49.1782550Z src/memmachine/common/resource_manager/semantic_manager.py                                                        60     42    30%
2026-01-07T20:51:49.1783280Z src/memmachine/common/language_model/amazon_bedrock_language_model.py                                            194    135    30%
2026-01-07T20:51:49.1784050Z src/memmachine/episodic_memory/declarative_memory/declarative_memory.py                                          167    114    32%
2026-01-07T20:51:49.1784830Z src/memmachine/server/mcp_stdio.py                                                                                22     14    36%
2026-01-07T20:51:49.1785530Z src/memmachine/common/reranker/cohere_reranker.py                                                                 34     17    50%
2026-01-07T20:51:49.1786250Z src/memmachine/common/reranker/amazon_bedrock_reranker.py                                                         79     39    51%
2026-01-07T20:51:49.1787060Z src/memmachine/common/embedder/sentence_transformer_embedder.py                                                   69     34    51%
2026-01-07T20:51:49.1788350Z src/memmachine/rest_client/project.py                                                                             68     33    51%
2026-01-07T20:51:49.1789230Z src/memmachine/episodic_memory/long_term_memory/long_term_memory.py                                               92     44    52%
2026-01-07T20:51:49.1790590Z src/memmachine/server/app.py                                                                                      84     40    52%
2026-01-07T20:51:49.1791310Z src/memmachine/common/resource_manager/resource_manager.py                                                       121     57    53%
2026-01-07T20:51:49.1791940Z src/memmachine/common/embedder/amazon_bedrock_embedder.py                                                         83     38    54%
2026-01-07T20:51:49.1792630Z src/memmachine/episodic_memory/long_term_memory/service_locator.py                                                 9      4    56%
2026-01-07T20:51:49.1793440Z src/memmachine/common/metrics_factory/prometheus_metrics_factory.py                                               65     28    57%
2026-01-07T20:51:49.1794450Z src/memmachine/installation/memmachine_configure.py                                                              207     79    62%
2026-01-07T20:51:49.1795160Z src/memmachine/common/filter/sql_filter_util.py                                                                   40     15    62%
2026-01-07T20:51:49.1795920Z src/memmachine/rest_client/client.py                                                                             187     67    64%
2026-01-07T20:51:49.1796580Z src/memmachine/common/resource_manager/__init__.py                                                                31     10    68%
2026-01-07T20:51:49.1797320Z src/memmachine/common/embedder/openai_embedder.py                                                                111     35    68%
2026-01-07T20:51:49.1798140Z src/memmachine/common/reranker/cross_encoder_reranker.py                                                          20      6    70%
2026-01-07T20:51:49.1798900Z src/memmachine/common/vector_graph_store/data_types.py                                                            47     14    70%
2026-01-07T20:51:49.1799660Z src/memmachine/episodic_memory/short_term_memory/service_locator.py                                                7      2    71%
2026-01-07T20:51:49.1800750Z src/memmachine/server/api_v2/mcp.py                                                                              176     49    72%
2026-01-07T20:51:49.1801420Z src/memmachine/common/vector_graph_store/vector_graph_store.py                                                    36     10    72%
2026-01-07T20:51:49.1802200Z src/memmachine/common/episode_store/episode_storage.py                                                            26      7    73%
2026-01-07T20:51:49.1802850Z src/memmachine/semantic_memory/storage/storage_base.py                                                            65     17    74%
2026-01-07T20:51:49.1803920Z src/memmachine/common/metrics_factory/metrics_factory.py                                                          31      8    74%
2026-01-07T20:51:49.1804580Z src/memmachine/episodic_memory/short_term_memory/short_term_memory.py                                            278     71    74%
2026-01-07T20:51:49.1805370Z src/memmachine/server/api_v2/service.py                                                                           36      9    75%
2026-01-07T20:51:49.1805990Z src/memmachine/main/memmachine.py                                                                                198     49    75%
2026-01-07T20:51:49.1806920Z src/memmachine/episodic_memory/declarative_memory/data_types.py                                                   45     11    76%
2026-01-07T20:51:49.1807660Z src/memmachine/common/session_manager/session_data_manager.py                                                     37      9    76%
2026-01-07T20:51:49.1808580Z src/memmachine/common/embedder/embedder.py                                                                        22      5    77%
2026-01-07T20:51:49.1809520Z src/memmachine/episodic_memory/service_locator.py                                                                 18      4    78%
2026-01-07T20:51:49.1810470Z src/memmachine/common/language_model/language_model.py                                                            10      2    80%
2026-01-07T20:51:49.1811560Z src/memmachine/common/configuration/__init__.py                                                                  167     32    81%
2026-01-07T20:51:49.1812140Z src/memmachine/common/errors.py                                                                                   32      6    81%
2026-01-07T20:51:49.1812880Z src/memmachine/common/language_model/openai_chat_completions_language_model.py                                    99     16    84%
2026-01-07T20:51:49.1813750Z src/memmachine/common/resource_manager/database_manager.py                                                       143     22    85%
2026-01-07T20:51:49.1814650Z src/memmachine/semantic_memory/semantic_ingestion.py                                                             119     18    85%
2026-01-07T20:51:49.1815500Z src/memmachine/common/language_model/openai_responses_language_model.py                                           98     14    86%
2026-01-07T20:51:49.1816150Z src/memmachine/__init__.py                                                                                        23      3    87%
2026-01-07T20:51:49.1816920Z src/memmachine/server/prompt/writing_assistant_prompt.py                                                          23      3    87%
2026-01-07T20:51:49.1817710Z src/memmachine/common/reranker/embedder_reranker.py                                                               32      4    88%
2026-01-07T20:51:49.1818460Z src/memmachine/semantic_memory/semantic_memory.py                                                                103     12    88%
2026-01-07T20:51:49.1819430Z src/memmachine/common/reranker/reranker.py                                                                         9      1    89%
2026-01-07T20:51:49.1820140Z src/memmachine/rest_client/memory.py                                                                             175     19    89%
2026-01-07T20:51:49.1820830Z src/memmachine/common/resource_manager/reranker_manager.py                                                       148     16    89%
2026-01-07T20:51:49.1821690Z src/memmachine/common/episode_store/episode_sqlalchemy_store.py                                                  171     18    89%
2026-01-07T20:51:49.1822530Z src/memmachine/common/configuration/embedder_conf.py                                                              90      9    90%
2026-01-07T20:51:49.1823300Z src/memmachine/semantic_memory/semantic_session_manager.py                                                       129     11    91%
2026-01-07T20:51:49.1824130Z src/memmachine/common/configuration/language_model_conf.py                                                        96      8    92%
2026-01-07T20:51:49.1824910Z src/memmachine/common/utils.py                                                                                    63      5    92%
2026-01-07T20:51:49.1827290Z src/memmachine/common/configuration/log_conf.py                                                                   84      6    93%
2026-01-07T20:51:49.1827960Z src/memmachine/episodic_memory/episodic_memory.py                                                                186     11    94%
2026-01-07T20:51:49.1828680Z src/memmachine/common/resource_manager/embedder_manager.py                                                        76      4    95%
2026-01-07T20:51:49.1829330Z src/memmachine/common/resource_manager/language_model_manager.py                                                  78      4    95%
2026-01-07T20:51:49.1830060Z src/memmachine/semantic_memory/semantic_llm.py                                                                    39      2    95%
2026-01-07T20:51:49.1831970Z src/memmachine/episodic_memory/episodic_memory_manager.py                                                        138      7    95%
2026-01-07T20:51:49.1832710Z src/memmachine/common/session_manager/session_data_manager_sql_impl.py                                           120      6    95%
2026-01-07T20:51:49.1833680Z src/memmachine/common/episode_store/count_caching_episode_storage.py                                              63      3    95%
2026-01-07T20:51:49.1834440Z src/memmachine/common/filter/filter_parser.py                                                                    168      7    96%
2026-01-07T20:51:49.1835100Z src/memmachine/common/api/spec.py                                                                                129      5    96%
2026-01-07T20:51:49.1835770Z src/memmachine/semantic_memory/semantic_model.py                                                                  80      3    96%
2026-01-07T20:51:49.1836900Z src/memmachine/server/api_v2/router.py                                                                           146      5    97%
2026-01-07T20:51:49.1837470Z src/memmachine/common/episode_store/episode_model.py                                                              33      1    97%
2026-01-07T20:51:49.1838060Z src/memmachine/common/configuration/mixin_confs.py                                                               117      3    97%
2026-01-07T20:51:49.1838710Z src/memmachine/common/configuration/reranker_conf.py                                                             105      2    98%
2026-01-07T20:51:49.1839450Z src/memmachine/installation/configuration_wizard.py                                                              183      3    98%
2026-01-07T20:51:49.1849510Z src/memmachine/common/configuration/database_conf.py                                                             138      1    99%
2026-01-07T20:51:49.1850240Z src/memmachine/common/__init__.py                                                                                  0      0   100%
2026-01-07T20:51:49.1850810Z src/memmachine/common/api/__init__.py                                                                              7      0   100%
2026-01-07T20:51:49.1851320Z src/memmachine/common/api/doc.py                                                                                  72      0   100%
2026-01-07T20:51:49.1851870Z src/memmachine/common/configuration/episodic_config.py                                                            69      0   100%
2026-01-07T20:51:49.1852440Z src/memmachine/common/data_types.py                                                                                9      0   100%
2026-01-07T20:51:49.1853030Z src/memmachine/common/embedder/__init__.py                                                                         2      0   100%
2026-01-07T20:51:49.1853580Z src/memmachine/common/episode_store/__init__.py                                                                    4      0   100%
2026-01-07T20:51:49.1854130Z src/memmachine/common/filter/__init__.py                                                                           0      0   100%
2026-01-07T20:51:49.1856100Z src/memmachine/common/language_model/__init__.py                                                                   2      0   100%
2026-01-07T20:51:49.1856970Z src/memmachine/common/metrics_factory/__init__.py                                                                  3      0   100%
2026-01-07T20:51:49.1857570Z src/memmachine/common/reranker/__init__.py                                                                         2      0   100%
2026-01-07T20:51:49.1858120Z src/memmachine/common/reranker/bm25_reranker.py                                                                   29      0   100%
2026-01-07T20:51:49.1858770Z src/memmachine/common/reranker/identity_reranker.py                                                                5      0   100%
2026-01-07T20:51:49.1860010Z src/memmachine/common/reranker/rrf_hybrid_reranker.py                                                             21      0   100%
2026-01-07T20:51:49.1861080Z src/memmachine/common/session_manager/__init__.py                                                                  0      0   100%
2026-01-07T20:51:49.1861680Z src/memmachine/common/vector_graph_store/__init__.py                                                               3      0   100%
2026-01-07T20:51:49.1862450Z src/memmachine/episodic_memory/__init__.py                                                                         2      0   100%
2026-01-07T20:51:49.1863150Z src/memmachine/episodic_memory/declarative_memory/__init__.py                                                      3      0   100%
2026-01-07T20:51:49.1863800Z src/memmachine/episodic_memory/instance_lru_cache.py                                                             108      0   100%
2026-01-07T20:51:49.1864450Z src/memmachine/episodic_memory/long_term_memory/__init__.py                                                        2      0   100%
2026-01-07T20:51:49.1865090Z src/memmachine/episodic_memory/short_term_memory/__init__.py                                                       0      0   100%
2026-01-07T20:51:49.1865700Z src/memmachine/installation/__init__.py                                                                            0      0   100%
2026-01-07T20:51:49.1866360Z src/memmachine/installation/utilities.py                                                                          44      0   100%
2026-01-07T20:51:49.1866920Z src/memmachine/main/__init__.py                                                                                    0      0   100%
2026-01-07T20:51:49.1867460Z src/memmachine/rest_client/__init__.py                                                                             4      0   100%
2026-01-07T20:51:49.1868010Z src/memmachine/semantic_memory/__init__.py                                                                         0      0   100%
2026-01-07T20:51:49.1868580Z src/memmachine/semantic_memory/storage/__init__.py                                                                 0      0   100%
2026-01-07T20:51:49.1869310Z src/memmachine/semantic_memory/storage/alembic_pg/__init__.py                                                      0      0   100%
2026-01-07T20:51:49.1869960Z src/memmachine/semantic_memory/storage/alembic_pg/versions/__init__.py                                             0      0   100%
2026-01-07T20:51:49.1870580Z src/memmachine/semantic_memory/util/__init__.py                                                                    0      0   100%
2026-01-07T20:51:49.1871170Z src/memmachine/semantic_memory/util/semantic_prompt_template.py                                                    4      0   100%
2026-01-07T20:51:49.1871820Z src/memmachine/server/__init__.py                                                                                  0      0   100%
2026-01-07T20:51:49.1872360Z src/memmachine/server/api_v2/__init__.py                                                                           0      0   100%
2026-01-07T20:51:49.1872920Z src/memmachine/server/prompt/__init__.py                                                                           0      0   100%
2026-01-07T20:51:49.1873500Z src/memmachine/server/prompt/coding_style_prompt.py                                                                5      0   100%
2026-01-07T20:51:49.1874060Z src/memmachine/server/prompt/crm_prompt.py                                                                        24      0   100%
2026-01-07T20:51:49.1874620Z src/memmachine/server/prompt/default_prompts.py                                                                    8      0   100%
2026-01-07T20:51:49.1875220Z src/memmachine/server/prompt/financial_analyst_prompt.py                                                          26      0   100%
2026-01-07T20:51:49.1875870Z src/memmachine/server/prompt/health_assistant_prompt.py                                                           12      0   100%
2026-01-07T20:51:49.1876700Z src/memmachine/server/prompt/profile_prompt.py                                                                     5      0   100%
2026-01-07T20:51:49.1877290Z src/memmachine/server/prompt/prompt_utilities.py                                                                  11      0   100%
2026-01-07T20:51:49.1878350Z ----------------------------------------------------------------------------------------------------------------------------------
2026-01-07T20:51:49.1878860Z TOTAL                                                                                                           8520   2754    68%
2026-01-07T20:51:49.1879240Z =========================== short test summary info ============================
2026-01-07T20:51:49.1880080Z FAILED tests/memmachine/semantic_memory/test_semantic_memory_background.py::test_multiple_sets_processed_independently[in_memory_semantic_storage-sql_db_episode_storage-sqlalchemy_sqlite_engine] - KeyError: 4
2026-01-07T20:51:49.1880860Z ====== 1 failed, 791 passed, 708 skipped, 18 warnings in 86.72s (0:01:26) ======
2026-01-07T20:51:49.4950430Z ##[error]Process completed with exit code 1.
2026-01-07T20:51:49.5211490Z Post job cleanup.
2026-01-07T20:51:50.0097440Z [command]/opt/homebrew/bin/git version
2026-01-07T20:51:50.0401960Z git version 2.52.0
2026-01-07T20:51:50.0425870Z Copying '/Users/runner/.gitconfig' to '/Users/runner/work/_temp/d9f0c836-5ffc-4fc7-afb7-51da626843e6/.gitconfig'
2026-01-07T20:51:50.0434650Z Temporarily overriding HOME='/Users/runner/work/_temp/d9f0c836-5ffc-4fc7-afb7-51da626843e6' before making global git config changes
2026-01-07T20:51:50.0436450Z Adding repository directory to the temporary git global config as a safe directory
2026-01-07T20:51:50.0437550Z [command]/opt/homebrew/bin/git config --global --add safe.directory /Users/runner/work/MemMachine/MemMachine
2026-01-07T20:51:50.0551150Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp core\.sshCommand
2026-01-07T20:51:50.0608860Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2026-01-07T20:51:50.1661290Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2026-01-07T20:51:50.1733080Z http.https://github.com/.extraheader
2026-01-07T20:51:50.1745430Z [command]/opt/homebrew/bin/git config --local --unset-all http.https://github.com/.extraheader
2026-01-07T20:51:50.1831540Z [command]/opt/homebrew/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2026-01-07T20:51:50.3059830Z [command]/opt/homebrew/bin/git config --local --name-only --get-regexp ^includeIf\.gitdir:
2026-01-07T20:51:50.3132990Z [command]/opt/homebrew/bin/git submodule foreach --recursive git config --local --show-origin --name-only --get-regexp remote.origin.url
2026-01-07T20:51:50.4740140Z Cleaning up orphan processes

Steps to reproduce

  1. Run the pytest.yml
  2. Observe the test fails with KeyError: 4 (or other episode ID).

Expected behavior

  • Unit tests should complete reliably.
  • The Method should either return only existing, persisted episodes by ID or raise a controlled exception if inserted IDs are missing, rather than triggering a raw KeyError.

Environment

Additional context

The error originates from

# src/memmachine/common/episode_store/episode_sqlalchemy_store.py (ref: cda6b58e607f2027187c8a73c739b592e6478aa9)
return [episodes_by_id[episode_id] for episode_id in int_episode_ids]

Observed behavior: If some inserted IDs are not found in the retrieval query, a raw KeyError is raised. This can happen if the database commit or session handling is inconsistent, or in cases of race conditions in async tests.

Possible fix: Safe-check for presence before lookup:

return [episodes_by_id[episode_id] for episode_id in int_episode_ids if episode_id in episodes_by_id]

or

missing = [eid for eid in int_episode_ids if eid not in episodes_by_id]
if missing:
    raise KeyError(f"Episode(s) not persisted: {missing}")
return [episodes_by_id[eid] for eid in int_episode_ids if eid in episodes_by_id]

Investigate the insert and retrieval logic for potential async race conditions or missing-data issues, and implement resilience in the lookup code as described above.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions