Skip to content

fix(llm): avoid mutating caller messages#1634

Open
iroiro147 wants to merge 1 commit into
getzep:mainfrom
iroiro147:fix/llm-message-immutability-1629
Open

fix(llm): avoid mutating caller messages#1634
iroiro147 wants to merge 1 commit into
getzep:mainfrom
iroiro147:fix/llm-message-immutability-1629

Conversation

@iroiro147

Copy link
Copy Markdown

Summary

  • clone caller-provided message lists before public generate_response prompt preparation
  • cover base, OpenAI/OpenAI-compatible, Anthropic, Gemini, and GLiNER2 response paths
  • add regressions proving reused caller messages do not accumulate schema/language/preamble/retry prompt mutations

Closes #1629

Tests

  • uv run pytest tests/llm_client/test_client.py tests/llm_client/test_openai_client.py tests/llm_client/test_openai_generic_client.py tests/llm_client/test_anthropic_client.py tests/llm_client/test_gemini_client.py -q
    • 72 passed, 1 warning
  • make lint
    • ruff passed
    • pyright passed with 0 errors
  • make test
    • environment-blocked after 171 passed / 2 skipped / 10 deselected
    • failed in Neo4j-backed tests/test_add_triplet.py setup because no local Neo4j service was available at localhost:7687; interrupted after repeated neo4j.exceptions.ServiceUnavailable connection retries

@zep-cla-assistant

zep-cla-assistant Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@iroiro147

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: sarthak.singh@juspay.in

@iroiro147

Copy link
Copy Markdown
Author

recheck

zep-cla-assistant Bot added a commit that referenced this pull request Jul 8, 2026
@iroiro147
iroiro147 force-pushed the fix/llm-message-immutability-1629 branch from 8c3ab0b to 06ff176 Compare July 12, 2026 16:29
@iroiro147

Copy link
Copy Markdown
Author

Hi maintainers — a gentle follow-up on this bug fix for #1629. It keeps caller-provided messages immutable across the base and provider-specific response paths, with focused regression coverage. I refreshed it onto current main; CLA, Ruff, and fork checks pass, and the remaining triage failure is the repository automation’s external-contributor permission check. Happy to adjust the approach or scope if you would prefer anything different.

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.

LLMClient.generate_response mutates messages non-idempotently: language instruction and schema JSON stack on reuse, cache misses

1 participant