Skip to content

Commit 8a09420

Browse files
committed
Refactored shield-related documentation
1 parent 226e4ef commit 8a09420

13 files changed

Lines changed: 358 additions & 45 deletions

File tree

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -769,22 +769,29 @@ For the configuration guide, skill authoring instructions, and examples, see the
769769
770770
## Safety Shields
771771
772-
A single Llama Stack configuration file can include multiple safety shields, which are utilized in agent
773-
configurations to monitor input and/or output streams. LCS uses the following naming convention to specify how each safety shield is
774-
utilized:
772+
Safety shields used by `/query`, `/streaming_query`, `/responses`, and `/rlsapi`
773+
are **owned by Lightspeed Core Stack** and configured in `lightspeed-stack.yaml`
774+
(not via the Llama Stack / OGX Safety or Moderations APIs).
775775
776-
1. If the `shield_id` starts with `input_`, it will be used for input only.
777-
1. If the `shield_id` starts with `output_`, it will be used for output only.
778-
1. If the `shield_id` starts with `inout_`, it will be used both for input and output.
779-
1. Otherwise, it will be used for input only.
776+
Supported shield types (`provider_id`):
780777
781-
Additionally, an optional list parameter `shield_ids` can be specified in `/query` and `/streaming_query` endpoints to override which shields are applied. You can use this config to disable shield overrides:
778+
- `question_validity` — topic / off-topic classification
779+
- `redaction` — regex-based PII redaction
780+
781+
List configured shields with `GET /v1/shields`. Optionally override which
782+
shields apply with the `shield_ids` request field (`null` = all, `[]` = none,
783+
or a list of configured `identifier` values). To forbid client overrides on
784+
`/query` and `/streaming_query`:
782785
783786
```yaml
784787
customization:
785788
disable_shield_ids_override: true
786789
```
787790
791+
For configuration details, endpoint application (direct-run vs agent
792+
capabilities), and examples, see the
793+
[Safety Shields Guide](docs/user_doc/shields_guide.md).
794+
788795
## Authentication
789796
790797
See [authentication and authorization](docs/auth.md).

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ See the full documentation at [`../README.md`](../README.md) or browse sub-pages
1919

