# How the Patent‑OA Sub‑Skill Automates Office Action Response Drafting

> Automate office action responses with the patent-oa sub-skill. This tool parses PDFs, searches prior art, and drafts a polished Word document, saving you time and effort.

- Repository: [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill)
- Tags: how-to-guide
- Published: 2026-09-05

---

**The patent‑oa sub‑skill streamlines examiner office action (OA) responses by parsing notification PDFs, retrieving relevant prior‑art cases through semantic or tag‑based search, and emitting a polished Word document—all from a single command.**

The `patent-oa` sub‑skill in the [handsomestWei/patent‑disclosure‑skill](https://github.com/handsomestWei/patent-disclosure-skill) repository transforms how patent practitioners handle examiner rejections. Instead of manually extracting PDF text, hunting for analogous cases, and formatting legal opinions, users run one CLI command to generate a ready‑to‑edit response draft backed by historical precedent.

## Core Capabilities of Patent‑OA

The sub‑skill combines three integrated capabilities: document parsing and draft generation, institutional knowledge distillation, and dual‑mode semantic retrieval.

### Draft Generation Pipeline

In [`skills/patent-oa/tools/search_cases.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/search_cases.py), the system ingests an examiner's notification—whether PDF or plain text—and constructs a structured query from the extracted content. The module then searches the local knowledge base (or a vector store when enabled) and produces a **Markdown draft opinion** containing argument scaffolding and cited precedents.

```bash
python -m skills.patent-oa.tools.search_cases \
    --pdf outputs/oa/2023_08_15_通知书.pdf \
    --tag "缺陷:缺少说明" \
    --top-k 5 \
    --config config.yaml

```

The JSON output includes:

- `query_preview` — a trimmed excerpt of extracted PDF text for verification
- `retrieval_mode` — indicates whether **vector** or **tags_only** search was active
- `hits` — ranked prior cases with a `diff` field highlighting domain, statutes, and defect type matches

Once edited, the opinion converts to submission format via [`skills/patent-oa/tools/emit_opinion_docx.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/emit_opinion_docx.py):

```bash
python -m skills.patent-oa.tools.emit_opinion_docx \
    -i outputs/oa/案/意见陈述_20230815090000.md \
    -o outputs/oa/案/意见陈述_20230815090000.docx

```

Success emits `DOCX: ok=1 path=...` with a professionally formatted Word document ready for filing.

### Knowledge Distillation from Historical Cases

Historical OA responses populate an Obsidian vault through [`store.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/store.py) and [`embed.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/embed.py). When processing a new notification, the system **hydrates** the draft with excerpts from structurally similar past cases—matching on defect categories, technical domains, and applied statutes. This institutional memory improves argument consistency and reduces research time. The full pipeline is documented in [`skills/patent-oa/README.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/README.md).

### Semantic Retrieval with Fallback Guarantees

Vector search activates when [`config.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/config.py) and [`embed.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/embed.py) detect a configured database. The query text is embedded and matched against stored case vectors for semantic similarity ranking. If vector infrastructure is unavailable, the tool automatically falls back to **tag‑based filtering**—ensuring every execution returns usable results regardless of environment state.

## Programmatic Integration

Embed the patent‑oa workflow within larger automation pipelines using direct Python imports:

```python
from skills.patent_oa.tools.search_cases import main as search_cases
from skills.patent_oa.tools.emit_opinion_docx import emit_opinion_docx

import json, subprocess, pathlib

# Execute search and capture structured output

result = subprocess.check_output([
    "python", "-m", "skills.patent-oa.tools.search_cases",
    "--pdf", "my_notification.pdf",
    "--top-k", "3"
])
data = json.loads(result)

# Generate minimal opinion from top match

opinion_md = f"# OA Response\n\nBased on case {data['hits'][0]['id']} ..."

path_md = pathlib.Path("draft_opinion.md")
path_md.write_text(opinion_md, encoding="utf-8")

# Convert to final submission format

docx_path = emit_opinion_docx(path_md)
print(f"Generated: {docx_path}")

```

## Key Source Files

| File | Responsibility |
|------|---------------|
| [`skills/patent-oa/README.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/README.md) | Capability overview and usage guidance |
| [`skills/patent-oa/tools/search_cases.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/search_cases.py) | PDF parsing, query construction, dual‑mode search, JSON draft emission |
| [`skills/patent-oa/tools/emit_opinion_docx.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/emit_opinion_docx.py) | Markdown‑to‑DOCX conversion with formatting |
| [`skills/patent-oa/tools/config.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/config.py) | Vector store toggles, default `top-k`, and runtime configuration |
| [`skills/patent-oa/tools/embed.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/embed.py) | Text embedding for semantic retrieval |
| [`skills/patent-oa/tools/store.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-oa/tools/store.py) | Local case persistence and search API |

## Summary

- **Single‑command workflow**: Supply a PDF notification, receive a structured draft and reference cases
- **Dual search modes**: Vector similarity when available, tag filters as guaranteed fallback
- **Knowledge hydration**: Historical case excerpts enrich new argument drafts
- **Professional output**: Pipeline terminates in submission‑ready Word documents
- **Full programmability**: Importable modules support custom pipeline integration

## Frequently Asked Questions

### What file formats does patent‑oa accept for office action notifications?

The [`search_cases.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/search_cases.py) tool accepts **PDF examiner notifications** and plain text files. PDF parsing extracts the structured rejection content automatically, while text files bypass extraction for direct query construction.

### How does patent‑oa handle cases when vector search is unavailable?

The system implements **automatic fallback**: when [`config.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/config.py) detects no vector database, [`search_cases.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/search_cases.py) switches to tag‑based filtering using defect categories, technical domains, and statute tags. Every execution returns results regardless of infrastructure state.

### Can I customize the number of prior cases retrieved?

Yes. The `--top-k` parameter controls result count (default configured in [`config.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/config.py)). Pass explicit values like `--top-k 10` for broader research or `--top-k 3` for focused precedent matching.

### Is the generated Word document editable before submission?

Absolutely. The [`emit_opinion_docx.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/emit_opinion_docx.py) tool converts **user‑editable Markdown** into DOCX format. Practitioners should review and refine arguments, add claim amendments, and verify citations before finalizing the office action response.