Skip to content
Product

Knowledge Bases: Give Your AI Recipes Real Company Context

How JieGou's knowledge bases use RAG to inject company-specific documents into AI executions — chunking strategies, embedding search, feedback-driven relevance, and automatic knowledge capture.

JT
JieGou Team
· · 6 min read

AI automations without company context produce generic outputs. Your recipe can write a great competitive analysis — but it doesn’t know your product names. It can draft an incident response — but it has no idea what your runbook says. It can summarize customer feedback — but it can’t reference your internal taxonomy.

Knowledge bases fix this. Upload your documents, and JieGou injects relevant content into every recipe and workflow execution automatically via Retrieval-Augmented Generation (RAG).

How documents are processed

Upload files in any of these formats: PDF, DOCX, CSV, XLSX, TXT, Markdown, HTML. Or import directly from a URL. The per-upload file size cap is 10 MB, with a 1 MB extracted content limit after parsing.

Once uploaded, documents go through a multi-stage processing pipeline:

1. Chunking. Documents are split using a two-tier strategy. First, the system scans for # and ## markdown headings and splits on those boundaries — this preserves the logical structure of well-organized documents. For unstructured documents without headings, it falls back to paragraph-based splitting. Target chunk size is approximately 40,000 characters (~10K tokens), with a minimum of 4,000 characters to avoid fragments that lack useful context.

2. Summarization. Each chunk gets an LLM-generated summary of 200-400 words via Claude. These summaries serve two purposes: they provide fallback context when embedding search returns no results, and they give the retrieval system a compressed representation of each chunk’s content.

3. Embedding. Each chunk is embedded using OpenAI text-embedding-3-small (1536 dimensions). Embeddings are stored in Firestore alongside the chunk content and metadata — no external vector database required.

How retrieval works at execution time

When a recipe or workflow step runs, the system builds a context window from your knowledge bases:

  1. A query embedding is generated from the user’s prompt or the step’s input
  2. Cosine similarity search runs against all chunk embeddings in the relevant knowledge bases
  3. Chunks below a minimum similarity threshold of 0.3 are discarded
  4. Top-k selection picks the best matches within a token budget — default is 5 chunks, 8,000 tokens max
  5. Selected chunks are injected into the LLM prompt as XML <reference_documents> blocks
  6. If no embeddings meet the threshold, the system falls back to summary-based context

Embeddings are stored in Firestore and cosine similarity is computed in application code. There is no external vector database dependency. This is practical because token budgets limit the number of documents per query — you are never searching millions of vectors, just the documents in your account’s knowledge bases.

Three-tier context resolution

Not every execution needs the same context. JieGou resolves knowledge base documents from three sources, merged and deduplicated automatically:

TierHow it worksWhen to use
Explicit document IDsSpecific document IDs passed at execution timeWhen you know exactly which documents are relevant
Recipe/workflow-attachedKnowledge bases linked via the knowledgeBaseIds field on a recipe or workflowWhen certain docs should always accompany a specific recipe
Auto-contextKnowledge bases marked isAutoContext: true, scoped by departmentWhen documents should be available to every execution in a department

Auto-context is the most powerful tier. Mark your company wiki, product documentation, or brand guidelines as auto-context, and every recipe in that department gets relevant chunks without any manual configuration.

Feedback-driven relevance

Knowledge bases get smarter over time. When users give thumbs-up or thumbs-down feedback on a run’s quality, the system adjusts chunk relevance scores for future retrievals.

The scoring uses Laplace smoothing: score = (ups + 1) / (ups + downs + 2). This starts every chunk at a neutral 0.5 and adjusts based on evidence, avoiding extreme scores from small sample sizes.

The resulting boost factor ranges from 0.5x to 1.5x, stored in Redis with a 7-day TTL. Chunks that consistently appear in high-quality runs get boosted. Chunks that appear in low-quality runs get demoted. Over time, the most useful content surfaces more frequently without any manual curation.

Knowledge capture: learning from good outputs

This is where knowledge bases become a flywheel. When a recipe execution receives positive feedback or scores well on JieGou’s Quality Guard, the system automatically captures structured knowledge from that output.

An LLM extracts:

  • Title — a descriptive name for the captured knowledge
  • Key facts — the important claims, decisions, or findings
  • Entities — people, products, companies, and other proper nouns mentioned
  • Topic tags — categories for retrieval matching

The extracted knowledge is stored in a dedicated “Auto-Captured Knowledge” base with isAutoContext: true. Future executions in the same department can retrieve this knowledge automatically.

The result: your AI system literally learns from its own good outputs. A well-crafted competitive analysis today becomes retrievable context for tomorrow’s strategy brief.

Document freshness

Documents sourced from URLs can be configured with a refreshIntervalDays setting for automatic re-fetching. When the system re-fetches a document, it computes a SHA-256 content hash and compares it to the stored hash. If the content has not changed, processing stops.

If the content has changed, only the affected chunks are re-processed — new embeddings and summaries are generated incrementally rather than reprocessing the entire document. This keeps your knowledge bases current without wasting compute on unchanged content.

Write-to-KB workflow step

Workflows can write outputs directly into knowledge bases using the dedicated Write-to-KB step type. This enables workflows that accumulate knowledge over time.

A customer support triage workflow might resolve a ticket, then write the resolution summary to a knowledge base. The next time a similar ticket arrives, the resolution is available as RAG context. A weekly market research workflow might append its findings to a competitive intelligence knowledge base that grows richer with every run.

Scoping and access control

Knowledge bases are scoped per account with optional department filtering. Auto-context knowledge bases respect department boundaries — the engineering department’s internal docs do not leak into marketing’s recipe executions.

This scoping is enforced at the retrieval layer. When the three-tier context resolution runs, auto-context knowledge bases are filtered by the executing user’s department before any embedding search occurs.

Availability

Knowledge bases with RAG are available on Pro plans and above. Auto-captured knowledge and the Write-to-KB workflow step are included at no additional cost. Learn more about all features or start your free trial.

knowledge-bases rag retrieval-augmented-generation context embeddings
Share this article

Enjoyed this post?

Get workflow tips, product updates, and automation guides in your inbox.

No spam. Unsubscribe anytime.