2020
[Agent skills](https://lightspeed-core.github.io/lightspeed-stack/user_doc/skills_guide.html)
2121

22+
[Safety shields](https://lightspeed-core.github.io/lightspeed-stack/user_doc/shields_guide.html)
23+
2224
[A2A [Agent-to-Agent] Protocol](https://lightspeed-core.github.io/lightspeed-stack/user_doc/a2a_protocol.html)
2325

2426
[RAG configuration guide](https://lightspeed-core.github.io/lightspeed-stack/user_doc/rag_guide.html)

docs/basic_info/overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
**Lightspeed Core Stack (LCore)** is an enterprise-grade middleware service that provides a robust layer between client applications and AI Large Language Model (LLM) backends. It adds essential enterprise features such as authentication, authorization, quota management, caching, and observability to LLM interactions.
88

9-
Current version of LCore is built on **Llama Stack** - open-source framework that provides standardized APIs for building LLM applications. Llama Stack offers a unified interface for models, RAG (vector stores), tools, and safety (shields) across different providers. LCore communicates with Llama Stack to orchestrate all LLM operations.
9+
Current version of LCore is built on **OGX (Llama Stack)** - open-source framework that provides standardized APIs for building LLM applications. OGX offers a unified interface for models, RAG (vector stores), and tools across different providers. LCore communicates with OGX to orchestrate all LLM operations.
1010

11-
To enhance LLM responses, LCore leverages **RAG (Retrieval-Augmented Generation)**, which retrieves relevant context from vector databases before generating answers. Llama Stack manages the vector stores, and LCore queries them to inject relevant documentation, knowledge bases, or previous conversations into the LLM prompt.
11+
To enhance LLM responses, LCore leverages **RAG (Retrieval-Augmented Generation)**, which retrieves relevant context from vector databases before generating answers. OGX manages the vector stores, and LCore queries them to inject relevant documentation, knowledge bases, or previous conversations into the LLM prompt.
12+
13+
LCore also provides **safety shields** such as topic validation and PII redaction. These are configured in LCore and applied on request endpoints before or during agent processing.
1214

1315
### Key Features
1416

docs/devel_doc/ARCHITECTURE.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424

2525
**Lightspeed Core Stack (LCORE)** is an enterprise-grade middleware service that provides a robust layer between client applications and AI Large Language Model (LLM) backends. It adds essential enterprise features such as authentication, authorization, quota management, caching, and observability to LLM interactions.
2626

27-
LCore is built on **Llama Stack** - Meta's open-source framework that provides standardized APIs for building LLM applications. Llama Stack offers a unified interface for models, RAG (vector stores), tools, and safety (shields) across different providers. LCore communicates with Llama Stack to orchestrate all LLM operations.
27+
LCore is built on **Llama Stack / OGX** - an open-source framework that provides standardized APIs for building LLM applications. It offers a unified interface for models, RAG (vector stores), and tools across different providers. LCore communicates with the stack to orchestrate all LLM operations.
2828

2929
To enhance LLM responses, LCore leverages **RAG (Retrieval-Augmented Generation)**, which retrieves relevant context from vector databases before generating answers. Llama Stack manages the vector stores, and LCore queries them to inject relevant documentation, knowledge bases, or previous conversations into the LLM prompt.
3030

31+
To keep requests on-topic and protect sensitive data, LCore applies **safety shields**, which validate user questions and redact PII from model traffic. Shields are owned by LCore and configured in the service configuration.
32+
3133
### 1.2 Key Features
3234

3335
- **Multi-Provider Support**: Works with multiple LLM providers (Ollama, OpenAI, Watsonx, etc.)
@@ -61,6 +63,7 @@ To enhance LLM responses, LCore leverages **RAG (Retrieval-Augmented Generation)
6163
│ ┌───────────────────────────────────────────────────┐ │
6264
│ │ Request Processing │ │
6365
│ │ • LLM Orchestration (via Llama Stack) │ │
66+
│ │ • Safety Shields │ │
6467
│ │ • Tool Integration (MCP servers) │ │
6568
│ │ • RAG & Context Management │ │
6669
│ └───────────────────────────────────────────────────┘ │
@@ -79,8 +82,8 @@ To enhance LLM responses, LCore leverages **RAG (Retrieval-Augmented Generation)
7982
│ │
8083
│ • Models & LLMs │
8184
│ • RAG Stores │
82-
│ • Shields │
83-
└────────┬─────────┘
85+
└──────────────────┘
86+
8487
│ (manages & invokes)
8588
8689
┌──────────────────┐
@@ -229,7 +232,6 @@ The system defines 30+ actions that can be authorized. Examples (see `docs/auth.
229232
- **Models**: List available LLM models
230233
- **Responses**: Generate LLM responses (OpenAI-compatible)
231234
- **Conversations**: Manage conversation history
232-
- **Shields**: List and apply guardrails (content filtering, safety checks)
233235
- **Vector Stores**: Access RAG databases for context injection
234236
- **Toolgroups**: Register MCP servers as tools
235237

@@ -394,11 +396,12 @@ Here's how a real query flows through the system:
394396
4. **Quota Check** - User has 50,000 tokens available ✅
395397
5. **Model Selection** - Use configured default model (e.g., `meta-llama/Llama-3.1-8B-Instruct`)
396398
6. **Context Building** - Retrieve conversation history, query RAG vector stores for relevant docs, determine available MCP tools
397-
7. **Llama Stack Call** - Send complete request with system prompt, RAG context, MCP tools, and shields
398-
8. **LLM Processing** - Llama Stack generates response, may invoke MCP tools, returns token counts
399-
9. **Post-Processing** - Apply shields, generate conversation summary if new
400-
10. **Store Results** - Save to Cache DB, User DB, consume quota, update metrics
401-
11. **Return Response** - Complete LLM response with referenced documents, token usage, and remaining quota
399+
7. **Shield moderation** - LCore-owned direct-run moderation (and agent capabilities where applicable) using shields configured in LCORE config
400+
8. **Llama Stack / agent call** - Send request with system prompt, RAG context, and MCP tools
401+
9. **LLM Processing** - Stack / agent generates response, may invoke MCP tools, returns token counts
402+
10. **Post-Processing** - Generate conversation summary if new
403+
11. **Store Results** - Save to Cache DB, User DB, consume quota, update metrics
404+
12. **Return Response** - Complete LLM response with referenced documents, token usage, and remaining quota
402405

403406
**Key Takeaways:**
404407
- RAG enhances responses with relevant documentation
@@ -497,8 +500,8 @@ This section documents the REST API endpoints exposed by LCore for client intera
497500
- `GET /v1/mcp-servers` - List all registered MCP servers (static and dynamic)
498501
- `DELETE /v1/mcp-servers/{name}` - Unregister a dynamically registered MCP server
499502

500-
**List Shields:** `GET /shields`
501-
- Returns available guardrails
503+
**List Shields:** `GET /v1/shields`
504+
- Returns list of shields configured in LCORE
502505

503506
**List RAG Databases:** `GET /rags`
504507
- Returns configured vector stores

docs/devel_doc/providers.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,12 @@ make run CONFIG=examples/lightspeed-stack-azure-entraid-service.yaml
198198

199199
## Safety Providers
200200

201-
| Name | Type | Pip Dependencies | Supported in LCS |
202-
|--------------|--------|--------------------------------------------------------------------------------------|:----------------:|
203-
| code-scanner | inline | `codeshield` | ❌ |
204-
| llama-guard | inline | — | ❌ |
205-
| prompt-guard | inline | `transformers[accelerate]`, `torch --index-url https://download.pytorch.org/whl/cpu` | ❌ |
206-
| bedrock | remote | `boto3` | ❌ |
207-
| nvidia | remote | `requests` | ❌ |
208-
| sambanova | remote | `litellm`, `requests` | ❌ |
201+
Shields are owned by LCORE (configured under `shields:` block), not as OGX `providers.safety` entries.
202+
203+
| Name | Type | Pip Dependencies | Supported in LCS |
204+
|--------------------|-------|------------------|:----------------:|
205+
| question_validity | lcore | — | ✅ |
206+
| redaction | lcore | — | ✅ |
209207

210208
---
211209

@@ -342,7 +340,6 @@ make run CONFIG=examples/lightspeed-stack-azure-entraid-service.yaml
342340
Some of APIs are associated with a set of **Resources**. Here is the mapping of APIs to resources:
343341

344342
- **Inference**, **Eval** and **Post Training** are associated with **Model** resources.
345-
- **Safety** is associated with **Shield** resources.
346343
- **Tool Runtime** is associated with **ToolGroup** resources.
347344
- **DatasetIO** is associated with **Dataset** resources.
348345
- **VectorIO** is associated with **VectorDB** resources.
@@ -359,9 +356,6 @@ make run CONFIG=examples/lightspeed-stack-azure-entraid-service.yaml
359356
provider_id: openai
360357
model_type: llm
361358
provider_model_id: gpt-4-turbo # provider label
362-
363-
shields:
364-
...
365359
```
366360
**Note** It is necessary for llama-stack to know which resources to use for a given provider. This means you need to explicitly register resources (including models) before you can use them with the associated APIs.
367361

docs/devel_doc/responses.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The following fields are LCORE-specific request extensions and are not part of t
107107
| Field | Type | Description | Required |
108108
|-------|------|-------------|----------|
109109
| `generate_topic_summary` | boolean | Generate topic summary for new conversations. Default: true | No |
110-
| `shield_ids` | array[string] | Shield IDs to apply. If omitted, all configured shields in LCORE are used | No |
110+
| `shield_ids` | array[string] | LCORE-configured shield `name` values to apply. If omitted, all configured shields are used. Not Llama Stack Safety resource names. | No |
111111
| `solr` | object | Optional `mode` and `filters`. Legacy top-level filter-only objects are still accepted. | No |
112112

113113

@@ -600,7 +600,7 @@ In streaming mode, server-deployed MCP events (e.g. `mcp_call`, `mcp_list_tools`
600600
The API introduces extensions that are not part of the OpenResponses specification:
601601

602602
- `generate_topic_summary` (request) — When set to `true` and a new conversation is created, a topic summary is automatically generated and stored in conversation metadata.
603-
- `shield_ids` (request) — Optional list of safety shield IDs to apply. If omitted, all configured shields are used.
603+
- `shield_ids` (request) — Optional list of LCORE shield `name` values to apply. If omitted, all shields from `lightspeed-stack.yaml` are used. See the [Safety Shields Guide](../user_doc/shields_guide.md).
604604
- `solr` (request) — Object with optional `mode` (`semantic`, `hybrid`, or `lexical`) and `filters` (Solr vector_io provider payload). Legacy filter-only objects (no `mode`/`filters` wrapper) still work.
605605
- `available_quotas` (response) — Provides real-time quota information from all configured quota limiters.
606606

docs/models/requests.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ Attributes:
832832
generate_topic_summary: Whether to generate topic summary for new conversations.
833833
media_type: The optional media type for response format (application/json or text/plain).
834834
vector_store_ids: The optional list of specific vector store IDs to query for RAG.
835-
shield_ids: The optional list of safety shield IDs to apply.
835+
shield_ids: The optional list of configured shield names to apply.
836836
solr: Optional Solr inline RAG options (mode, filters) or legacy filter-only dict.
837837

838838

@@ -848,7 +848,7 @@ Attributes:
848848
| generate_topic_summary | boolean | Whether to generate topic summary for new conversations |
849849
| media_type | string | Media type for the response format |
850850
| vector_store_ids | array | Optional list of specific vector store IDs to query for RAG. If not provided, all available vector stores will be queried. |
851-
| shield_ids | array | Optional list of safety shield IDs to apply. If None, all configured shields are used. |
851+
| shield_ids | array | Optional list of configured shield names to apply. If None, all configured shields are used. |
852852
| solr | | Solr inline RAG config: mode (semantic, hybrid, lexical) and filters; a legacy filter-only object (e.g. fq) is still accepted. |
853853

854854

@@ -900,8 +900,8 @@ Attributes:
900900
calls, MCP tools). Defaults to all tools available to the model.
901901
generate_topic_summary: LCORE-specific flag indicating whether to generate a
902902
topic summary for new conversations. Defaults to True.
903-
shield_ids: LCORE-specific list of safety shield IDs to apply. If None, all
904-
configured shields are used.
903+
shield_ids: LCORE-specific list of configured shield names to apply.
904+
If None, all configured shields are used.
905905
solr: Optional Solr inline RAG options (mode, filters) or legacy filter-only dict.
906906

907907

docs/testing/e2e_scenarios.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@
102102
* Check if the OpenAPI endpoint works as expected
103103
* Check if info endpoint is working
104104
* Check if info endpoint reports error when llama-stack connection is not working
105-
* Check if shields endpoint is working
106-
* Check if shields endpoint reports error when llama-stack is unreachable
105+
* Check if shields endpoint is working (lists LCORE-configured shields)
107106
* Check if tools endpoint is working
108107
* Check if tools endpoint reports error when llama-stack is unreachable
109108
* Check if metrics endpoint is working

docs/testing/e2e_testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This guide describes how to run, extend, and understand the Lightspeed Core Stac
2424

2525
- **Framework**: [Behave](https://behave.readthedocs.io/) (Python BDD).
2626
- **Scope**: REST API of the Lightspeed Core Stack (query, streaming_query, models, info, health, feedback, conversations, RBAC, MCP, etc.).
27-
- **Execution**: Tests run in a **separate process** from the app. They send HTTP requests to the service and (in server mode) optionally talk to the Llama Stack service for shield setup.
27+
- **Execution**: Tests run in a **separate process** from the app. They send HTTP requests to the service. LCORE shields are configured in `lightspeed-stack.yaml` (not via Llama Stack Safety APIs).
2828
- **Environments**: Local (Docker Compose) or Prow/OpenShift (containers/pods). Mode is detected via `E2E_DEPLOYMENT_MODE` and `RUNNING_PROW`.
2929

3030
---
@@ -206,8 +206,8 @@ You can put several tags on one scenario. To document why a scenario is skipped,
206206

207207
- **before_all**: Sets `deployment_mode`, `is_library_mode`, detects or overrides `default_model` / `default_provider`, sets `faiss_vector_store_id`.
208208
- **before_feature**: Applies feature-level config and restarts container for `Authorized`, `RBAC`, `RHIdentity`, `Feedback`, `MCP`.
209-
- **before_scenario**: Skips scenarios for `@skip`, `@local`, `@skip-in-library-mode`; applies scenario config for `InvalidFeedbackStorageConfig` / `NoCacheConfig`; for `@disable-shields` (server mode) unregisters the shield.
210-
- **after_scenario**: Restores Llama Stack if it was disrupted; restores config and restarts for scenario config tags; for `@disable-shields` re-registers the shield.
209+
- **before_scenario**: Skips scenarios for `@skip`, `@local`, `@skip-in-library-mode`; applies scenario config for `InvalidFeedbackStorageConfig` / `NoCacheConfig`.
210+
- **after_scenario**: Restores Llama Stack if it was disrupted; restores config and restarts for scenario config tags.
211211
- **after_feature**: Restores config and restarts for `Authorized`, `RBAC`, `RHIdentity`, `MCP`; deletes feedback conversations for `Feedback`.
212212

213213
---

docs/user_doc/a2a_protocol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The A2A protocol is an open standard for agent-to-agent communication that allow
4343
│ ┌──────────────────────────────────────────────────────────┐ │
4444
│ │ Llama Stack Client │ │
4545
│ │ - Responses API (streaming responses) │ │
46-
│ │ - Tools, Shields, RAG integration │ │
46+
│ │ - Tools, RAG integration │ │
4747
│ └──────────────────────────────────────────────────────────┘ │
4848
└─────────────────────────────────────────────────────────────────┘
4949
```

0 commit comments

Comments
 (0)