Skip to content

[Bug]: StreamingResponse citations do not have working URLs #2330

@tianjing-li

Description

@tianjing-li
Contributor

Language

Javascript/Typescript

Version

latest - 1.7.3

Description

Using the StreamingResponse with .setCitation(), I have added an array of citations that are all formatted like so

                        return {
                            title: doc.title || '',
                            url: doc.url || '',
                            content: truncLong(doc.text || ''),
                            filepath: '',
                        };

The citations appear:

Image

However the URLs do not work, and it also seems like the title and content fields might be misplaced?

Reproduction Steps

1. Inside a message handler `app.activity(ActivityTypes.Message,`
2. Initialize a `let streamer = new StreamingResponse(context);`
3. 
Format citations and set them on the streamer like so:


let stream_citations: Citation[] = docs.map((doc) => {
                        return {
                            title: doc.title || '',
                            url: doc.url || '',
                            content: truncLong(doc.text || ''),
                            filepath: '',
                        };
                    });

                    streamer.setCitations(stream_citations);

Activity

sayali-MSFT

sayali-MSFT commented on Feb 28, 2025

@sayali-MSFT

@tianjing-li ,Thank you for your inquiry about your Teams app development issue! To assist you better, could you please provide the following details?

Documentation Links: Any specific documentation you followed that relates to your problem.

This information will help us better understand the situation and provide a more accurate response.

tianjing-li

tianjing-li commented on Feb 28, 2025

@tianjing-li
ContributorAuthor

@sayali-MSFT I've looked at the docs for the StreamingResponse class directly. Here there is a setCitations() method which I've called with correctly formatted Citation objects

tianjing-li

tianjing-li commented on Feb 28, 2025

@tianjing-li
ContributorAuthor

When using context.sendActivity(..) to send a message directly with citations attached this seems to work for the URL, however I need citations to work for my streamed response. Let me know if my approach with setCitations() is not correct, otherwise there's likely a bug.

lilyydu

lilyydu commented on Mar 1, 2025

@lilyydu
Collaborator

Hi @tianjing-li , what are the URLs linking to right now?

sayali-MSFT

sayali-MSFT commented on Mar 3, 2025

@sayali-MSFT

@tianjing-li , It looks like you're trying to use the StreamingResponse class to send a message with citations. Based on your description, the URLs in the citations may not be working, and the title and content fields might be misplaced.

To resolve this, please ensure the following:

  1. The URLs are valid and accessible—try testing them separately to confirm they work.
  2. The field mapping is correct, ensuring that the title, url, and content fields are properly assigned.
  3. The StreamingResponse class is correctly implemented and supports the setCitations method as expected.

Additionally, could you please share the information requested by @lilyydu?

tianjing-li

tianjing-li commented on Mar 3, 2025

@tianjing-li
ContributorAuthor

Hi @lilyydu, I've tested them with links to regular wikipedia pages, here's an example command I used to test a stream with citations:

app.message('/stream', async (context: TurnContext, state: ApplicationTurnState) => {
        let streamer = new StreamingResponse(context);
        streamer.setGeneratedByAILabel(true);
        streamer.queueInformativeUpdate('hello this is informative');
        streamer.queueTextChunk('This');
        streamer.queueTextChunk(' is a[1]');
        streamer.queueTextChunk(' streaming test [2]');

        const citations: Citation[] = [
            {
                title: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
                url: 'https://en.wikipedia.org/wiki/Canada',
                content: 'Canada description',
                filepath: '',
            },
            {
                title: 'Another country',
                url: 'https://en.wikipedia.org/wiki/Japan',
                content: 'Japan description',
                filepath: '',
            },
        ];
        streamer.setCitations(citations);
        await streamer.endStream();
    });

I also have working RAG functionality that generates actual citations, but the general logic is the same. Neither of them seem to open the URL.

Just in case, here's my package versions:

        @microsoft/teams-ai": "^1.7.3",
        "botbuilder": "^4.23.2",
        "botbuilder-core": "^4.23.2",
lilyydu

lilyydu commented on Mar 4, 2025

@lilyydu
Collaborator

Based on the screenshot above, is the message being represented as the URL instead?
And can you confirm that the message being returned is correct as well?

tianjing-li

tianjing-li commented on Mar 4, 2025

@tianjing-li
ContributorAuthor

@lilyydu I believe I found the error, if you look at the source code of setCitations(), you'll see actually that you're parsing the Citation object in the parameter but not using the url property when constructing the new ClientCitation object.

See: https://github.com/microsoft/teams-ai/blob/main/js/packages/teams-ai/src/StreamingResponse.ts#L158

tianjing-li

tianjing-li commented on Mar 4, 2025

@tianjing-li
ContributorAuthor

Changing the method to

...
                    appearance: {
                        '@type': 'DigitalDocument',
                        name: citation.title || `Document #${currPos + 1}`,
                        abstract: Utilities.snippet(citation.content, 477),
                        url: citation.url || undefined,
                    },
...

Seems to work

corinagum

corinagum commented on Mar 13, 2025

@corinagum
Collaborator

@tianjing-li This was an intentional decision at the time of implementation because the citation urls provided by Azure inevitably linked to a 404. After a lot of discussion internally, we decided that linking to a 404 would confuse people more than leaving it intentionally blank, since for a user to be able to view anything in the citation the develper would need to provide a public link to the file being cited.

However it looks like that's been resolved, it looks like we can update both streaming and non-streaming in all three languages to automatically link the citation.url :)

lilyydu

lilyydu commented on Mar 13, 2025

@lilyydu
Collaborator

@tianjing-li Would you be able to file this python fix in a PR for both the streaming and non-streaming cases?

The other spot would be here-
https://github.com/microsoft/teams-ai/blob/5b3d35c832de200ad374da7a0a1819f73bf795eb/python/packages/ai/teams/ai/ai.py#L302-L311

tianjing-li

tianjing-li commented on Jul 8, 2025

@tianjing-li
ContributorAuthor

@lilyydu is this still a need? I likely have bandwidth this week to make a PR

lilyydu

lilyydu commented on Jul 8, 2025

@lilyydu
Collaborator

Hi @tianjing-li,

Yup that would be greatly appreciated!

tianjing-li

tianjing-li commented on Jul 10, 2025

@tianjing-li
ContributorAuthor

@lilyydu Please take a look at #2528

added a commit that references this issue on Jul 15, 2025
2ae4c42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @corinagum@tianjing-li@lilyydu@sayali-MSFT

    Issue actions

      [Bug]: StreamingResponse citations do not have working URLs · Issue #2330 · microsoft/teams-sdk