Skip to content

feat(memory-tools): accept client supplied memory ids in CreateMemoryTool - #27

Merged
nkanu17 merged 4 commits into
mainfrom
feat/client-supplied-memory-ids
Jul 31, 2026
Merged

feat(memory-tools): accept client supplied memory ids in CreateMemoryTool#27
nkanu17 merged 4 commits into
mainfrom
feat/client-supplied-memory-ids

Conversation

@nkanu17

@nkanu17 nkanu17 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Closes #24

CreateMemoryTool.run_async now accepts an optional application-level id. On the managed Redis Agent Memory backend, the ID is combined with the resolved namespace and user to derive a collision-resistant, managed-safe record ID. A retry with the same application ID in the same scope upserts instead of creating a duplicate, while equal IDs in different user or namespace scopes remain isolated. When absent, the existing stable_memory_id fallback is unchanged.

Design decisions:

  • The parameter is deliberately not added to the LLM tool declaration; models must not invent memory IDs. Direct callers pass it programmatically for idempotent retries.
  • The self-hosted opensource-agent-memory backend cannot honor client IDs because add_memory_tool generates its own ID. The tool logs the limitation without exposing the supplied ID and proceeds with a server-generated ID.
  • The branch is rebased onto the latest main, including invocation-user resolution through tool_context.

Tests cover scoped ID derivation, raw-ID collision resistance, namespace/user isolation including tool_context users, numeric zero, stable fallback behavior, same-ID idempotency, and redacted self-hosted warnings.

make check passes fully: format, lint, mypy, 142 passed, 9 skipped.

Copilot AI review requested due to automatic review settings July 31, 2026 20:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for application-supplied memory IDs to CreateMemoryTool.run_async to enable idempotent retries for managed Redis Agent Memory writes, while explicitly not exposing the parameter to the LLM tool declaration. For the self-hosted backend, the tool warns that client IDs are not supported and proceeds with the server-generated ID.

Changes:

  • Accept optional id in CreateMemoryTool.run_async, sanitize it for the managed backend, and use it as the record ID to support upserts on retries.
  • Log a warning when id is provided for the self-hosted opensource-agent-memory backend (which cannot honor client IDs).
  • Add tests for client ID passthrough, sanitization, stable-id fallback, idempotency behavior, and the self-hosted warning path; document the behavior in the memory concepts docs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/adk_redis/tools/memory/create.py Adds optional client-supplied id handling, managed-ID sanitization, and self-hosted warning behavior.
tests/tools/test_memory_tools.py Adds coverage for client ID behavior (managed) and warning behavior (self-hosted).
docs/concepts/memory.md Documents the optional application-level id and the differing backend behaviors.
Suppressed comments (1)

src/adk_redis/tools/memory/create.py:205

  • client_memory_id is checked using truthiness (if client_memory_id:), which treats values like 0 as absent and falls back to stable_memory_id. If callers derive IDs from numeric task IDs, this breaks the idempotency contract. Use an explicit None check so any provided ID value is honored (or rejected by sanitization).
      if client_memory_id:
        memory_id = sanitize_managed_identifier(str(client_memory_id))
      else:

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

Comment thread src/adk_redis/tools/memory/create.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d20ca6e20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/adk_redis/tools/memory/create.py Outdated
Comment thread src/adk_redis/tools/memory/create.py Outdated
Comment thread src/adk_redis/tools/memory/create.py Outdated
Copilot AI review requested due to automatic review settings July 31, 2026 21:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Suppressed comments (1)

src/adk_redis/tools/memory/create.py:177

  • The warning for the self-hosted backend logs the raw client-supplied memory id. Since this is an application-level id (often derived from queue/task identifiers), logging it at WARNING can unintentionally leak sensitive identifiers into logs. Consider logging the limitation without echoing the provided id (or log a redacted/hash form).
          logger.warning(
              "Client-supplied memory id %r is not supported by the "
              "opensource-agent-memory backend: add_memory_tool generates "
              "its own memory ID. Proceeding without the client id.",
              client_memory_id,

Copilot AI review requested due to automatic review settings July 31, 2026 21:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

@nkanu17
nkanu17 force-pushed the feat/client-supplied-memory-ids branch from 53cb536 to a121b25 Compare July 31, 2026 21:56
Copilot AI review requested due to automatic review settings July 31, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

@nkanu17
nkanu17 merged commit 8cf052c into main Jul 31, 2026
4 checks passed
@nkanu17
nkanu17 deleted the feat/client-supplied-memory-ids branch July 31, 2026 22:00
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.

CreateMemoryTool: support client-supplied memory ids for idempotent retries

2 participants