Skip to content

feat: add Netra.redteam.run_redteam() to trigger an existing red-team config - #386

Open
jithin23-kv wants to merge 5 commits into
developfrom
feat/redteam-sdk-client
Open

feat: add Netra.redteam.run_redteam() to trigger an existing red-team config#386
jithin23-kv wants to merge 5 commits into
developfrom
feat/redteam-sdk-client

Conversation

@jithin23-kv

Copy link
Copy Markdown
  • Netra.redteam.run_redteam(config_id, handler, max_concurrency=None) — fetches the run's prompt list once, drives every session's turns locally against a plain handler function, submits results, returns an aggregated RedteamResult (results/progress/risk_score/run_number)
  • Depends on the backend PR (KeyValueSoftwareSystems/combat-ai-core#1445) for the /redteam/sdk/* endpoints
  • Python port of feat: add Netra.redteam.runRedteam() to trigger an existing red-team config netra-sdk-js#134, following this repo's existing netra/simulation/ module conventions (sync httpx client, dataclass models, thread-per-session concurrency)
  • Adds netra/shutdown_hooks.py, a shared SIGINT/SIGTERM hook registry so an in-flight run is cancelled server-side on Ctrl-C — new capability, Python had no signal handling before this

625/625 tests passing (81 new). Verified against a real running backend + real Postgres (not just mocks) — full multi-turn attack loop across single-turn, multi-turn, and iterative-jailbreak evaluators, judge scoring, progress/risk_score aggregation, and cancellation via SIGINT (confirmed cancelled status + synthetic result backfill in the DB). Also cross-checked side-by-side against the JS SDK on the same config for both the completion and cancellation paths.

@jithin23-kv
jithin23-kv changed the base branch from main to develop August 28, 2026 04:16
@jithin23-kv
jithin23-kv force-pushed the feat/redteam-sdk-client branch from 1fab2e5 to 2cb78ff Compare August 28, 2026 04:32
Comment thread netra/redteam/api.py Outdated
Comment thread netra/__init__.py Outdated
Comment thread netra/redteam/__init__.py Outdated
Comment thread netra/redteam/api.py Outdated
Comment thread netra/red_team/api.py
Comment thread netra/red_team/api.py
error: Optional[str] = None
try:
message, session_id = await execute_handler(handler, prompt_text, session_id, turn_index)
output = self._truncate_output(message)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are we truncating the message here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Raised it to match the backend's actual 100k limit

Comment thread netra/redteam/client.py Outdated
Comment thread netra/redteam/api.py Outdated
Comment thread netra/red_team/api.py
)

try:
result = self._client.submit_turn(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Will the BE need the trace_id for this particular turn? We are passing it within simulation and evaluation modules.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Currently our backend does not support this. will need some changes in backend including db change. should we do it now?

jithin23-kv and others added 2 commits August 28, 2026 19:38
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

2 participants