Skip to content

fix(core): ExtraContent lost after alias resolution#553

Closed
xfromcnZL wants to merge 1 commit intochenhg5:mainfrom
xfromcnZL:fix/extra-content-alias-override
Closed

fix(core): ExtraContent lost after alias resolution#553
xfromcnZL wants to merge 1 commit intochenhg5:mainfrom
xfromcnZL:fix/extra-content-alias-override

Conversation

@xfromcnZL
Copy link
Copy Markdown
Contributor

Summary

  • ExtraContent (reply quotes, location text, etc.) was silently discarded during message processing
  • Root cause: handleMessage correctly prepends ExtraContent to msg.Content, but the subsequent alias resolution uses the original content variable (without ExtraContent) and overwrites msg.Content
  • Fix: pass msg.Content (which includes ExtraContent) to resolveAlias instead of the original content variable

Bug reproduction

  1. User replies to a message in Discord (or any platform that sets ExtraContent)
  2. enrichReplyContent correctly returns [Reply to user]: original message
  3. Line 1342 correctly sets msg.Content = ExtraContent + "\n" + content
  4. Bug: Line 1347 content = e.resolveAlias(content) uses the original content without ExtraContent
  5. Line 1348 msg.Content = content overwrites the enriched content — reply context is lost
  6. Agent never sees what the user was replying to

Changes

  • core/engine.go: Changed resolveAlias(content)resolveAlias(msg.Content) (1 line)

Test plan

  • go test ./core/ -run Alias passes
  • go build ./... passes
  • Manual test: Discord reply now correctly delivers quoted context to the agent

🤖 Generated with Claude Code

When a message has ExtraContent (e.g. reply quotes from Discord/Telegram),
handleMessage correctly prepends it to msg.Content at line 1342. However,
the alias resolution at line 1347 still uses the original `content` variable
(without ExtraContent) and then overwrites msg.Content, silently discarding
the enriched context.

Fix: pass msg.Content (which includes ExtraContent) to resolveAlias instead
of the original content variable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@chenhg5 chenhg5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Correct fix — using msg.Content (which preserves ExtraContent prefix from reply quotes) instead of the already-stripped local variable. Simple and correct.

PR: #553

@chenhg5
Copy link
Copy Markdown
Owner

chenhg5 commented Apr 15, 2026

@xfromcnZL, please help resolve the current code conflicts. Thx.

@xfromcnZL
Copy link
Copy Markdown
Contributor Author

Thanks for flagging the conflict @chenhg5.

After reviewing, main already fixes the same ExtraContent-loss bug with a better approach (resolve aliases on pure user text first, then merge ExtraContent back). This avoids the edge case where reply-quoted content could accidentally trigger an alias match.

Since the root cause is already addressed on main, closing this PR as superseded. 🙏

@xfromcnZL xfromcnZL closed this Apr 15, 2026
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