Text Generation
Transformers
Safetensors
English
qwen3
agent-safety
tool-use
guard-model
step-level-safety
conversational
text-generation-inference
Instructions to use ninty-seven/StepGuard with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ninty-seven/StepGuard with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ninty-seven/StepGuard") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ninty-seven/StepGuard") model = AutoModelForCausalLM.from_pretrained("ninty-seven/StepGuard", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ninty-seven/StepGuard with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ninty-seven/StepGuard" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ninty-seven/StepGuard", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ninty-seven/StepGuard
- SGLang
How to use ninty-seven/StepGuard with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ninty-seven/StepGuard" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ninty-seven/StepGuard", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ninty-seven/StepGuard" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ninty-seven/StepGuard", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ninty-seven/StepGuard with Docker Model Runner:
docker model run hf.co/ninty-seven/StepGuard
Add model card
Browse files
README.md
CHANGED
|
@@ -31,6 +31,76 @@ Use the prompt templates released with the AgentGuard codebase:
|
|
| 31 |
- `agentguard_finnal_lite_traj` for trajectory-level inputs. It receives the
|
| 32 |
user request, available tools, and the complete action-observation trajectory.
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
### `agentguard_finnal_lite` (action level)
|
| 35 |
|
| 36 |
```text
|
|
|
|
| 31 |
- `agentguard_finnal_lite_traj` for trajectory-level inputs. It receives the
|
| 32 |
user request, available tools, and the complete action-observation trajectory.
|
| 33 |
|
| 34 |
+
## Exact Input Contract
|
| 35 |
+
|
| 36 |
+
The placeholders in the templates below are not free-form field names. Render
|
| 37 |
+
them as follows so that inference matches the released evaluation setup.
|
| 38 |
+
|
| 39 |
+
### Action-Level Input
|
| 40 |
+
|
| 41 |
+
- `{user_request}`: the original user request, copied verbatim.
|
| 42 |
+
- `{history_text}`: all *prior* agent actions and environment observations.
|
| 43 |
+
When there is no history, use `(no prior history)`. Actions and observations
|
| 44 |
+
are rendered in this form:
|
| 45 |
+
|
| 46 |
+
```text
|
| 47 |
+
=== System/Profile ===
|
| 48 |
+
optional system or agent profile
|
| 49 |
+
|
| 50 |
+
[Step 1] [AGENT]:
|
| 51 |
+
[THOUGHT]: optional private reasoning
|
| 52 |
+
[ACTION]: {"name": "tool_name", "arguments": {...}}
|
| 53 |
+
|
| 54 |
+
[Observation after Step 1] [ENVIRONMENT]: tool response
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
- `{current_action_text}`: the action currently being judged, rendered as
|
| 58 |
+
`[Step N] [AGENT]:` followed by an optional `[THOUGHT]: ...` line and an
|
| 59 |
+
`[ACTION]: ...` line. A tool call uses JSON with exactly `name` and
|
| 60 |
+
`arguments` keys.
|
| 61 |
+
- `{tool_list_text}`: one line per available tool, formatted as
|
| 62 |
+
`- tool_name: first line of the tool description`.
|
| 63 |
+
|
| 64 |
+
Only the action under review receives the action-level judgment; prior actions
|
| 65 |
+
are context, not independent targets.
|
| 66 |
+
|
| 67 |
+
### Trajectory-Level Input
|
| 68 |
+
|
| 69 |
+
- `{user_request}` and `{tool_list_text}` use the same representation as
|
| 70 |
+
above.
|
| 71 |
+
- `{trajectory}` includes the original user request, every prior agent action
|
| 72 |
+
and observation, and the final action being judged. Each agent action has a
|
| 73 |
+
numeric `[Step N]` identifier; environment feedback is attached as
|
| 74 |
+
`[Observation after Step N]`. The reported `UnsafeStep` must be an agent
|
| 75 |
+
action step identifier from this serialization, not an observation or user
|
| 76 |
+
turn.
|
| 77 |
+
|
| 78 |
+
### Required Output Schema
|
| 79 |
+
|
| 80 |
+
Return the tags exactly once and do not emit Markdown, JSON, or additional
|
| 81 |
+
prose outside the tags. `RiskSourcePresent` is `yes` when a relevant risk source
|
| 82 |
+
exists even if the agent handled it safely; use `none` only when no relevant
|
| 83 |
+
risk source is present. For a safe trajectory, `UnsafeStep` must be `None`.
|
| 84 |
+
|
| 85 |
+
Action-level output:
|
| 86 |
+
|
| 87 |
+
```text
|
| 88 |
+
<Analysis>4-7 sentences covering evidence, intent, consequence, and decision</Analysis>
|
| 89 |
+
<Judgment>safe or unsafe</Judgment>
|
| 90 |
+
<RiskSourcePresent>yes or no</RiskSourcePresent>
|
| 91 |
+
<RiskSource>one allowed label</RiskSource>
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Trajectory-level output:
|
| 95 |
+
|
| 96 |
+
```text
|
| 97 |
+
<Analysis>4-8 sentences covering evidence, intent, consequence, decision, and step</Analysis>
|
| 98 |
+
<Judgment>safe or unsafe</Judgment>
|
| 99 |
+
<RiskSourcePresent>yes or no</RiskSourcePresent>
|
| 100 |
+
<RiskSource>one allowed label</RiskSource>
|
| 101 |
+
<UnsafeStep>None or one integer agent-action step id</UnsafeStep>
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
### `agentguard_finnal_lite` (action level)
|
| 105 |
|
| 106 |
```text
|