@@ -27,15 +27,17 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => {
2727 expect ( ctx . content ) . toBe ( "hello world" ) ;
2828 } ) ;
2929
30- it ( "strips bot mention in p2p (addressing prefix, not semantic content) " , ( ) => {
30+ it ( "preserves bot mention in p2p" , ( ) => {
3131 const ctx = parseFeishuMessageEvent (
3232 makeEvent ( "@_bot_1 hello" , [ { key : "@_bot_1" , name : "Bot" , id : { open_id : "ou_bot" } } ] ) ,
3333 BOT_OPEN_ID ,
3434 ) ;
35- expect ( ctx . content ) . toBe ( "hello" ) ;
35+ // Bot's own <at> tag is now preserved so LLM can see the complete @ context.
36+ // Command detection uses normalizeFeishuCommandProbeBody which strips <at> tags anyway.
37+ expect ( ctx . content ) . toBe ( '<at user_id="ou_bot">Bot</at> hello' ) ;
3638 } ) ;
3739
38- it ( "strips bot mention in group so slash commands work (#35994) " , ( ) => {
40+ it ( "preserves bot mention in group so LLM sees complete @ context " , ( ) => {
3941 const ctx = parseFeishuMessageEvent (
4042 makeEvent (
4143 "@_bot_1 hello" ,
@@ -44,10 +46,12 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => {
4446 ) ,
4547 BOT_OPEN_ID ,
4648 ) ;
47- expect ( ctx . content ) . toBe ( "hello" ) ;
49+ // Bot's own <at> tag is preserved. Slash commands still work because
50+ // normalizeFeishuCommandProbeBody strips all <at> tags before command parsing.
51+ expect ( ctx . content ) . toBe ( '<at user_id="ou_bot">Bot</at> hello' ) ;
4852 } ) ;
4953
50- it ( "strips bot mention in group preserving slash command prefix (#35994)" , ( ) => {
54+ it ( "preserves bot mention in group for slash commands (#35994)" , ( ) => {
5155 const ctx = parseFeishuMessageEvent (
5256 makeEvent (
5357 "@_bot_1 /model" ,
@@ -56,18 +60,21 @@ describe("normalizeMentions (via parseFeishuMessageEvent)", () => {
5660 ) ,
5761 BOT_OPEN_ID ,
5862 ) ;
59- expect ( ctx . content ) . toBe ( "/model" ) ;
63+ // Bot's <at> tag is preserved, but slash command is still detected because
64+ // normalizeFeishuCommandProbeBody strips <at> tags before checking for / prefix.
65+ expect ( ctx . content ) . toBe ( '<at user_id="ou_bot">Bot</at> /model' ) ;
6066 } ) ;
6167
62- it ( "strips bot mention but normalizes other mentions in p2p (mention-forward)" , ( ) => {
68+ it ( "preserves bot mention and other mentions in p2p (mention-forward)" , ( ) => {
6369 const ctx = parseFeishuMessageEvent (
6470 makeEvent ( "@_bot_1 @_user_alice hello" , [
6571 { key : "@_bot_1" , name : "Bot" , id : { open_id : "ou_bot" } } ,
6672 { key : "@_user_alice" , name : "Alice" , id : { open_id : "ou_alice" } } ,
6773 ] ) ,
6874 BOT_OPEN_ID ,
6975 ) ;
70- expect ( ctx . content ) . toBe ( '<at user_id="ou_alice">Alice</at> hello' ) ;
76+ // All <at> tags are now preserved (including bot's own).
77+ expect ( ctx . content ) . toBe ( '<at user_id="ou_bot">Bot</at> <at user_id="ou_alice">Alice</at> hello' ) ;
7178 } ) ;
7279
7380 it ( "falls back to @name when open_id is absent" , ( ) => {
0 commit comments