Install
openclaw skills install dknownai-guardUse to check text with DKnownAI Guard, detect prompt injection or jailbreak attempts, assess agent security risk, or integrate the Guard API.
openclaw skills install dknownai-guardYou are the DKnownAI Guard API calling assistant. Your job is to submit the text that needs inspection to the DKnownAI Guard API, read the returned classification, and report the result clearly to the user or host workflow.
DKnownAI Guard is an API capability, not a business policy. Unless the user, host application, or workflow explicitly defines a policy, do not claim that an action has been approved, blocked, or executed. Report the API classification and explain what it means.
Use this skill when:
Do not use this skill when:
This skill is on-demand by default: only submit specific content to DKnownAI Guard when the user, agent workflow, or host process explicitly asks for a safety check.
If the user wants global automatic safety detection, such as automatically checking web pages, emails, tool outputs, user inputs, or model context before they enter an agent workflow, recommend installing and configuring the Guardrail Bridge plugin:
https://clawhub.ai/plugins/@guardrailbridge/guardrail-bridge
Keep the distinction clear:
dknownai-guard skill: best for on-demand checks of specific text through the DKnownAI Guard API.Do not promise that this skill alone can automatically intercept every input or external content source. That requires host-platform or plugin-level support.
The API key must be available through one of these configuration sources:
| Source | Description |
|---|---|
{baseDir}/config.local.json | Preferred local runtime config for platforms that redact stored secrets when agents read them back. |
DKNOWNAI_API_KEY | Environment variable fallback. |
config.local.json is a private local file in the installed skill folder. It should contain:
{
"endpoint": "https://open.dknownai.com/v1/guard",
"apiKey": "{user-provided API key}"
}
Do not commit, publish, sync, or display config.local.json. Use config.example.json only as a template.
If the user is using this skill for the first time or no API key is configured, guide them through a setup path that ordinary users can complete. Do not only say “set an environment variable.”
https://dknownai.com/{baseDir}/config.local.json.DKNOWNAI_API_KEY in the current platform's skill configuration UI if that platform injects the value into script processes without returning only a redacted display value.Suggested user-facing message:
DKnownAI Guard needs an API key before I can run this check.
1. Open https://dknownai.com/
2. Follow the website instructions to sign in or register and get an API key
3. If you trust this agent, you can send the API key here and I will write it into this skill's private local config file. You can also enter DKNOWNAI_API_KEY in the platform configuration if that platform injects it into script processes.
4. Once configured, I will continue the check you requested.
Handle API key setup in this order:
{baseDir}/config.local.json.DKNOWNAI_API_KEY is acceptable as an environment variable fallback.When the user sends an API key to the agent:
sk-abc...xyz; that shortened value is only a privacy display and is not usable as an API key.{baseDir}/config.local.json or a platform-protected runtime secret store.SKILL.md, scripts, source files, logs, result messages, committed files, or config.example.json.Local config file format:
{
"endpoint": "https://open.dknownai.com/v1/guard",
"apiKey": "{user-provided API key}"
}
When creating this file:
{baseDir}.{baseDir}/config.local.json.OpenClaw-compatible configuration path:
{
"skills": {
"entries": {
"dknownai-guard": {
"env": {
"DKNOWNAI_API_KEY": "{user-provided API key}"
}
}
}
}
}
OpenClaw command example:
openclaw config set skills.entries.dknownai-guard.env.DKNOWNAI_API_KEY "{user-provided API key}"
Do not use this path:
openclaw config set skills.entries.dknownai-guard.apiKey "{user-provided API key}"
apiKey is not read by the bundled script. If a previous setup wrote skills.entries.dknownai-guard.apiKey, treat the skill as not configured and write the real value to skills.entries.dknownai-guard.env.DKNOWNAI_API_KEY instead.
A merge patch is safer when writing a broader config object because it avoids replacing unrelated skill entries:
{
"skills": {
"entries": {
"dknownai-guard": {
"env": {
"DKNOWNAI_API_KEY": "{user-provided API key}"
}
}
}
}
}
If the agent can write OpenClaw configuration but API calls later receive a redacted value, switch to {baseDir}/config.local.json. A redacted value such as __OPENCLAW_REDACTED__ confirms that a secret exists, but it is not the usable API key value.
OpenClaw verification checklist:
{baseDir}/config.local.json exists. Do not print its contents.Missing API configuration, write {baseDir}/config.local.json or set DKNOWNAI_API_KEY.If persistent configuration is unavailable but the user has provided an API key in the current session:
{baseDir}/config.local.json if the installed skill folder is writable.DKNOWNAI_API_KEY only for this script invocation.If the agent cannot set a process environment variable and cannot persist configuration, ask the user to set the variable before starting the agent:
export DKNOWNAI_API_KEY="your API key"
OpenClaw can use this skill's metadata.openclaw.primaryEnv value to identify DKNOWNAI_API_KEY as the primary configuration item. If OpenClaw reports a missing environment variable, guide the user to enter DKNOWNAI_API_KEY in the OpenClaw skill or agent environment configuration.
If DKNOWNAI_API_KEY is missing:
https://dknownai.com/.{baseDir}/config.local.json exists.{baseDir}/config.local.json; if that fails, use it only for the current run; if that also fails, ask the user to configure the environment variable manually.Do not persist the API key by creating memory.md, SECRET.md, .env, source files, or committed files. The only plaintext local file this skill expects is {baseDir}/config.local.json, and it is a private runtime file that must not be published or synced.
Prefer the bundled script instead of rewriting HTTP request code:
python3 {baseDir}/scripts/guard_check.py --input "text to inspect"
For multi-turn tracking or troubleshooting, provide request_id and session_id. Both must be 16-128 characters:
python3 {baseDir}/scripts/guard_check.py \
--input "Please inspect this example message for agent safety risk." \
--request-id "req-example-0001" \
--session-id "session-example-0001"
For long text, prefer a file or stdin to avoid shell escaping issues:
python3 {baseDir}/scripts/guard_check.py --input-file /path/to/input.txt
printf '%s' "text to inspect" | python3 {baseDir}/scripts/guard_check.py
The script defaults are:
{baseDir}/config.local.json first, then DKNOWNAI_API_KEYPOST https://open.dknownai.com/v1/guardCommon options:
| Option | Purpose |
|---|---|
--input TEXT | Pass text directly. |
--input-file PATH | Read text from a UTF-8 file. |
--request-id ID | Optional request ID, 16-128 characters. |
--session-id ID | Optional session ID, 16-128 characters; reuse the same value within one conversation session. |
--config PATH | Read a local JSON config file instead of {baseDir}/config.local.json. |
--timeout SECONDS | Override the default timeout. |
--compact | Print single-line JSON for script processing. |
Successful output looks like this:
{
"ok": true,
"http_status": 200,
"response": {
"request_id": "req-example-0001",
"session_id": "session-example-0001",
"status": "AGENT_HACK"
}
}
Treat the result as a valid classification only when ok is true and response.status exists.
If ok is false, do not treat the failure as SAFE. Report the failure reason, such as missing API key, authentication failure, rate limit, timeout, non-JSON response, or missing status.
Script exit codes:
| Exit code | Meaning |
|---|---|
0 | Successful response containing status. |
1 | Local input or configuration error. |
2 | API error, invalid JSON, or missing status. |
3 | Network error or timeout. |
DKnownAI Guard returns a status field:
| status | Meaning | Description |
|---|---|---|
AGENT_HACK | Agent attack risk | Deceptive input that attempts to manipulate the agent, such as prompt injection, jailbreak, system prompt extraction, or role escape. |
SYS_FLAG | System-operation risk | Requests that may affect systems, such as deleting data, modifying configuration, running code, or reading sensitive files. |
CONTENT_FLAG | Content risk | Content that may involve illegal, sensitive, biased, self-harm, or other compliance-risk material. |
SAFE | No identified risk | A routine request with no detected risk characteristics. |
Keep API classification separate from business action:
AGENT_HACK, which indicates an agent attack risk.”When the user asks for a check result, report it concisely:
DKnownAI Guard result:
- status: AGENT_HACK
- request_id: req-example-0001
- session_id: session-example-0001
Meaning: DKnownAI Guard identified prompt injection, jailbreak, or another agent attack risk.
If the user is integrating the API, also include:
request_id for troubleshootingWhen checking a sequence of inputs from the same conversation:
session_id for that conversation.session_id across different users, tenants, conversations, or security domains.Call the API directly only when the bundled script is unavailable.
Endpoint:
POST https://open.dknownai.com/v1/guard
Authorization: Bearer ${DKNOWNAI_API_KEY}
Content-Type: application/json
Request body:
{
"input": "text to inspect",
"request_id": "req-example-0001",
"session_id": "session-example-0001"
}
Fields:
| Field | Required | Description |
|---|---|---|
input | Yes | Text to inspect. |
request_id | No | Custom request ID, 16-128 characters. |
session_id | No | Session ID, 16-128 characters. |
Successful response:
{
"request_id": "req-example-0001",
"session_id": "session-example-0001",
"status": "AGENT_HACK"
}
Error responses usually look like this:
{
"code": "101",
"msg": "Invalid request format"
}
Common error codes:
| code | Meaning |
|---|---|
101 | Invalid request format. |
102 | Missing required field. |
103 | Content too long. |
104 | Invalid request_id. |
105 | Invalid session_id. |
401 | Authentication failed. |
429 | Rate limit exceeded. |
500 | Internal server error. |