Use the middle layer for two things: ask the question accurately, and select the returned materials accurately. Execute ordinary retrieval directly; do not turn the thinking model into a mandatory form to fill out every time.
Default path
- Locate the question: Identify from existing context "what is to be determined, and which fact would change the applicable rule." When an existing analysis report is available, read only the relevant issues and do not repeat the full-case analysis. If the law name and article number or the case number is clear, query the details directly; even if case facts are attached, a single issue is by default handled lightly.
- Call one appropriate tool: If Yuandian MCP is available, call it directly according to the tool's actual schema, without requiring a local Key, CLI, research plan JSON, or archiving. Only when there is no MCP / the user requests the API, read API entry. The first round is not "after trial retrieval there must be formal retrieval"; if it can answer, it is complete.
- Filter and answer: Check the scope of application, key facts, time point, original text support, and source; explain only useful authority. If existing results are sufficient, stop.
Ordinary conversation does not generate research-plan.json、selected-sources.json, does not run contract validation, does not force pulling details, and does not automatically perform dual retrieval with semantics plus keywords. Do not send another request just to cover both sides: a single return can include both supporting and contrary materials.
Parameters and budget
- Use the current MCP schema / API defaults; set filters, rewrites, or counts explicitly only when specifically needed. Do not stuff CLI parameter names directly into MCP parameters.
YD_STRATEGY=aggressive/balanced/economicalis a historical compatibility configuration; it no longer directs legal retrieval, nor does it change CLI retrieval parameters. Do not first read policies, change user configuration, or batch-execute old workflows.- Defaults do not mean returning less: the Yuandian semantic interface may recall dozens of items. Candidate volume is not report length; do not rewrite summaries item by item, and do not recite the entire response to the user. If the context is already clearly crowded, you may explicitly limit the next candidate count as actually needed, and explain that this is not the server-side default.
- Calls consume platform credits; execute within the retrieval scope and budget authorized by the user, and do not repeatedly ask for permission every time. Confirm again when expanding the question scope, batch verification, enterprise investigation, hallucination detection, or when costs exceed existing authorization. When there is no budget agreement, do not make batch calls on your own.
Lightweight legal judgment
Keep only judgments that can change retrieval or material selection, and do not require displaying the entire internal reasoning process:
- Issue: What is the claim or defense, not just the name of the cause of action.
- Key premises: Among the subject, object, conduct, and order of performance / time, which ones would affect the application of the rule. Do not fill unknown facts in as established; ask a follow-up only when it would change the route, otherwise note the assumption and proceed.
- Applicability check: Which point the material can support, which fact is missing, and whether it is merely a close neighbor on the same topic.
For example, for "whether the security deposit can be forfeited if the lease is terminated early," it is necessary to distinguish ordinary housing leases from financial leases, and to treat "whether the security deposit constitutes liquidated damages" as a question to be verified rather than determining it in advance. For issues of property transfer and final payment, it is necessary to compare simultaneous performance with sequential performance; in customer list disputes, the information content, confidentiality measures, and usage conduct must be examined, not merely "employee departure."
Subsumption is a method of judgment, not a fixed output procedure. Only when multiple issues constrain one another, decisive authorities conflict, or the user explicitly requests in-depth case research/a complete search plan should it be loaded as needed In-depth research. It must not be escalated merely because there are case facts or an advocacy position.
When to conduct additional searches
First identify the gaps not yet resolved in the first round, then choose a corresponding action:
| Observed problem | Next step when necessary |
|---|---|
| The law name, article number/case number is known, and the text needs to be determined | Exact details; if a complete verifiable text is already available, do not retrieve it again |
| Results are mixed with neighboring case types | Supplement key facts, rephrase, or use filters supported by that interface |
| Semantic results have the right topic, but the performance order/adjudicative proposition is wrong | Use the already discovered adjudicative language for keyword/field re-checking |
| Zero hits | Check parameters, shorten overly narrow expressions, or switch search methods; do not claim "no similar cases" |
| The returned text is insufficient to support the conclusion to be cited | Verify only the sources intended for use; if they cannot be obtained, disclose that they are unverified |
| What is missing is case facts or evidence | Prompt for supplementation; do not substitute more queries for supplementing evidence |
Stop and explain the boundaries when the user's question has been resolved, there is no new valid material, or the next step exceeds budget. Read keyword techniques and scenario examples only when needed Query correction、Search examples。
Result quality and delivery
- Backend scores only reflect retrieval ranking; they do not represent legal applicability, authority, or verification passing.
- Check the regulated object, level of legal effect, time of entry into force, and the time involved in the case. Typical cases are cases, not legal provisions; industry guidelines are not judicial interpretations. "Currently effective" also does not mean applicable to this case.
- Historical legal sources are not necessarily useless: old facts may require old law; they must not be replaced merely because there is new law, nor adopted directly without an explanation of temporal applicability. The current report script does not yet accept historical legal sources as core; in such circumstances, disclose the limitation and do not falsely label it current to pass the gate.
- Compare similar cases on decisive facts and the court's actual reasoning for adjudication, distinguishing party claims, court judgments, and platform compilation. Yuandian case semantic results may be compiled content and are not automatically equivalent to the verbatim full text of adjudicative documents; do not say that "verbatim full-text verification" has been performed.
- Default conversational delivery: answer the question first, then provide a small amount of selected authority, applicable premises, and unresolved points. If unnecessary, do not add cases or fill the 12-item upper limit.
- Read only when the user requests a report/writing to disk Report generation and selected source contract. Ordinary reports use focused lightweight records; in-depth reports are compatible with the original complete contract. Complete recall must not be copied into the main text.
- Formal reports still require source verification, relevance explanations, grouped ordering, and citation tracing. The program only checks structure and declarations; it does not automatically prove that the Agent's legal judgment is correct.
MCP, API, and data retention
For MCP connection configuration/optional archiving, see the MCP Guide. Do not manually rewrite the entire tool response as JSON for archiving; if there is a file, use ingest --input, otherwise just retain the tool call and source link.
The CLI writes archive/ raw JSON, per-call Markdown, and usually also writes a working directory copy; these are candidate drafts, not formal reports. For ordinary API retrieval, prefer adding --no-report to prevent drafts from being mistaken for deliverables.
--no-report: does not write Markdown, still writes archive JSON.--no-cwd-report: only does not write working directory Markdown.--no-archive: disables all retrieval retention; still reads existing cache, new queries are no longer cached, and subsequent charges may be duplicated. This switch does not replace theconsolidatereport writing explicitly initiated by the user.--archive-dir/YD_ARCHIVE_DIR: redirects archiving. Archiving failure only warns, does not swallow the response, and does not automatically retry.
Requests are sent to open.chineselaw.com, source links may be located in ydzk.chineselaw.com; use the minimum necessary facts, and redact first. Raw documents, client materials, Keys, and archives must not be submitted to public repositories. Do not output scripts/.env content or write Keys into commands.
Dependencies
The MCP path only requires the client to have the Yuandian tools configured; there are no prerequisites for local Python or an API Key. API/archive/report scripts use the Python 3 standard library, with no third-party Python packages.
| Dependencies | Installation method |
|---|---|
| Python 3 (local scripts only) | macOS:brew install python;Linux:sudo apt-get install python3 |
When an API is needed, read the Key from the environment variable YD_API_KEY or scripts/.env ; when missing, prompt for configuration according to the API entry point ; do not prevent use of an existing MCP or organizing existing results because the Key is missing.