Skip to content
中文

Configuration and soft conventions ​

A type system guarantees field shapes, not sensible values: which document lives where, how large a budget should be, how many candidates to keep, what to log, or where credentials come from. These are soft conventions and need explicit management. Otherwise problems appear at runtime as "answers got worse" rather than "configuration is wrong".

What types do not protect ​

SettingRiskAdvice
Corpus layout and file namesFiles move or are silently skipped; an empty corpus looks healthyValidate the directory, ids and revisions at startup
Topic vocabulary and aliasesNew phrasings retrieve nothingAdd real misses to the vocabulary
Budgets and candidate countsToo tight rejects requests; too loose crowds out rulesMeasure real calls, then adjust
Prompt and domain rule textSemantic drift that compilation cannot catchVersion it and keep the reason for changes
Log fieldsMissing fields block diagnosis; extra fields leak privacyDefine fields, then retention
Environment variables and secretsCommitted secrets or mixed environmentsRead only from env or a secret store

Boundaries the SDK enforces ​

The SDK rejects out-of-range values but does not choose business values for you. Known boundaries include:

  • TextSearch and VectorSearch accept limit from 1 to 1000, and filters must return a boolean synchronously;
  • VectorSearch requires dimensions from 1 to 16384, keeps minScore within -1 to 1, and rejects zero vectors;
  • TextSearch requires a non-empty query and field declarations at construction time;
  • Knowledge maxChars and context fragment limits are App-set, and exceeding them raises an error;
  • ModelCalls requires timeoutMs to be a supported positive safe integer.

These are contracts, not advice. Business budgets, candidate counts and timeouts still belong to the App.

The values below are starting points, not standards. Measure real calls before changing them.

ItemStarting pointBasis for adjustment
Document readsPrefer the whole document; keep one read under about one third of the model inputRead by topic or section when exceeded
Retrieval candidatesAbout 20 each from lexical and vector, keep 5 to 8 after fusionWatch recall@k and context usage
Model timeoutShorter than the total request deadline, with room for retriesProvider latency distribution and cancellation needs
Embedding timeoutSeparate from model calls, with a fallbackWhether retrieval can fall back to lexical
Log retentionSet separately by privacy and diagnosis needsNever copy examples or temporary values
Index rebuildIncremental when content revision changesFull rebuild on tokenizer, field or model changes

Do not tune budgets to exactly fit the current sample. Rejecting on a small growth makes the system look unreliable in real use.

Startup checks ​

Run a read-only check at startup, and either refuse to start or disable the affected capability when it fails:

  • The corpus directory exists, files are readable, and the catalog parses;
  • Document and section ids are unique and revision is non-empty;
  • Internal links, sources and scope references resolve;
  • An empty corpus is allowed, but must not be recorded as "loaded";
  • The embedding model identity matches the index space;
  • The effective configuration version can be written to logs.

These checks prove structure and references, not that content is true or semantically correct.

Naming and versions ​

  • Documents, sections and chunks use stable id values. Titles may change; identity should not.
  • revision is a content hash or an explicit release number. One revision must not describe two different texts.
  • Bump TextSearch.indexRevision when fields, tokenization or normalization change; otherwise old snapshots restore under the wrong rules.
  • Give retrieval configurations their own identifier and record it per request. Without it, "answers got worse" cannot be attributed to a configuration change.
  • Publish corpus changes through the candidate and publication flow. Do not hand-edit runtime copies and pretend the version did not change.

Secrets and environments ​

  • Read model, embedding and storage credentials only from environment variables or a secret store. Never put them in the corpus, prompts or repository.
  • Use different credentials and indexes per environment; never share test data.
  • Keep secrets, full prompts and unmasked personal data out of logs.
  • Client-supplied configuration is data. It cannot elevate permissions or change the model connection.

How to change configuration ​

Configuration changes need evidence too: what changed, why, which samples were observed, and how to roll back. An "optimization" without measurements does not go straight to production.

Do not hand-edit generated directories, runtime copies or build artifacts. Change the source and regenerate; otherwise the next build overwrites the edit and the diff cannot be explained.

Common issues ​

SymptomLikely causeFix
Starts fine but always says there is no materialThe corpus was not loaded, or empty data looks normalAdd startup checks and log the load result
Updated material still returns old contentRevision did not change, or caches were not clearedRegenerate the revision and clear indexes and caches
Budget rejections happen occasionallyThe value sits at the current sample ceilingLeave headroom or read in passes
Retrieval breaks after a model changeEmbedding spaces differValidate identity and rebuild the index
Logs cannot locate the problemConfiguration id, stage or tool id is missingAdd fields before debugging further

Next ​

API reference, usage examples and developer guides.