Skip to content

fix(db): normalize agent name in memory vector search - #2307

Merged
EItanya merged 4 commits into
kagent-dev:mainfrom
mesutoezdil:fix/memory-search-agent-name
Jul 21, 2026
Merged

fix(db): normalize agent name in memory vector search#2307
EItanya merged 4 commits into
kagent-dev:mainfrom
mesutoezdil:fix/memory-search-agent-name

Conversation

@mesutoezdil

Copy link
Copy Markdown
Contributor

ListAgentMemories and DeleteAgentMemory match both the hyphen and underscore forms of the agent name. SearchAgentMemory only matched the raw form, so a search with one form silently missed memories stored under the other. The same normalization is now applied in the search query. Covered by a new test.

Copilot AI review requested due to automatic review settings July 21, 2026 08:58
@mesutoezdil
mesutoezdil requested a review from a team as a code owner July 21, 2026 08:58
@github-actions github-actions Bot added the bug Something isn't working label Jul 21, 2026

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.

Pull request overview

This PR fixes inconsistent agent-name normalization in the Postgres vector-search query so SearchAgentMemory returns memories regardless of whether they were stored under a hyphenated or underscore-normalized agent name. This aligns search behavior with the existing normalization behavior in list/delete paths and adds a regression test.

Changes:

  • Update SearchAgentMemory SQL to match either of two agent-name variants (raw + normalized) while keeping the user scoping intact.
  • Update the Postgres DB client to pass both the raw agent name and its hyphen→underscore normalized variant into the query.
  • Add a new test that stores a memory under the underscore form and verifies searching with the hyphenated form returns it.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
go/core/internal/database/queries/memory.sql Expands SearchAgentMemory filtering to match either raw or normalized agent name, adjusts parameter ordering.
go/core/internal/database/gen/memory.sql.go Regenerates sqlc output to reflect the updated query signature (additional agent-name parameter).
go/core/internal/database/client_postgres.go Passes both raw and normalized agent name into SearchAgentMemory.
go/core/internal/database/client_test.go Adds regression test for normalized-name search and includes minor comment punctuation tweaks.
Files not reviewed (1)
  • go/core/internal/database/gen/memory.sql.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@mesutoezdil
mesutoezdil force-pushed the fix/memory-search-agent-name branch from dbe754c to 5682f20 Compare July 21, 2026 09:09
@EItanya
EItanya merged commit 0c4f57f into kagent-dev:main Jul 21, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants