Skip to content

refactor!: remove Safety/Shields API and all connected code#5291

Draft
leseb wants to merge 9 commits intollamastack:mainfrom
leseb:remove-safety-api
Draft

refactor!: remove Safety/Shields API and all connected code#5291
leseb wants to merge 9 commits intollamastack:mainfrom
leseb:remove-safety-api

Conversation

@leseb
Copy link
Copy Markdown
Collaborator

@leseb leseb commented Mar 25, 2026

Summary

Remove the Safety/Shields API and all connected code. Shields are already marked deprecated in the spec. Safety enforcement is better handled at the platform level (guardrails orchestrators, NeMo Guardrails).

What was removed

  • Safety and Shields API packages
  • All safety providers (llama-guard, prompt-guard, code-scanner, bedrock, nvidia, sambanova, passthrough)
  • Guardrail execution code from the agent/responses loop
  • All distribution config references
  • All integration and unit tests

Stats

  • 149 files changed, -10,642 lines net
  • 226 unit tests pass

Test plan

  • Unit tests pass
  • CI

Signed-off-by: Sebastien Han shan@redhat.com

Remove the deprecated Safety and Shields APIs entirely from llama-stack.
This includes:

- API packages (llama_stack_api/safety/, llama_stack_api/shields/)
- Provider implementations (inline: llama-guard, prompt-guard, code-scanner;
  remote: bedrock, nvidia, sambanova, passthrough)
- Provider registry (providers/registry/safety.py)
- Router and routing table (core/routers/safety.py, core/routing_tables/shields.py)
- Api enum values (Api.safety, Api.shields)
- SafetyConfig, ShieldWithOwner, ShieldsProtocolPrivate from core datatypes
- Distribution YAML configs (safety providers, shields registered resources,
  safety config sections, run-with-safety.yaml files)
- Distribution template code (get_shield_registry, default_shields, safety_config)
- Agent/responses guardrail execution code (run_guardrails, extract_guardrail_ids,
  safety_api parameter threading, input/output guardrail checks in streaming)
- Telemetry helpers and constants for safety
- All safety-related unit and integration tests
- ShieldToModerationMixin utility

The guardrails parameter in create_openai_response is preserved in the
signature but is now a no-op. The Responses API continues to work without
safety.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 25, 2026
@leseb leseb added this to the 0.8.0 milestone Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

✱ Stainless preview builds

This PR will update the llama-stack-client SDKs with the following commit message.

refactor!: remove Safety/Shields API and all connected code

Edit this comment to update it. It will appear in the SDK's changelogs.

llama-stack-client-node studio · conflict

Your SDK build had at least one new note diagnostic, which is a regression from the base state.

New diagnostics (6 note)
💡 Model/Recommended: `#/components/schemas/ChatCompletionMessageToolCall` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat`.
💡 Model/Recommended: `#/components/schemas/OpenAIFile` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIFileFile` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAISystemMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIToolMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIDeveloperMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
llama-stack-client-go studio · conflict

Your SDK build resulted in a merge conflict between your custom code and the newly generated changes, but this did not represent a regression.

llama-stack-client-openapi studio · code · diff

Your SDK build had at least one "warning" diagnostic, but this did not represent a regression.
generate ⚠️

New diagnostics (6 note)
💡 Model/Recommended: `#/components/schemas/ChatCompletionMessageToolCall` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat`.
💡 Model/Recommended: `#/components/schemas/OpenAIFile` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIFileFile` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAISystemMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIToolMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIDeveloperMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
llama-stack-client-python studio · conflict

Your SDK build had at least one new note diagnostic, which is a regression from the base state.

New diagnostics (6 note)
💡 Model/Recommended: `#/components/schemas/ChatCompletionMessageToolCall` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat`.
💡 Model/Recommended: `#/components/schemas/OpenAIFile` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIFileFile` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAISystemMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIToolMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.
💡 Model/Recommended: `#/components/schemas/OpenAIDeveloperMessageParam` could potentially be defined as a [model](https://www.stainless.com/docs/guides/configure#models) within `#/resources/chat/subresources/completions`.

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-03-27 14:56:12 UTC

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 25, 2026

This pull request has merge conflicts that must be resolved before it can be merged. @leseb please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 25, 2026
Signed-off-by: Sébastien Han <seb@redhat.com>
@mergify mergify bot removed the needs-rebase label Mar 25, 2026
leseb and others added 3 commits March 25, 2026 18:09
Signed-off-by: Sébastien Han <seb@redhat.com>
Resolve merge conflicts from upstream/main, primarily around the
agents-to-responses API rename (PR llamastack#5195) and new upstream changes.
The key resolutions were updating Api.agents to Api.responses in
datatypes.py and resolver.py, removing reintroduced safety/shields
references from OCI and WatsonX distributions, fixing the stainless
config to remove safety/shields/moderations endpoints, and
regenerating all OpenAPI specs, distribution configs, and coverage
documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
Merge upstream/main into remove-safety-api, resolving conflicts by
keeping the safety API removal from this branch. All modify/delete
conflicts for safety-related files (shields, safety providers, safety
router, safety registry) were resolved by accepting the deletion.
Content conflicts in core/datatypes.py, core/stack.py,
distributions/template.py, and llama_stack_api/datatypes.py were
resolved by removing the safety-related code (ShieldWithOwner,
ShieldsProtocolPrivate, validate_safety_config, get_shield_registry)
that upstream had modified but this branch intentionally removes.

Signed-off-by: Sébastien Han <seb@redhat.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 26, 2026

This pull request has merge conflicts that must be resolved before it can be merged. @leseb please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 26, 2026
leseb and others added 2 commits March 26, 2026 21:23
Accept upstream's updated OpenAI API conformance data including the new
Moderations category and updated summary statistics (28/146 endpoints,
87.8% conformance score). These are auto-generated documentation files
tracking OpenAI API coverage which are unrelated to the Llama Stack
Safety/Shields API removal in this branch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
The pre-commit hook regenerated conformance data to reflect the actual
endpoints available in this branch (27/146 endpoints, 89.0% conformance
score) since the Moderations endpoint is not present after the Safety
API removal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
@mergify mergify bot removed the needs-rebase label Mar 26, 2026
leseb added a commit to leseb/llama-stack that referenced this pull request Mar 27, 2026
- Add "agentic" to tagline per franciscojavierarceo suggestion
- Remove Safety/Moderations (being removed in llamastack#5291)
- Use uv instead of pip in install instructions
- Remove Swift and Kotlin from SDK table
- Fix "semantic search" to just "search" for vector stores
- Mention non-OpenAI APIs (Prompts, File Processors)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
leseb and others added 2 commits March 27, 2026 11:53
Resolve modify/delete conflicts for dell distribution files that were
deleted upstream. Accept the upstream deletion since the dell distribution
was removed in main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant