Skip to content

Python: fix(memory): return no results for a non-positive transcript search limit - #9907

Open
lisry-1 wants to merge 1 commit into
microsoft:mainfrom
lisry-1:fix/search-transcripts-non-positive-limit
Open

lisry-1 wants to merge 1 commit into
microsoft:mainfrom
lisry-1:fix/search-transcripts-non-positive-limit

Conversation

@lisry-1

@lisry-1 lisry-1 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

MemoryFileStore.search_transcripts appended a match and only then checked whether it had reached limit, so limit=0 (and any negative limit) returned exactly one result instead of none. The search_memory_transcripts tool passes limit through unchanged, so a model supplying 0 silently received a single row — inconsistent with the pagination convention elsewhere (_validate_paging rejects top <= 0).

Changes

  • Short-circuit before scanning when limit <= 0, returning an empty list.
  • Empty-query validation is unchanged (still raises ValueError).

Tests

Adds test_search_transcripts_non_positive_limit_returns_nothing covering limit=0 and a negative limit.

…imit

MemoryFileStore.search_transcripts appended a match and only then checked
whether it had reached the limit, so limit=0 (and any negative limit)
returned exactly one result instead of none. The limit is passed through
unchanged by the search_memory_transcripts tool, so a model supplying 0
silently got a single row.

Short-circuit before scanning when limit <= 0. Adds a regression test
covering limit=0 and a negative limit.

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.

🟢 Approval recommended

No active review issues were identified for the fix to non-positive transcript-search limits.

No open issues 🎉

What changed in this PR

Fixes transcript search in Python’s MemoryFileStore so non-positive limits return no results instead of one match.

Changes:

  • Returns an empty list before scanning transcripts when limit <= 0, while preserving empty-query validation.
  • Adds regression coverage for zero and negative limits.
File Description
python/​packages/​core/​tests/​core/​test_harness_memory.py Adds regression assertions for limits of 0 and -1.
python/​packages/​core/​agent_framework/​_harness/​_memory.py Adds an early return for non-positive search limits.

Review effort: Balanced

This branch was previously deployed

1 inactive deployment
github-app-auth — 3ce8b23c Deployed Oct 31, 2026 by lisry-1 via team_check #8205
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants