-
Notifications
You must be signed in to change notification settings - Fork 8
Agent parse conversation history #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 the GuardrailAgent to properly parse conversation history and extract the user's last message as a string, fixing an error when using the moderation endpoint (which expects string input rather than complex message structures).
Key Changes:
- Replaces
ContentUtils.extractTextFromMessagewith new custom text extraction functions that handle nested conversation structures - Adds three new helper functions to recursively extract text from various input formats (content parts, message entries, and agent inputs)
- Includes a new test case validating that conversation history is correctly parsed and the latest user message is extracted
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/agents.ts | Removes unused imports and adds new text extraction functions (extractTextFromContentParts, extractTextFromMessageEntry, extractTextFromAgentInput) to handle conversation history parsing; refactors resolveInputText to use the new extraction logic |
| src/tests/unit/agents.test.ts | Fixes indentation in existing test and adds new test case to verify conversation history parsing with multi-part user messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return record.text.trim(); | ||
| } | ||
| } | ||
|
|
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The inline comment explains the parameter but doesn't clarify when this fallback path is reached. Consider adding a brief comment above this line explaining that this is a last-resort extraction attempt for object structures that don't match standard message patterns.
| // Last-resort extraction: if entry does not match standard message patterns, | |
| // attempt to extract text from any value type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
gabor-openai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY
Update Agents to properly parse the conversation history for the user's last message