fix: citation marker in response - #1143
Merged
Merged
Conversation
…hestration manager - Add functions to manage streaming citation buffers and clean citations. - Update orchestration manager to clear citation buffers and clean final text. - Enhance unit tests for citation cleaning and streaming callbacks.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the backend response handling to strip Azure Foundry-style citation markers (e.g., [5:0†source]) from both final and streaming agent output, and adds/updates tests to cover the new citation format and chunk-splitting behavior.
Changes:
- Expand
clean_citations()to remove Foundry citation markers with optional spacing/casing. - Add buffering logic in
streaming_agent_response_callback()to prevent split citation markers from leaking across streamed chunks, plus explicit buffer clearing hooks from the orchestration manager. - Add/adjust tests to validate Foundry citation cleaning and split-chunk streaming behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/backend/callbacks/response_handlers.py | Adds streaming citation buffer management and expands citation-cleaning regex to handle Foundry markers. |
| src/backend/orchestration/orchestration_manager.py | Clears streaming citation buffers at orchestration boundaries and cleans manager final output citations. |
| src/tests/backend/callbacks/test_response_handlers.py | Adds coverage for Foundry citation formats and split-across-chunks streaming cleanup. |
| src/tests/backend/orchestration/test_orchestration_manager.py | Mocks new callback exports and adds a test ensuring manager final output is citation-cleaned. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… and add unit tests for citation handling
Roopan-Microsoft
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR fixed citation marker which was appending in agent response.
Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information