Skip to content

Conversation

@KarthikeyaKollu
Copy link

fixes #215 This commit fixes two critical issues that prevented memory injection from working with the Google GenAI SDK:

  1. _extract_user_query now handles Google GenAI's 'contents' parameter:

    • Supports string contents (simple query)
    • Supports list of strings
    • Supports structured contents format with parts/role
  2. inject_recalled_facts now properly injects context for Google GenAI:

    • If config.system_instruction is available, appends context there
    • Otherwise, prepends context to the first user message's content
    • If first message is not a user role, inserts a new context message
    • Properly normalizes contents format (string/list/structured)
    • Ensures kwargs['contents'] is properly updated

Also fixed a minor bug where kwargs['messages'] wasn't being assigned back in the else branch for non-Anthropic/Bedrock providers.

Includes comprehensive tests for all Google GenAI scenarios:

  • String contents
  • List of strings
  • Structured contents with parts/role
  • system_instruction config
  • Edge case: first message not user role

…#215)

This commit fixes two critical issues that prevented memory injection
from working with the Google GenAI SDK:

1. _extract_user_query now handles Google GenAI's 'contents' parameter:
   - Supports string contents (simple query)
   - Supports list of strings
   - Supports structured contents format with parts/role

2. inject_recalled_facts now properly injects context for Google GenAI:
   - If config.system_instruction is available, appends context there
   - Otherwise, prepends context to the first user message's content
   - If first message is not a user role, inserts a new context message
   - Properly normalizes contents format (string/list/structured)
   - Ensures kwargs['contents'] is properly updated

Also fixed a minor bug where kwargs['messages'] wasn't being assigned back
in the else branch for non-Anthropic/Bedrock providers.

Includes comprehensive tests for all Google GenAI scenarios:
- String contents
- List of strings
- Structured contents with parts/role
- system_instruction config
- Edge case: first message not user role
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.

[Bug] Automatic memory injection fails for Google GenAI provider (contents vs messages mismatch)

1 participant