Skip to content

feat(helpers): add ConversationManager for multi-turn conversations#1478

Open
ajit216 wants to merge 3 commits intoanthropics:mainfrom
ajit216:feature/rap-836-conversation-manager
Open

feat(helpers): add ConversationManager for multi-turn conversations#1478
ajit216 wants to merge 3 commits intoanthropics:mainfrom
ajit216:feature/rap-836-conversation-manager

Conversation

@ajit216
Copy link
Copy Markdown

@ajit216 ajit216 commented Apr 30, 2026

Summary

  • Adds ConversationManager (sync) and AsyncConversationManager (async) helpers to anthropic.helpers that maintain multi-turn conversation history and auto-truncate oldest message pairs when approaching context window limits
  • Supports both heuristic (zero extra API calls) and accurate (count_tokens) truncation modes with configurable headroom
  • Includes comprehensive test suite (60 tests), example script, and code review report per RAP-836 plan

Test plan

  • All 60 unit tests pass (pytest tests/helpers/test_conversation.py)
  • Verify imports: from anthropic.helpers import ConversationManager, AsyncConversationManager
  • Run example script with live API key: python examples/helpers/conversation_example.py
  • Validate no regressions in existing test suite

🤖 Generated with Claude Code

ajitchavan-fp and others added 2 commits April 30, 2026 13:23
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nagement

Implements RAP-836: ConversationManager (sync) and AsyncConversationManager
(async) helpers that maintain multi-turn conversation history and auto-truncate
the oldest messages when approaching a model's context window limit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ajit216 ajit216 requested a review from a team as a code owner April 30, 2026 09:07
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants