Repository navigation
FEAT: Add an Agent pane to Co-PyRIT - #4838
Open
Adrian Gavrila (adrian-gavrila) wants to merge 43 commits into
Open
Adrian Gavrila (adrian-gavrila) wants to merge 43 commits into
Adrian Gavrila (adrian-gavrila) wants to merge 43 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The persistence and credential-forwarded execution changes need maintainer validation because SQL Server migration/runtime behavior and agent execution in the production Docker image remain unverified.
No open issues 🎉
What changed in this PR
Adds an Agent pane to Co-PyRIT for discussing attacks and scans, querying data, and starting scans through registered targets and the existing REST API.
Changes:
- Adds a responsive conversation pane with History, page sharing, lookup summaries, and in-app links.
- Adds separate conversation storage, agent API types, target eligibility checks, and lifecycle integration.
- Builds on #4825’s supported
TargetSendContexthook, with supporting tests and documentation.
| File | Description |
|---|---|
tests/unit/prompt_target/target/test_request_tracing.py |
Uses the public context export. |
tests/unit/prompt_target/target/test_prompt_target.py |
Tests caller-owned history without persistence. |
tests/unit/models/test_agent_conversation.py |
Tests conversation validation and turn outcomes. |
tests/unit/mocks.py |
Adds a reusable agent target mock. |
tests/unit/memory/test_agent_conversation_migration.py |
Checks migration behavior and SQL Server column bounds. |
tests/unit/memory/memory_interface/test_interface_agent_conversations.py |
Tests isolated storage, ordering, and pagination. |
tests/unit/backend/test_runtime_lifecycle.py |
Tests active-turn reinitialization protection. |
tests/unit/backend/test_api_routes.py |
Tests agent operator labels. |
tests/unit/backend/test_agent_tools.py |
Tests tool attribution and recording. |
tests/unit/backend/test_agent_targets.py |
Tests eligibility and target-copy isolation. |
tests/unit/backend/mocks.py |
Adds a REST toolset mock. |
tests/unit/backend/conftest.py |
Adds isolated agent fixtures. |
pyrit/prompt_target/common/target_send_context.py |
Documents the supported send-context contract. |
pyrit/prompt_target/common/prompt_target.py |
Updates send-context documentation. |
pyrit/prompt_target/__init__.py |
Publicly exports TargetSendContext. |
pyrit/prompt_normalizer/prompt_normalizer.py |
Uses and documents the public context. |
pyrit/prompt_normalizer/normalizer_request.py |
Uses the public context import. |
pyrit/models/agent_conversation.py |
Defines conversations and turn-end records. |
pyrit/models/__init__.py |
Exports agent models. |
pyrit/memory/memory_models.py |
Adds separate agent storage models. |
pyrit/memory/alembic/versions/ffd3cf3adbd9_add_agent_conversations.py |
Creates agent tables and indexes. |
pyrit/backend/services/service_lifecycle.py |
Integrates agent shutdown and activity checks. |
pyrit/backend/services/runtime_lifecycle.py |
Blocks reinitialization during agent turns. |
pyrit/backend/services/message_send_service.py |
Uses the public context import. |
pyrit/backend/services/agent_tools.py |
Wraps REST tools with caller attribution and recording. |
pyrit/backend/services/agent_targets.py |
Checks eligibility and configures target copies. |
pyrit/backend/routes/labels.py |
Exposes agent conversation operators. |
pyrit/backend/routes/attacks.py |
Reuses the signed-in alias helper. |
pyrit/backend/README.md |
Documents agent endpoints and lifecycle. |
pyrit/backend/models/agent.py |
Defines agent API request and response types. |
pyrit/backend/middleware/auth.py |
Extracts the shared user-alias helper. |
pyrit/backend/main.py |
Registers agent routes. |
frontend/src/utils/userPreferences.ts |
Validates and restores pane preferences. |
frontend/src/utils/agentPaneWidth.ts |
Defines responsive pane width bounds. |
frontend/src/utils/agentPaneWidth.test.ts |
Tests pane width bounds. |
frontend/src/utils/agentAppLink.ts |
Restricts same-tab reply navigation. |
frontend/src/utils/agentAppLink.test.ts |
Tests accepted and rejected links. |
frontend/src/types/index.ts |
Adds agent UI and API types. |
frontend/src/test-utils/layout.ts |
Adds responsive-layout test helpers. |
frontend/src/test-utils/agentFixtures.ts |
Adds conversation and preference fixtures. |
frontend/src/services/api.ts |
Adds agent API calls and label support. |
frontend/src/services/api.test.ts |
Tests agent request construction. |
frontend/src/hooks/useUserPreferences.test.tsx |
Tests saved pane preference handling. |
frontend/src/hooks/useMeasuredElement.ts |
Tracks element width changes. |
frontend/src/hooks/useMeasuredElement.test.ts |
Tests measurement and observer cleanup. |
frontend/src/hooks/useFollowLatest.ts |
Shares transcript-following behavior. |
frontend/src/hooks/useAgentStatus.ts |
Loads and refreshes target eligibility. |
frontend/src/hooks/useAgentStatus.test.ts |
Tests status refresh and stale responses. |
frontend/src/hooks/useAgentPane.tsx |
Manages persistent pane state and drafts. |
frontend/src/hooks/useAgentPane.test.tsx |
Tests pane persistence and minimum width. |
frontend/src/hooks/useAgentPageReference.ts |
Tracks page-sharing selection. |
frontend/src/components/Sidebar/navigationViews.tsx |
Extracts shared navigation definitions. |
frontend/src/components/Sidebar/Navigation.tsx |
Consumes shared navigation definitions. |
frontend/src/components/Registry/Registry.styles.ts |
Allows tabs to scroll beside the pane. |
frontend/src/components/Markdown/MarkdownContent.tsx |
Supports allowlisted router links. |
frontend/src/components/Markdown/MarkdownContent.test.tsx |
Tests preserved new-tab link behavior. |
frontend/src/components/Layout/MainLayout.tsx |
Adds the Agent button and drawer. |
frontend/src/components/Layout/MainLayout.styles.ts |
Styles the button and shared workspace. |
frontend/src/components/Home/Home.styles.ts |
Makes grids adapt to available space. |
frontend/src/components/helpDefinitions.ts |
Adds agent-target help text. |
frontend/src/components/ContextualHelpLabel.tsx |
Supports visually hidden labels. |
frontend/src/components/Chat/TargetBadge.tsx |
Supports registry-name display. |
frontend/src/components/Chat/MessageList.tsx |
Reuses transcript-following behavior. |
frontend/src/components/Chat/ChatWindow.styles.ts |
Constrains the conversation drawer to Chat. |
frontend/src/components/Chat/ChatTargetPicker.tsx |
Makes the picker reusable for agents. |
frontend/src/components/Chat/ChatTargetPicker.styles.ts |
Supports compact picker layout. |
frontend/src/components/Agent/PaneResizeHandle.tsx |
Adds pointer and keyboard resizing. |
frontend/src/components/Agent/PaneResizeHandle.test.tsx |
Tests resizing controls and announcements. |
frontend/src/components/Agent/PaneResizeHandle.styles.ts |
Styles the accessible resize handle. |
frontend/src/components/Agent/pageReference.ts |
Maps routes to shared page references. |
frontend/src/components/Agent/pageReference.test.ts |
Tests page-reference mapping. |
frontend/src/components/Agent/agentPaneIds.ts |
Shares pane and composer element IDs. |
frontend/src/components/Agent/AgentPaneDrawer.tsx |
Handles docking, overlays, resizing, and focus. |
frontend/src/components/Agent/AgentPaneDrawer.styles.ts |
Bounds drawer width. |
frontend/src/components/Agent/AgentPane.styles.ts |
Styles pane controls and notices. |
frontend/src/components/Agent/AgentConversationList.tsx |
Adds filtered, paginated conversation History. |
frontend/src/components/Agent/AgentConversationList.styles.ts |
Styles History and its filters. |
frontend/src/components/Agent/AgentConversation.tsx |
Renders replies, lookup summaries, and turn state. |
frontend/src/components/Agent/AgentConversation.test.tsx |
Tests transcript controls and lookup summaries. |
frontend/src/components/Agent/AgentConversation.styles.ts |
Styles the transcript and lookup details. |
frontend/src/components/Agent/AgentComposer.test.tsx |
Tests sending and page-reference chips. |
frontend/src/components/Agent/AgentComposer.styles.ts |
Styles the composer and sharing controls. |
frontend/src/App.tsx |
Integrates agent state and linked-conversation checks. |
frontend/src/App.test.tsx |
Tests pane integration and navigation. |
frontend/src/App.targets.test.tsx |
Adds agent-status mocking. |
frontend/src/App.labels.test.tsx |
Adds agent-status mocking. |
frontend/src/App.drafts.test.tsx |
Adds agent-status mocking. |
doc/gui/0_gui.md |
Documents pane usage and responsive behavior. |
doc/code/targets/11_message_normalizer.py |
Removes the context’s internal-only wording. |
doc/code/targets/11_message_normalizer.ipynb |
Mirrors the context documentation change. |
doc/code/targets/0_prompt_targets.md |
Documents supported caller-owned send history. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.
Description
Co-PyRIT gets an Agent pane: a chat that sits beside any page, where you can ask about your attacks and scans, have the agent look things up, and start a scan once you've agreed to it. The agent is one of your own registered targets, and it works through Co-PyRIT's REST API as you.
This builds on #4825, which makes
TargetSendContexta supported hook. The branch includes that commit until #4825 merges.What you can do
How it's built
AgentServicesends each turn through a copy of the chosen target, using PyRIT's own tool loop, with the turn's history supplied through aTargetSendContext. Turns run in the backend process, one at a time per conversation. Stop, a failure, the five-minute limit, and shutdown each save how the turn ended.AgentConversationEntriesandAgentMessageEntries, added by an Alembic migration. Messages are stored as PyRITMessagePieces, but apart from attack memory, so they never show up in attack history, scoring, or analytics./api/agentendpoints for status, conversations, turns, and Stop, plusGET /api/labels?source=agent_conversationsfor History's operator filter.There's no separate approval step before the agent starts a scan in this version; the go-ahead is part of the conversation.
Demo
About a minute, recorded on an isolated database with waits for replies shortened: asking about an attack, expanding the lookups, starting a small scan after confirming it, following the reply's link, History with another operator's conversation open read only, and the narrow-window overlay.
agent-pane-demo.webm