Skip to content

Fix conversation context loss in Addie chat - #525

Merged
bokelley merged 1 commit into
mainfrom
bokelley/fix-lost-context
Jan 3, 2026
Merged

Fix conversation context loss in Addie chat#525
bokelley merged 1 commit into
mainfrom
bokelley/fix-lost-context

Conversation

@bokelley

@bokelley bokelley commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixed Addie losing conversation context by using proper Claude API message turns instead of flattening thread history into a single string
  • Claude now receives actual user/assistant message turns, which it understands as real conversation context

Problem

Addie was losing context mid-conversation. When a user asked follow-up questions, Addie would forget what was just discussed and ask clarifying questions unnecessarily.

Root cause: Conversation history was being flattened into a single user message string:

Previous messages in thread:
User: Can you help me with AdMesh?
Addie: AdMesh looks like a strong prospect...

Current message: an outreach message would be great!

Claude treats this as informational text, not actual conversation context.

Solution

Created buildMessageTurns() function that converts history into proper alternating message turns:

[
  { role: 'user', content: 'Can you help me with AdMesh?' },
  { role: 'assistant', content: 'AdMesh looks like a strong prospect...' },
  { role: 'user', content: 'an outreach message would be great!' }
]

Claude's API treats this as actual conversation, preserving context.

Test plan

  • Unit tests for buildMessageTurns() covering edge cases
  • All existing tests pass (153 tests)
  • TypeScript compiles with no errors
  • Manual testing in Slack to verify context is preserved

🤖 Generated with Claude Code

Addie was losing conversation context because thread history was being
flattened into a single user message string rather than proper
user/assistant turns. Claude treats this flattened format as
informational text rather than actual conversation context.

Changes:
- Add buildMessageTurns() function to convert thread context into
  proper alternating user/assistant message turns
- Handle Claude API requirements: user-first messages, alternating roles
- Skip empty messages defensively
- Add unit tests for the new function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley
bokelley merged commit 2c06591 into main Jan 3, 2026
6 checks passed
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.

1 participant