Avoid duplicate user prompt and responses in context history#139
Avoid duplicate user prompt and responses in context history#139rangamani54 wants to merge 7 commits into
Conversation
WalkthroughThe Slack client tightens thread-reply deduplication when building conversation history and removes the prior behavior of appending the assistant's finalResponse to history in the LLM no-tool execution path. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant S as SlackClient
participant H as HistoryStore
participant L as LLM
U->>S: send prompt (timestamp)
S->>S: fetch thread replies for timestamp
loop for each reply
S->>H: check if reply in history
alt exists in history
S-->>H: skip reply
else if reply.Timestamp == timestamp
S-->>H: skip original message
else
S->>H: append reply to history
end
end
S->>L: call LLM with built history
alt LLM invokes a tool
L->>S: tool result + assistant response
S->>H: append tool result and assistant response to history
else No tool executed
L->>S: assistant finalResponse
S-->>H: (no append of assistant finalResponse in this path)
end
S->>U: send reply
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)internal/slack/**/*.go📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (2)📚 Learning: 2025-07-20T02:54:03.119ZApplied to files:
📚 Learning: 2025-07-20T02:54:03.119ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
internal/slack/client.go (2)
384-384: Consider removing commented-out code.The commented-out line suggests a previous deduplication approach using a composite key format
UserID:Content. Since the current implementation usesSlackTimestampas the unique identifier (which is more reliable), this commented code should be removed to improve code cleanliness.Apply this diff to remove the commented code:
- // key := fmt.Sprintf("%s:%s", msg.UserID, msg.Content) existingMessages[msg.SlackTimestamp] = true
388-388: Consider removing commented-out code.Similar to line 384, this commented-out line should be removed as it references the old deduplication approach.
Apply this diff to remove the commented code:
- // replyKey := fmt.Sprintf("%s:%s", reply.User, reply.Text) // Check if this reply is already in history and not the original message
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/slack/client.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
internal/slack/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
Slack client implementation and message formatting should be in
internal/slack/
Files:
internal/slack/client.go
🔇 Additional comments (1)
internal/slack/client.go (1)
389-390: LGTM! The deduplication logic correctly prevents the original message from being added twice.The additional condition
reply.Timestamp != timestampensures that when iterating through thread replies, the original message that triggered this handler is excluded. This prevents duplication since the same message is explicitly added to history at line 409.The logic is sound:
- Thread replies include all messages in the thread (including the current one)
- Without this check, the current message would be added both in this loop and at line 409
- The timestamp comparison effectively filters it out during the loop iteration
Signed-off-by: rangamani54 <[email protected]>
874c57c to
db8aafc
Compare
Signed-off-by: rangamani54 <[email protected]>
…sage' into fix/skip_actual_message
Signed-off-by: rangamani54 <[email protected]>
|
@cursor code review |
Summary by CodeRabbit