Guardrails and verification护栏与验证
Deterministic checks on tool calls and on answers, each one written from a real failure.对工具调用和回答做确定性检查,每一条都源自一次真实的失败。
What it is and why it exists它是什么,为什么需要它
What是什么
Guardrails are code that inspects what the agent is about to do or say. Hooks check tool calls before they run. An answer guard checks the draft against the evidence gathered in this request.护栏是检查智能体即将做什么、说什么的代码。钩子在工具调用执行前做检查。回答护栏把草稿与本次请求收集到的证据进行比对。
Why为什么
Models produce fluent text whether or not it is supported. The reference agent once ran the right queries, got the right rows, and answered with an invented table. Only a check outside the model catches that.无论有没有依据,模型都能写出流畅的文字。参考智能体曾经执行了正确的查询、拿到了正确的数据,却给出了一张编造的表格。只有模型之外的检查才能发现这种情况。
How it works工作原理
- Extract the figures the draft states.提取草稿中陈述的数字。
- Collect evidence: numbers in tool results and in what the user said. The assistant's own earlier words are not evidence.收集证据:工具结果里的数字,以及用户说过的数字。助手自己之前说的话不算证据。
- A figure is grounded when it is in the evidence, or is the sum or difference of two evidence numbers.一个数字出现在证据中,或是两个证据数字的和或差,就算有依据。
- A failed draft gets one corrective message. The retry is judged by majority. If it still fails, a fixed fallback text is returned.草稿不通过时,给一次纠正提示。重试按多数规则判断。仍不通过就返回固定的兜底文本。
Where it sits in the build order它在搭建顺序中的位置
Needs first前置模块
- Harness engineeringHarness 工程The guard is a stage in the loop, after the draft and before the response. Hooks wrap tool execution. Both need the loop's plug points.护栏是循环中的一个阶段,在草稿之后、响应之前。钩子包裹工具执行。两者都需要循环提供的接入点。Build out of order不按顺序搭建 Stand in with:可用以下替代: Run the guard offline over logged answers.离线对已记录的回答运行护栏。
- Tools and MCP工具与 MCPThe guard compares the answer with tool results. Tools must return values it can parse.护栏把回答与工具结果比对。工具必须返回它能解析的值。Build out of order不按顺序搭建 Stand in with:可用以下替代: A fixed evidence string.一段固定的证据字符串。
Unlocks解锁
- Self-evolving agents自进化智能体The promotion gate is guard logic applied to stored knowledge, and it follows the same observe-first practice.晋升关卡是应用在已存储知识上的护栏逻辑,同样遵循先观察的做法。
In the reference build在参考系统中
| Path路径 | Role作用 |
|---|---|
| apps/agent-server/answer_guard.py | Figure, count, and name checks. Corrective and fallback messages. Stream gate.数字、计数和名称检查。纠正提示和兜底文本。流式输出闸门。 |
| apps/agent-server/test_answer_guard.py | Regression tests, one per rule.回归测试,每条规则一个。 |
| apps/agent-server/hooks/write_path_guard.py | Blocks writes outside an allowed folder.阻止写入允许目录之外的位置。 |
Process map流程图
What happens to a draft answer一份草稿回答会经历什么
- 1Draft草稿The model's answer, not yet shown to anyone.模型的回答,此时还没有展示给任何人。
- 2Should this turn be judged?这一轮需要判断吗?Skip when the user asked for a made-up example, or when no tools ran on a non-data turn.用户明确要求举个虚构的例子时跳过;非数据轮次且没有运行工具时也跳过。
- 3Extract figures提取数字Money amounts stated in the draft.草稿中陈述的金额。
- 4Compare with evidence与证据比对Strict on the first draft: any unsupported figure fails.对第一稿从严:只要有一个数字没有依据就不通过。
- 5Corrective retry纠正重试Name the unsupported figures and ask for a rewrite. Judge by majority.指出没有依据的数字,要求重写。按多数规则判断。
- 6Fallback兜底If the retry fails, return a plain statement with no figures.如果重试仍不通过,返回一段不含数字的说明。
Build steps搭建步骤
Follow them in order the first time. Each step names what it uses from earlier steps and what it leaves for later ones. Code is read from the lab files, and output is what the lab printed when it was run.第一次请按顺序做。每一步都写明它用到前面步骤的什么成果,又为后面的步骤留下什么。代码直接读取自 lab 文件,输出是 lab 实际运行时打印的内容。
- 1Start from logged failures从日志里的失败案例出发
- 2Write the grounding check编写依据检查
- 3Wrap the check in review(), with modes and exemptions用 review() 封装检查,加入模式和豁免
- 4Run in observe mode first先以观察模式运行
- 5Enforce: corrective retry, then fallback强制执行:先纠正重试,再兜底
- 6Add a pre-tool hook for writes为写操作加一个工具前置钩子
- 7Keep one regression test per rule每条规则保留一个回归测试
01Start from logged failures从日志里的失败案例出发
Do this操作
- Read the request log. Collect answers that stated something the tools did not return.阅读请求日志。收集那些陈述了工具未返回内容的回答。
- For each, write what kind of thing was invented: an amount, a count, a name.对每一条,写下被编造的是哪类内容:金额、数量还是名称。
- Also collect answers that correctly state numbers from nowhere: a requested example, a well-known threshold.同时收集那些数字虽无来源却完全合理的回答:用户要求的示例、众所周知的阈值。
- Guardrails and verification护栏与验证 2: Write the grounding check编写依据检查 (the kinds of figures to extract需要提取的数字类型)
- Guardrails and verification护栏与验证 7: Keep one regression test per rule每条规则保留一个回归测试 (the two case lists两份案例清单)
02Write the grounding check编写依据检查
- the kinds of figures to extract需要提取的数字类型 ← Guardrails and verification护栏与验证 1: Start from logged failures从日志里的失败案例出发
Do this操作
- `claims()` extracts money figures from the answer.`claims()` 从回答中提取金额。
- `evidence_numbers()` collects numbers from tool and user messages only.`evidence_numbers()` 只从工具消息和用户消息里收集数字。
- `grounded()` accepts a figure that is in the evidence or is a sum or difference of two evidence numbers.`grounded()` 接受出现在证据中的数字,或两个证据数字的和或差。
- `check()` is strict by default, and uses a majority rule when asked.`check()` 默认从严,按要求时使用多数规则。
def claims(answer: str) -> list:
"""Every money figure the answer states."""
return [_num(a or b) for a, b in MONEY.findall(answer)]
def evidence_numbers(messages: list) -> list:
"""Every number in tool results and in what the user said. The assistant's own
earlier words are not evidence."""
out = []
for m in messages:
if m.get("role") in ("tool", "user") and not str(m.get("content") or "").startswith("[harness]"):
out += [_num(x) for x in NUMBER.findall(str(m.get("content") or ""))]
return out
def grounded(value: float, ev: list) -> bool:
"""In the evidence as is, or the sum or difference of two evidence numbers."""
near = lambda a, b: abs(a - b) <= 0.005 * max(1.0, abs(b)) # noqa: E731
if any(near(value, e) for e in ev):
return True
small = sorted(set(ev))[:400]
return any(near(value, a + b) or near(value, abs(a - b)) for i, a in enumerate(small) for b in small[i:])
def check(answer: str, messages: list, strict: bool = True) -> dict:
ev = evidence_numbers(messages)
stated = claims(answer)
bad = [v for v in stated if not grounded(v, ev)]
ok = not bad if strict else len(bad) * 2 <= len(stated) # retry: majority rule
return {"ok": ok, "stated": stated, "unsupported": bad}python3 -m labs.m10_guard.demo1 check: PASS | stated [219.0] | unsupported []
1 check: PASS | stated [455.0, 17.0] | unsupported []
1 check: FAIL | stated [312.4] | unsupported [312.4]- Guardrails and verification护栏与验证 3: Wrap the check in review(), with modes and exemptions用 review() 封装检查,加入模式和豁免 (check()check())
- Evaluation评估 7: Evaluate the whole agent with mechanical checks用代码检查评估整个智能体 (check(), reused to grade figurescheck(),复用来给数字评分)
03Wrap the check in review(), with modes and exemptions用 review() 封装检查,加入模式和豁免
- check()check() ← Guardrails and verification护栏与验证 2: Write the grounding check编写依据检查
- the skill name, which marks a data turn技能名,用来标识数据轮次 ← Skills技能(Skills) 5: Plug the router into the harness把路由器接入 Harness
Do this操作
- Skip when the user asked for a made-up example.用户要求举虚构的例子时跳过。
- Skip when no tool ran and the turn is not a data turn. General talk may quote a threshold.没有运行工具且不是数据轮次时跳过。一般性的交谈可以引用某个阈值。
- Read a mode from the environment: enforce, observe, or off.从环境变量读取模式:enforce、observe 或 off。
- Return the verdict with a corrective message that names the figures, and a fallback text.返回裁定,并附上指出具体数字的纠正提示和兜底文本。
def review(messages: list, answer: str, skill: Optional[str] = None) -> dict:
"""What the loop calls. Returns ok, plus the corrective message and the fallback text."""
mode = os.environ.get("GUARD_MODE", "enforce") # enforce | observe | off
used_tools = any(m.get("role") == "tool" for m in messages)
data_turn = bool(skill and skill.startswith(DATA_SKILLS))
retry = any(str(m.get("content") or "").startswith("[harness] These figures") for m in messages)
verdict = check(answer, messages, strict=not retry)
reason = None
if mode == "off" or asks_for_example(messages):
verdict["ok"], reason = True, "skipped"
elif not used_tools and not data_turn:
verdict["ok"], reason = True, "not a data turn" # general knowledge may quote thresholds
elif mode == "observe":
reason, verdict["would_block"] = "observe", not verdict["ok"]
verdict["ok"] = True
figures = ", ".join(f"{v:,.2f}" for v in verdict["unsupported"])
verdict["reason"] = reason
verdict["corrective"] = (f"These figures are not in the evidence of this conversation: {figures}. "
"Rewrite the answer using only numbers the tools returned. "
"If the tools did not return a number, say so.")
verdict["fallback"] = ("I ran the lookups but could not produce an answer whose figures all match the tool results. "
"Please ask again or narrow the question.")
return verdict4 requested example passes: True
5 no tools, general talk : not a data turn- Guardrails and verification护栏与验证 4: Run in observe mode first先以观察模式运行 (the mode switch模式开关)
- Guardrails and verification护栏与验证 7: Keep one regression test per rule每条规则保留一个回归测试 (the functions under test被测试的函数)
04Run in observe mode first先以观察模式运行
Do this操作
- Set the mode to observe and attach the guard to the agent.把模式设为 observe,并把护栏接到智能体上。
- Let it log would-block decisions for a period.让它在一段时间内记录“本应拦截”的决定。
- Read each one. Add an exemption for every legitimate case.逐条查看。为每个合理的情况添加豁免。
3 observe mode : would_block = True -> answer left alone: B. Chen paid 312.40 dollars for lodging, ...- Guardrails and verification护栏与验证 5: Enforce: corrective retry, then fallback强制执行:先纠正重试,再兜底 (confidence in the exemptions对豁免规则的信心)
- Multi-agent patterns多智能体模式 6: Calibrate the judges before they remove anything在裁判移除任何内容之前先校准 (the observe-first practice先观察再执行的做法)
05Enforce: corrective retry, then fallback强制执行:先纠正重试,再兜底
- confidence in the exemptions对豁免规则的信心 ← Guardrails and verification护栏与验证 4: Run in observe mode first先以观察模式运行
- the guard plug point and retry path护栏接入点和重试路径 ← Harness engineeringHarness 工程 7: Assemble run(): guard, retry, log, record组装 run():护栏、重试、日志、记录
Do this操作
- Pass `review` as the `guard` argument of the agent.把 `review` 作为智能体的 `guard` 参数传入。
- Run three models: honest, one that invents a figure once, one that keeps inventing.运行三种模型:诚实的、编造一次数字的、持续编造的。
- Read the three outcomes: pass, corrected on retry, fallback.看三种结果:通过、重试后被纠正、兜底。
from labs.m10_guard.guard import review
agent = Agent(registry, skills=router.match, guard=review)2 honest model : retried=False fallback=False -> The lodging cap is 220 dollars per night (policy NW-FIN-012, Section 3). B. Chen paid 21
2 fabricates once: retried=True fallback=False -> The lodging cap is 220 dollars per night (policy NW-FIN-012, Section 3). B. Chen paid 21
2 keeps inventing: retried=True fallback=True -> I ran the lookups but could not produce an answer whose figures all match the tool resul- Harness engineeringHarness 工程 9: Add streaming last最后再加流式输出 (the guard, which decides when tokens may be released护栏,由它决定何时可以放出 token)
06Add a pre-tool hook for writes为写操作加一个工具前置钩子
- the hook list钩子列表 ← Harness engineeringHarness 工程 6: Add hooks before tool execution在工具执行前加入钩子
Do this操作
- Resolve the target path, so `..` and symlinks are followed before the test.先解析目标路径,让 `..` 和符号链接在判断之前就被展开。
- Block when the resolved path is outside the allowed folder.解析后的路径在允许目录之外时,阻止操作。
- Return nothing for tools that do not write.对不执行写操作的工具,什么都不返回。
def write_path_guard(allowed_root: Path):
"""Build a hook that limits file writes to one folder. Return a reason to block, or None."""
root = allowed_root.resolve()
def hook(name: str, args: dict) -> Optional[str]:
if name not in WRITE_TOOLS:
return None
target = (root / str(args.get("path", ""))).resolve() # resolves ../ tricks and symlinks
if root != target and root not in target.parents:
return f"writes are limited to {root.name}/"
return None
return hook6 write notes/summary.md -> allowed
6 write ../../etc/passwd -> writes are limited to m10/
6 write /tmp/elsewhere.txt -> writes are limited to m10/
7 other tools untouched -> allowed07Keep one regression test per rule每条规则保留一个回归测试
- the two case lists两份案例清单 ← Guardrails and verification护栏与验证 1: Start from logged failures从日志里的失败案例出发
- the functions under test被测试的函数 ← Guardrails and verification护栏与验证 3: Wrap the check in review(), with modes and exemptions用 review() 封装检查,加入模式和豁免
Do this操作
- For each must-catch case, write a test that fails the guard.为每个“必须拦住”的案例写一个让护栏不通过的测试。
- For each must-allow case, write a test that passes it.为每个“必须放行”的案例写一个让护栏通过的测试。
- Run them before every change to the guard, and keep test traffic out of the production guard log. The lab guard writes no log, so the lab tests only the first part.每次修改护栏前都运行它们,并且不要让测试流量进入生产环境的护栏日志。lab 里的护栏不写日志,所以 lab 只测试前一部分。
"""Regression tests for the answer guard. One must-catch and one must-allow case per rule.
python3 -m unittest labs.m10_guard.test_guard -v
"""
from __future__ import annotations
import os
import unittest
from labs.m10_guard.guard import check, review
EV = [{"role": "user", "content": "Did Chen exceed the cap?"},
{"role": "tool", "content": '{"rows": [{"amount_usd": 219.0}, {"amount_usd": 236.0}], "total_usd": 455.0, "cap": 220}'}]
class Grounding(unittest.TestCase):
def test_catch_invented_figure(self):
self.assertFalse(check("Chen paid 312.40 dollars.", EV)["ok"])
def test_allow_figure_from_tool(self):
self.assertTrue(check("Chen paid 219.00 dollars, under the 220 dollar cap.", EV)["ok"])
def test_allow_sum_and_difference(self):
self.assertTrue(check("The stays total $455.00 and differ by $17.00.", EV)["ok"])
class RetryRule(unittest.TestCase):
def test_catch_one_wrong_figure_on_first_draft(self):
self.assertFalse(check("$219.00, $236.00 and $999.00.", EV, strict=True)["ok"])
def test_allow_one_stubborn_figure_on_retry(self):
self.assertTrue(check("$219.00, $236.00 and $999.00.", EV, strict=False)["ok"])
class Exemptions(unittest.TestCase):
def test_allow_requested_example(self):
msgs = [{"role": "user", "content": "Give me a made-up example with numbers."}] + EV[1:]
self.assertTrue(review(msgs, "Say a trip costs 3,100 dollars.", "policy-citation")["ok"])
def test_catch_same_text_when_no_example_was_asked(self):
self.assertFalse(review(EV, "Say a trip costs 3,100 dollars.", "policy-citation")["ok"])
def test_allow_general_talk_without_tools(self):
self.assertTrue(review([{"role": "user", "content": "hi"}], "A typical cap might be $200.", None)["ok"])
def test_catch_data_turn_without_tools(self):
msgs = [{"role": "user", "content": "Who spent the most?"}]
self.assertFalse(review(msgs, "Chen spent $4,410.00.", "expense-investigation")["ok"])
class Modes(unittest.TestCase):
def tearDown(self):
os.environ.pop("GUARD_MODE", None)
def test_observe_records_but_does_not_block(self):
os.environ["GUARD_MODE"] = "observe"
v = review(EV, "Chen paid 312.40 dollars.", "expense-investigation")
self.assertTrue(v["ok"])
self.assertTrue(v["would_block"])
def test_enforce_blocks(self):
os.environ["GUARD_MODE"] = "enforce"
self.assertFalse(review(EV, "Chen paid 312.40 dollars.", "expense-investigation")["ok"])
if __name__ == "__main__":
unittest.main()python3 -m labs.m10_guard.run_testsok Exemptions.test_allow_general_talk_without_tools
ok Exemptions.test_allow_requested_example
ok Exemptions.test_catch_data_turn_without_tools
ok Exemptions.test_catch_same_text_when_no_example_was_asked
ok Grounding.test_allow_figure_from_tool
ok Grounding.test_allow_sum_and_difference
ok Grounding.test_catch_invented_figure
ok Modes.test_enforce_blocks
ok Modes.test_observe_records_but_does_not_block
ok RetryRule.test_allow_one_stubborn_figure_on_retry
ok RetryRule.test_catch_one_wrong_figure_on_first_draft
11 tests, 0 failedHow it works with the other parts它如何与其他部分协作
- Harness engineeringHarness 工程The loop calls review() on the draft and each hook before each tool call.循环对草稿调用 review(),并在每次工具调用前调用各个钩子。
- Tools and MCP工具与 MCPTool messages are the evidence. Structured results make figures easy to find.工具消息就是证据。结构化的结果让数字容易被找到。
- Evaluation评估The agent eval reuses check() to grade whether figures are grounded.智能体评估复用 check() 来判断数字是否有依据。
- Self-evolving agents自进化智能体The promotion gate is a guard on stored knowledge: support must be independent.晋升关卡是针对已存储知识的护栏:支持证据必须相互独立。
What went wrong in the real build真实搭建中踩过的坑
An answer with no tool call passed unchecked没有工具调用的回答未经检查就通过了
- What happened发生了什么
- A follow-up question was answered with three invented totals and no query. The guard ran only when tools had been called.一个追问被直接回答了三个编造的合计数,没有执行任何查询。当时护栏只在调用过工具时才运行。
- Fix修复
- On data turns, check tool-free answers against the conversation so far.在数据轮次上,对没有调用工具的回答也要对照已有对话进行检查。
- Lesson教训
- Decide what the default is when a check has nothing to compare against.当检查没有可比对的对象时,默认行为是什么,要事先决定。
The guard blocked a requested example护栏拦住了用户要求的示例
- What happened发生了什么
- A user asked for a made-up numeric example. The guard rejected the invented amounts and the user got an apology.用户要求举一个虚构的数字示例。护栏拒绝了这些虚构的金额,用户只得到一句道歉。
- Fix修复
- Detect explicit requests for examples and skip the figure check on that turn.识别明确要求举例的请求,在该轮跳过数字检查。
- Lesson教训
- Every guard needs a list of legitimate cases it must let through, with tests.每个护栏都需要一份必须放行的合理情况清单,并配上测试。
Four right totals and one wrong one passed四个对的合计加一个错的,通过了
- What happened发生了什么
- A majority rule let through an answer with one wrong figure among four right ones.多数规则放过了一个四对一错的回答。
- Fix修复
- Judge the first draft strictly. Use the majority rule only on the retry.对第一稿从严判断。多数规则只用于重试。
- Lesson教训
- Strict first, lenient second: catch the single error, and do not turn one stubborn figure into a refusal.先严后宽:既要抓住单个错误,也不要因为一个纠正不过来的数字就把整个回答变成拒绝。
Right figures from the wrong source数字是对的,来源是错的
- What happened发生了什么
- Once in six runs a spending question was answered from a web search while the data tools were never called. Every figure matched the web result, so the check passed.六次运行中有一次,一个支出问题是根据网页搜索回答的,数据工具根本没被调用。每个数字都与网页结果一致,所以检查通过了。
- Fix修复
- On a data turn, reject a first draft that cites figures after a web search and no data tool.在数据轮次上,如果第一稿只做了网页搜索、没有调用数据工具就引用数字,则拒绝。
- Lesson教训
- Grounded is not the same as grounded in the right source.“有依据”不等于“依据来自正确的来源”。
The same idea on other platforms同样的思路在其他平台上
| Platform平台 | How this module maps本模块如何对应 |
|---|---|
| Databricks | Unity Gateway applies guardrails at the endpoint. Groundedness checks like this one are custom code in your agent, or scorers such as RetrievalGroundedness run on traces.Unity Gateway 在端点层面应用护栏。像这样的依据检查需要你在智能体里自己写,或用 RetrievalGroundedness 这类 scorer 在 trace 上运行。 |
| IBM watsonx | watsonx.governance provides guardrails and monitors. Domain checks go in a tool or a post-processing step you write.watsonx.governance 提供护栏和监控。业务领域的检查要放在工具里,或你自己写的后处理步骤里。 |
| Codex | Sandbox and approval modes limit actions. Hooks and your own test commands act as checks on changes.沙箱和审批模式限制操作。钩子和你自己的测试命令充当对改动的检查。 |
| Cursor | Hooks can block or modify agent actions. Rules can require checks before completion.钩子可以阻止或修改智能体的操作。规则可以要求在完成前执行检查。 |
| Claude Code / Agent SDK | Hooks run before and after tool use and can block. Permission modes limit actions. Output checks are code you add in hooks or in the SDK loop.钩子在工具使用前后运行,可以阻止操作。权限模式限制操作范围。输出检查是你在钩子或 SDK 循环里添加的代码。 |
| Another machine | The guard is a pure Python module that takes an answer and messages. Portable as is.护栏是一个纯 Python 模块,输入回答和消息即可。可以原样移植。 |
Step-by-step guides per platform各平台的分步指南
Explain it back讲给自己听
Answer aloud first. Then open the answer and compare.先自己说一遍答案,再展开对照。
Why judge the first draft strictly and the retry by majority?为什么第一稿从严、重试按多数规则?
Why does every rule need an observe mode?为什么每条规则都需要观察模式?
Why is the assistant's earlier text excluded from evidence?为什么助手之前说的话不算证据?
What is the difference between a hook and the answer guard?钩子和回答护栏有什么区别?
Terms术语
| Grounded有依据 | Present in the evidence of this request, or derived from it by a simple rule.出现在本次请求的证据中,或可由简单规则从证据推出。 |
| Data turn数据轮次 | A turn where a data skill was loaded, so figures are expected to come from tools.加载了数据类技能的轮次,其中的数字应当来自工具。 |
| Observe mode观察模式 | The guard records what it would block and changes nothing.护栏只记录它本来会拦截什么,不改变任何结果。 |
| Fallback兜底文本 | A fixed, figure-free reply used when a retry also fails.重试仍不通过时使用的、不含数字的固定回复。 |
From the live build来自实时构建
Recent changes and files the sync job filed under this module. These lines are in English as written in the build.同步任务归到本模块下的近期变更和文件。这些内容保留了构建系统中的英文原文。
- claim_verify: a simplification alone keeps a claim in service; --redecide re-applies the rule to recorded votes
- claim_verify: two-vote check of served claims against their source (dry run and calibration); off-topic the oversight body reports retired from the learner queue
- Guard: on a spending turn a draft sourced from a web search alone is rejected and sent to the spending tools; skill says the same
- Guard: a requested made-up example is recorded, not rejected; wiki ingest runs 23:00-07:00
- Chat eval: the round-limit message counts as a fallback, not a bad answer delivered
- Answer guard checks counts; chat eval in the Sunday cycle; CHAT line in the daily report
- Answer guard: plain message when the model returns nothing twice; chat eval allows 6000 output tokens
- Skills: route by natural-language examples only (descriptions as fallback)
- What the failures teach about making the agent actually get smarter
- check served claims against their source, two votes, and take the ones that fail both out of service.
- a final answer may not state dollar figures the tools did not return (2026-10-02). Why: on 2026-10-02 the agent ran the right a commodity and a commodity queries, got the right rows back, and then answered with a table of an unrelated item purchases ("$18.96 Billion", "Nuccio shipyard").
- the 2026-10-02 an unrelated item answer must fail the guard and the correct a commodity answer must pass. Exits non-zero on failure.
- re-checks the 2026-09-07 fixes, on demand. $AI_DATA/apps/agent-server/venv/bin/python3 $AI_DATA/apps/agent-server/verify_fixes.py Exits 0 if every check passes, 1 otherwise, so it can go in a cycle step.
- Step 5 (AGENT_SERVER_GUIDE_v2.md §4): a small, pluggable pre/post tool-call event registry. A pre-tool hook is `fn(tool_name: str, arguments: dict) -> dict | None`.
- hooks/ — Step 5 (AGENT_SERVER_GUIDE_v2.md §4): a small, pluggable pre/post tool-call event registry, plus the two first real hooks.
- Step 5's second real hook: after a filesystem write/edit/move tool call actually SUCCEEDS against a path under one of the two knowledge banks, automatically triggers kb_sync.py for that bank — the same reconciliation Sync-Knowledge-Base.command already runs by hand (§4 Step ...
- Step 5's first real hook: blocks any tool call that looks like a filesystem write/edit/create/move operation whose target path(s) fall outside an allow-listed set of directories.