bash scripts/clean.sh # optional: remove generated results and clear assets/policy.rego
cd examples/hr-agentMake sure the .env in the Smith skill directory points to this example:
# --- the target agent (the HR agent's Smith shim) ---
AGENT_URL=http://localhost:9000
# --- point Smith at this example ---
TARGET_AGENT_PATH=examples/hr-agent/
GUIDANCE_FILE=examples/hr-agent/smith/guidance.txt
SYSTEM_VAR_FILE=examples/hr-agent/smith/system_vars.json
PROMPTFOO_CONFIG_FILE=examples/hr-agent/smith/promptfooconfig.yaml
PROMPTFOO_OUTPUT_FILE=examples/hr-agent/smith/redteam.yaml
# --- MCP transport ---
MCP_TRANSPORT=http
MCP_URL=http://localhost:9000/tool_definitions
# ---Inference model ---
INFERENCE_MODEL=aws/claude-haiku-4-5
INFERENCE_BASE_URL=${OPENAI_BASE_URL}
INFERENCE_API_KEY=${OPENAI_API_KEY}
Start the MCP server (separate terminal):
uvicorn server:app --host 0.0.0.0 --port 9100Start the agent (separate terminal):
uvicorn agent:app --host 0.0.0.0 --port 9000| File | Description |
|---|---|
guidance_raw.txt |
Source guidance to upload to the Guidance Classifier. |
guidance.txt |
Active guidance saved by the classifier and used for policy generation. |
system_vars.json |
Session roles, permissions, approval state, and action descriptions. Subject values map to input.extensions.subject.* in the OPA policy. |
tool_definitions.json |
Tool definitions and parameters for the current Smith session; parameters map to input.arguments.*. |
promptfooconfig.yaml |
Promptfoo configuration for red-team test generation. |
redteam.yaml |
Saved Promptfoo red-team output. |
smith_outputs/ |
Saved outputs from Smith runs (see below). |
| Folder | Description |
|---|---|
get_compensation/ |
Generated and revised policies, bypass report, and allow/ and disallow/ test cases for the get_compensation run. |
all_guidance/ |
Generated and revised policies, bypass report, and allow/ and disallow/ test cases for the broader guidance run. |
From the Smith skill directory, start the Guidance Classifier:
smith --flag classify_guidanceOpen the URL printed by the command (http://127.0.0.1:8110/) in a browser
or VS Code's Simple Browser. Then:
- Upload
examples/employee/smith/guidance_raw.txt. - Click 1: Select a tool, such as
get_compensation. - Click 2: Check the guidance lines of this tool.
- Click 3: Click Combine → guidance and review the combined text.
- Click 4: Click Save Smith inputs.
Saving overwrites examples/hr-agent/smith/guidance.txt and records the selected
tools in references/session_config.json. The uploaded source file is unchanged.
Ask your coding assistant to use the Smith skill to generate an OPA policy from the guidance file:
Prompt: /smith generate an opa policy for the target agent
If Smith asks whether to limit the scope to the selected tools, confirm.
There are three ways to generate or reuse test cases:
-
After generating the policy, Smith asks whether to generate test cases or reuse existing ones. If generating cases, follow its suggestions to refresh the Promptfoo config, generate cases, and translate them. Test case evaluation is optional.
-
Generate test cases via CLI:
smith --flag generate_promptfoo_config # optional: generate and review the Promptfoo config smith --flag test_generation --mode fresh # required: generate guidance-targeted cases smith --flag bypass_case_generation # optional: policy-bypass cases (requires an existing, non-empty policy) smith --flag test_case_evaluation # optional: visualize test cases without changing results smith --flag test_case_translation # required: translate cases, skipping those already translated
-
To reuse the saved
get_compensationcases, copyexamples/hr-agent/smith/smith_outputs/get_compensation/test_cases/toreferences/test_cases/, then skip generation and translation.
Run policy testing (ask Smith or via CLI):
-
Smith: Follow Smith's suggestions and approve policy testing.
-
CLI:
smith --flag policy_testing
- If there are 0 test cases or a 100% failure rate — the policy may have structural or syntax issues. Ask Smith to cross-validate the policy (it will follow
opa_policy/policy_cross_validation/policy_cross_validation.md). - If some tests pass and others fail — some test case labels may be wrong. Ask Smith to cross-validate the test cases before running the refinement loop (it should follow
test_generation/cross_validate.md). This step can take time, depending on the number of failed test cases.
If no test cases fail, Smith skips this step.
If test cases fail, follow Smith's suggestions to patch the policy:
Fix failed test cases — patch the policy to handle cases that should be denied but are currently allowed.
Fix formatting issues — resolve Regal lint warnings and opa fmt differences.
Remove duplication — eliminate redundant rules with overlapping logic.
-
Go to the webpage opened in Step 0 and check all lines.
-
Click Combine → guidance
-
click Save Smith inputs.
Repeat Previous Step 1-3. But at this turn, you can choose update test cases rather than generate from scratch.
smith --flag test_generation --mode update