Skip to content

TEST: cover literal metadata filter keys - #3180

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
ManoharPaturi:fix/metadata-filter-keys
Oct 14, 2026
Merged

Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
ManoharPaturi:fix/metadata-filter-keys

Conversation

@ManoharPaturi

@ManoharPaturi Manohar Paturi (ManoharPaturi) commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds regression coverage for #3179. The production literal-key fix has already merged in #3125. This branch now includes current main and preserves that implementation unchanged rather than using quoted JSON paths, which can select or delete an unrelated nested-key record.

The remaining delta is test-only:

  • Save and reopen a file-backed SQLite database, then retrieve seeds, seed groups and message pieces by literal metadata keys.
  • Exercise individual and whole-group seed removal while preserving nested-key, wrong-value, wrong-flag and trailing-space records.
  • Cover quotes, backslashes, dots, hyphens, spaces, empty keys and Unicode keys, with multiple predicates and integer/string value distinctions.
  • Compile all Azure SQL metadata wrappers with the MSSQL pyodbc dialect and verify literal bound keys, scalar types, key-length guards and positional bindings.

No public API, schema or production behavior changes relative to current main.

Tests and Documentation

Local validation after merging main:

  • uv run --frozen --no-sync python -m pytest tests\unit\memory\test_sqlite_memory.py tests\unit\memory\test_azure_sql_memory.py tests\unit\memory\memory_interface\test_interface_seed_prompts.py tests\unit\memory\memory_interface\test_interface_remove_seeds.py tests\unit\memory\memory_interface\test_interface_prompts.py -q: 426 passed, 1 skipped.
  • uv run --frozen --no-sync ruff check tests\unit\memory\test_sqlite_memory.py tests\unit\memory\test_azure_sql_memory.py: passed.
  • uv run --frozen --no-sync ruff format --check tests\unit\memory\test_sqlite_memory.py tests\unit\memory\test_azure_sql_memory.py: passed.
  • uv run --frozen --no-sync ty check tests\unit\memory\test_sqlite_memory.py tests\unit\memory\test_azure_sql_memory.py: passed.
  • Repository commit hooks, including the full production type check: passed.

No live Azure SQL integration was run. Azure assertions check generated SQL and bound parameters, not live server execution. The SQLite tests use real local databases. No documentation changed, so JupyText was not run.

_get_seed_metadata_conditions and _get_message_pieces_prompt_metadata_
conditions interpolated the metadata key into the JSON path and the bind
parameter name. A key like a.b made SQLAlchemy parse :a.b as parameter a
plus literal text, so the later bindparams() call raised ArgumentError
and the query crashed. Keys with hyphens or spaces failed the same way.

Bind each key as a quoted JSON path parameter with an indexed value
parameter on both SQLite and Azure SQL, the same shape the label fix in
microsoft#3063 already uses.

Fixes microsoft#3179

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Use SQLite json_each and Azure SQL OPENJSON rather than constructing JSON paths from free-form keys. Preserve scalar value comparisons and protect seed and seed-group deletion from matching nested or padded keys.

Add saved/reopened retrieval and removal regressions, including quoted and backslash keys, and verify literal key bindings through the MSSQL dialect.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1696f5bb-ccc6-41e1-a983-7cceb2ec6e3c
Comment thread pyrit/memory/sqlite_memory.py Outdated
Keep the production literal-key fix already merged in microsoft#3125 and retain additional saved/reopened retrieval, deletion, value-type and MSSQL binding coverage for microsoft#3180.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 1696f5bb-ccc6-41e1-a983-7cceb2ec6e3c
@romanlutz Roman Lutz (romanlutz) changed the title FIX: quote metadata filter keys so special characters work TEST: cover literal metadata filter keys Oct 14, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 14, 2026
Merged via the queue into microsoft:main with commit 60d3f0e Oct 14, 2026
51 checks passed
@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Saw the merge, thanks for reworking it onto the literal matching and keeping the regression tests, that is the version that should stick. Congratulating myself for trying to close an already merged PR, classic.

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.

3 participants