Skip to content

Conversation

@steven10a
Copy link
Collaborator

  • Updating examples to follow best practice of not appending messages until guardrails run
  • Added this guidance to the quickstart

Copilot AI review requested due to automatic review settings October 22, 2025 14:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates conversation history management in examples to follow best practices by only appending messages after guardrails validation succeeds, preventing blocked messages from polluting conversation context.

Key changes:

  • Modified examples to pass user input inline without mutating conversation history first
  • Added messages to history only after successful guardrail validation
  • Added explicit documentation in quickstart explaining this pattern

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
examples/basic/multiturn_with_prompt_injection_detection.ts Refactored to defer adding user/assistant/tool messages to history until after guardrails pass
examples/basic/local_model.ts Updated to append conversation history only after successful guardrail validation
examples/basic/azure_example.ts Modified to maintain conversation history and only update after guardrails pass
examples/basic/agents_sdk.ts Changed to update thread history only after successful agent execution
docs/quickstart.md Added new section explaining multi-turn conversation best practices with guardrails

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@gabor-openai gabor-openai left a comment

Choose a reason for hiding this comment

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

TY!

@gabor-openai gabor-openai merged commit d934a65 into main Oct 22, 2025
1 check passed
@steven10a steven10a deleted the dev/steven/update_convo_history_examples branch October 30, 2025 21:08
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.

3 participants