How the Agent Self-Check List Ensures Protocol Compliance Across All Five Operating Modes
The agent self-check list guarantees protocol compliance by executing a unified three-step validation cycle—parameter whitelisting, mode-specific consistency checks, and decision-gated logging—before permitting any action in the patent-disclosure skill.
The handsomestWei/patent-disclosure-skill repository implements a robust governance layer that prevents malformed requests from reaching external services such as CNIPA search, CAD processors, or Obsidian vault updates. At the core of this safety mechanism is an agent self-check list that runs identically across all five high-level operating modes, ensuring uniform validation logic regardless of the task complexity. This systematic approach creates a single source of truth for protocol compliance that is shared across every entry point in the codebase.
The Five Operating Modes and Their Entry Points
The patent-disclosure skill defines five distinct operational contexts in SKILL.md, each triggered by specific user commands but governed by the same validation infrastructure:
- 交底书 (Disclosure) – Generates formal patent disclosure documents from technical briefs.
- 通俗解读 (Plain-language reading) – Translates patent claims into accessible explanations, implemented in
tools/patent_reader/vault/write_patent_obsidian_note.py. - 技能自进化 (Skill evolution) – Executes policy radar tasks for automated skill refinement.
- 审查答复 (Office-action response) – Drafts responses to patent office actions.
- 项目扫描 (Project scan) – Handles CAD file ingestion and project analysis.
Despite their functional differences, all five modes import the same validation routines from tools/shared/structure_lineart_gate.py and tools/shared/iteration_dialog_log.py, ensuring that protocol compliance is enforced uniformly before mode-specific logic executes.
The Three-Step Validation Cycle
The self-check list operates through a rigid three-phase pipeline that inspects every incoming request. This cycle runs automatically before the agent touches any external resource.
Parameter Validation Against Whitelists
First, the system inspects the JSON-like brief object passed to the skill and verifies that mandatory fields exist and contain whitelisted values. The validate_brief() function in tools/shared/structure_lineart_gate.py maintains strict allow-lists for critical parameters.
For example, the callout_mode field must be one of overlay, in_prompt, or contour_only. Any deviation triggers an immediate validation error:
from tools.shared.structure_lineart_gate import validate_brief
brief = {
"patent_type": "utility_model",
"callout_mode": "overlay", # Must be in whitelist
"visible_part_ids": ["A1", "B3"]
}
errors = validate_brief(brief) # Returns list of protocol violations
if errors:
raise RuntimeError("\n".join(errors))
Mode-Specific Consistency Checks
Second, the self-check list enforces cross-field dependencies that vary by operational context. Certain parameter combinations are only valid in specific modes, and the validation layer flags logical mismatches before execution proceeds.
A critical rule implemented in structure_lineart_gate.py requires that visible_part_ids must be provided whenever callout_mode is not set to contour_only:
# Mode-specific consistency enforcement
if brief.get("callout_mode") != "contour_only" and not brief.get("visible_part_ids"):
error = "When callout_mode!=contour_only, visible_part_ids must be supplied"
raise ValueError(error)
This check prevents the agent from entering undefined states where required contextual data is missing for the selected operating mode.
Logging and Decision Gating
Third, all validation results—errors, warnings, and success flags—are recorded in the iteration dialog log via log_self_check() in tools/shared/iteration_dialog_log.py. The dispatcher consults this log before proceeding; a non-empty error list aborts the operation and returns structured diagnostics to the user:
from tools.shared.iteration_dialog_log import log_self_check
errors = validate_brief(brief)
if errors:
log_self_check(errors, mode="disclosure") # Records to iteration_dialog_log.py
# Execution halts here; external services are never contacted
return {"status": "blocked", "diagnostics": errors}
This decision gate ensures that protocol violations are captured in an audit trail while preventing invalid requests from consuming compute resources or corrupting external systems.
Shared Validation Layer Implementation
The uniformity of protocol compliance across all five modes stems from a shared import architecture. Rather than duplicating validation logic, every high-level entry point—including tools/patent_reader/vault/write_patent_obsidian_note.py for plain-language mode and the CAD handling pipelines for project scan mode—imports the same validate_brief() and log_self_check() functions.
This design guarantees that:
- Uniformity – All modes reference identical field whitelists and consistency rules defined in
structure_lineart_gate.py. - Safety – Incompatible or missing parameters trigger an early bail-out before external API calls or file system operations occur.
- Traceability – Every execution produces a structured record in the iteration dialog log, creating an auditable history of what was validated and why specific requests were rejected.
Because new modes automatically inherit these checks by importing the shared validation modules, the self-check list scales linearly with feature additions without requiring boilerplate replication.
Summary
- The agent self-check list runs a three-step validation cycle (parameter whitelisting, consistency checks, and decision-gated logging) before any action executes.
- All five operating modes—交底书, 通俗解读, 技能自进化, 审查答复, and 项目扫描—share the same validation logic from
tools/shared/structure_lineart_gate.py. - The
validate_brief()function enforces mandatory field presence and whitelist membership for critical parameters likecallout_mode. - Mode-specific consistency checks prevent logical errors, such as missing
visible_part_idswhencallout_modeis notcontour_only. - The iteration dialog log (
iteration_dialog_log.py) serves as the final gatekeeper, aborting execution and recording diagnostics when protocol violations are detected.
Frequently Asked Questions
What happens if a brief fails the self-check list validation?
If validate_brief() returns errors, the log_self_check() function records the failures to the iteration dialog log, and the dispatcher aborts the operation before any external service is contacted. The user receives a clear diagnostic message listing the specific protocol violations without any partial execution occurring.
How does the self-check list handle new operating modes added to the skill?
New modes automatically inherit protocol compliance checks by importing the shared validation functions from tools/shared/structure_lineart_gate.py and tools/shared/iteration_dialog_log.py. Because the validation logic is centralized, adding a new mode requires no duplication of check-list code—only the brief structure and mode-specific business logic need definition.
Where are the whitelisted values for parameters like callout_mode defined?
The allowed values for callout_mode (overlay, in_prompt, contour_only) and other constrained fields are defined in tools/shared/structure_lineart_gate.py. This file serves as the central authority for protocol constraints, ensuring all five modes reference the same validation rules through the validate_brief() function.
Can the self-check list be bypassed during execution?
No. The validation calls are hard-coded into the entry points of every operating mode, including the disclosure pipeline and tools/patent_reader/vault/write_patent_obsidian_note.py. Because the checks run before the dispatcher hands control to mode-specific logic, there is no execution path that bypasses the protocol compliance layer.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →