A context engineer is developing a Databricks legal research agent for an international financial services organization. The agent uses a DELTA_SYNC Databricks AI Search index containing regulatory compliance documents for the United States, United Kingdom, and European Union.
Each document chunk includes the following metadata:
jurisdiction: The regulatory jurisdiction to which the document applies.
document_status: Whether the document is active, superseded, or archived.
effective_date: The date on which the regulatory provision became effective.
document_id: The unique identifier of the source document.
The agent uses semantic similarity search with num_results=10 to retrieve regulatory evidence.
During MLflow evaluation, the engineer discovers that questions about current UK financial reporting obligations frequently retrieve superseded UK regulations and highly relevant US regulatory documents. The resulting answers are technically plausible but cite requirements that do not apply to the user's jurisdiction or requested reporting period.
The embedding model produces accurate semantic similarity scores, and increasing num_results does not improve regulatory correctness.
The engineer must preserve semantic retrieval while ensuring that only regulations applicable to the requested jurisdiction and reporting date are considered.
Which retrieval configuration should the context engineer implement?
Answer : B
The observed failure results from a mismatch between semantic relevance and regulatory applicability.
Semantic similarity measures how closely document content relates to a query. It does not independently establish whether a regulatory document applies to a specific jurisdiction, reporting period, or effective date.
Consequently, a highly relevant US regulation may rank above an applicable UK regulation when both discuss similar financial reporting obligations.
Option B resolves this problem through metadata-constrained retrieval.
Databricks AI Search supports query filters that restrict results according to indexed metadata fields. The engineer can filter documents by jurisdiction and applicable regulatory status before incorporating their contents into the agent's context.
Effective-date filtering should account for the requested reporting date and the organization's regulation-versioning rules. A document marked active today is not necessarily the regulation that governed an earlier reporting period.
After applying the eligibility constraints, semantic retrieval can identify the most relevant passages from the remaining documents.
Option A increases candidate volume without correcting applicability. Option C sacrifices valuable semantic matching. Option D relies on generation-time instructions to compensate for incorrect retrieval.
The engineer should also enforce access permissions independently; metadata filters improve retrieval correctness but are not a substitute for authorization.
Official Databricks reference: AI Search filtering guide and Improve RAG chain quality --- Metadata Filtering.
A context engineer manages a Genie space for a finance team. Users repeatedly ask the same shape of QUESTION NO: with different fiscal periods: ''What is the total open pipeline by region for FY26 Q1?'', ''...for FY26 Q2?'' ''...for the last quarter?''. The SQL pattern Genie generates is identical across these questions (same JOIN, GROUP BY, and aggregation, with only the fiscal-period filter changing), and the team requires that responses to these recurring questions be labeled Trusted in the chat UI. The engineer must register an asset that reuses the same vetted SQL pattern with the user-supplied fiscal period.
Which curation choice should the engineer make?
Answer : A
A parameterized example SQL query is the appropriate choice when users repeatedly request the same analytical calculation with different filter values.
The finance team's requests share the same SQL structure, including table joins, regional grouping, pipeline aggregation, and relevant business filters. Only the fiscal-period value changes.
Rather than requiring Genie to regenerate this SQL independently for every question, the engineer can register a validated example query containing a typed parameter, such as :fiscal_period.
Databricks Genie supports query parameters with defined data types, including String, Date, Date and Time, Decimal, and Integer.
When a question supplies a fiscal period, Genie can associate the input with the parameter while preserving the approved SQL structure.
This approach also supports trusted responses when Genie uses the exact registered parameterized query in chat mode.
Option B allows Genie to compose surrounding SQL dynamically, meaning the complete query structure is not necessarily preserved. Option C relies on generated SQL derived from textual instructions. Option D requires maintaining separate static examples and does not generalize well to additional fiscal periods.
A parameterized example therefore provides stronger consistency, simpler maintenance, and controlled reuse of a verified calculation.
The engineer should validate fiscal-period formats and ensure that relative expressions such as 'last quarter' resolve to the correct accounting period.
Official Databricks reference: Databricks --- Tune Genie Agent quality, particularly Add Query Parameters and Trusted Assets.
A context engineer is tuning a compaction prompt for a Databricks agent that summarizes customer support ticket histories before sending them to a downstream LLM. The trace being compacted spans 40 turns, and the compacted output must fit within the downstream LLM's context window. During initial evaluation against a benchmark of escalated support cases, the engineer observes that the compaction output consistently omits several prior resolutions and key escalation events, even though it fits well within the downstream LLM's context window.
What tuning step should the engineer take next?
Answer : C
The evaluation indicates that the compaction process is losing important information despite producing summaries comfortably within the available context budget.
This is primarily a context-retention failure rather than a token-efficiency problem.
Option C correctly prioritizes improving information recall before attempting further compression.
The engineer should revise the compaction instructions to explicitly preserve previous resolutions, escalation decisions, unresolved issues, ownership changes, customer commitments, and significant troubleshooting events.
These details may remain important even when they occurred many turns earlier.
For example, an escalation decision made at turn 8 may determine how a support case should be handled at turn 40. A summarizer that prioritizes recent messages may incorrectly omit that earlier decision.
Option A would make summaries shorter and potentially worsen information loss. Option B assumes recent events are always more important. Option D changes both retention and pruning behavior simultaneously, making it harder to identify which modification improves performance.
A disciplined optimization process should first establish adequate coverage of important facts, then remove redundant language while preserving that coverage.
Databricks MLflow evaluation supports testing application behavior against representative datasets and comparing quality across configurations.
The engineer should use a benchmark containing expected escalation events and resolutions to assess completeness before optimizing summary length.
Official Databricks reference: Tracing overview, MLflow API Reference, and Debug and analyze your app with tracing.
A context engineer is developing a RAG pipeline for a pharmaceutical knowledge base. Document chunks from clinical trial summaries are stored in a Unity Catalog-governed Delta table with precomputed embedding vectors. Pure vector similarity search retrieves topically related chunks effectively but misses chunks that depend on precise drug compound names and dosage identifiers in the search string, because those tokens are underrepresented in the embedding space. The engineer wants to recover those exact-term chunks while preserving the semantic retrieval that already works, without standing up a separate keyword index or adding a downstream merge step.
Which configuration should the engineer use to close this retrieval gap?
Answer : C
Databricks AI Search hybrid retrieval is designed for queries that require both semantic understanding and accurate matching of specific terminology.
In this scenario, approximate nearest-neighbor search successfully identifies semantically relevant clinical trial summaries but fails to recover certain passages containing exact compound names and dosage identifiers. These identifiers can be weakly represented in embedding space, particularly when their surrounding clinical descriptions are similar.
Hybrid search addresses this limitation by executing approximate nearest-neighbor retrieval and full-text keyword search within the same query operation.
Databricks combines the two result sets using Reciprocal Rank Fusion (RRF), which integrates their respective rankings into a unified relevance ranking. This allows the retrieval process to consider both semantic relevance and precise textual matches.
Option A applies filtering without establishing a combined semantic and lexical ranking. Option B incorrectly treats reranking as the mechanism for independently combining full-text and ANN retrieval. Option D performs filtering after vector retrieval, meaning documents omitted from the original candidate set cannot be recovered.
The appropriate implementation uses query_type='HYBRID' when querying the AI Search index.
For pharmaceutical applications, the engineer should also evaluate retrieval performance using compound identifiers, dosage codes, and clinical terminology to ensure that relevant evidence is not overlooked.
Official Databricks reference: Query an AI Search index --- Retrieval Algorithms, Full-Text Search, Hybrid Search, and Reciprocal Rank Fusion.
A context engineer is evaluating a Databricks agent built for a healthcare scheduling platform. The agent's system prompt is 5,100 tokens and includes detailed instructions for three rarely invoked capabilities, each triggered in fewer than 2% of sessions:
Insurance eligibility verification, which requires calls to a third-party payer API with variable response times
Appointment rescheduling fee calculations, with complex branching logic across dozens of plan types and provider tiers
Medical record release consent workflows, with multi-step conditional logic and regulatory references
The agent's primary function is answering patient appointment availability queries, which account for 95% of traffic. The team must reduce per-session context cost without degrading task success rate on the dominant use case, and the solution must stay within the existing Databricks agent framework without introducing additional hosted components to manage.
Which loading strategy should the context engineer use for the three rarely invoked capabilities?
Answer : C
Agent Skills provide a mechanism for organizing specialized instructions into task-specific capabilities that are loaded only when relevant.
The original system prompt consumes 5,100 tokens, including detailed guidance for capabilities invoked in fewer than 2% of sessions. Consequently, most requests pay the context cost of instructions that the agent never uses.
Option C applies progressive disclosure by separating rarely required workflows from the baseline system prompt.
Each capability can be packaged as an Agent Skill containing its instructions, decision rules, relevant tool guidance, and supporting resources.
The agent initially receives only the minimal information necessary to identify the available skills. When a request requires insurance verification, fee calculation, or medical record release processing, the corresponding instructions are loaded into the working context.
Databricks documents automatic, relevance-based loading of Agent Skills in Genie Code and supports governed skills through Unity Catalog and Unity Gateway. A custom agent must have the appropriate skill-discovery and loading integration configured.
Option A reduces instruction length but retains unnecessary baseline context. Option B may improve caching economics but does not remove irrelevant instructions. Option D adds retrieval complexity where a structured skill mechanism is more appropriate.
The resulting architecture preserves detailed instructions for exceptional workflows while minimizing context consumption for routine appointment availability requests.
Official Databricks reference: Extend Genie Code with agent skills, Unity Catalog Skills, and Add tools and skills.
A context engineer is building a memory-augmented agent that stores user session memories in Lakebase as an OLTP Postgres table. Each memory record contains columns such as user_id, session_timestamp, preference_category, and confirmed_preference_value. At runtime, the agent must retrieve all confirmed preferences for a specific user that were recorded within the last 30 days. A Databricks AI Search index is created over conversation summary embeddings as part of a delta table synced from the Lakebase, providing an additional data source.
Which retrieval mechanism should the context engineer configure for this type of query?
Answer : B
Structured SQL retrieval is the appropriate mechanism because the requested memory records are identified by explicit attributes rather than semantic similarity.
The agent needs all confirmed preferences belonging to a particular user within a defined 30-day period. This is a deterministic filtering requirement involving user_id and session_timestamp.
Lakebase provides a managed PostgreSQL-compatible transactional database optimized for operational applications requiring low-latency record access.
A parameterized SQL query can retrieve the required records using an exact user identifier and a bounded timestamp condition.
For example, the query could filter records where user_id matches the requesting user and session_timestamp falls within the previous 30 days. The retrieved results can then be incorporated into the agent's memory context.
Unlike semantic search, structured SQL does not depend on embedding similarity scores, approximate nearest-neighbor rankings, or top-k retrieval thresholds.
Option A introduces unnecessary similarity processing. Option C uses a vector index for information already represented through structured fields. Option D incorrectly introduces additional filtering conditions that could exclude valid preferences belonging to other sessions or categories.
For production efficiency, the engineer should consider an index on the user identifier and timestamp columns and enforce user-level authorization.
Official Databricks reference: Lakebase Postgres and Agent state and memory.
A context engineer is building a retrieval-augmented generation agent on Databricks to answer questions about a large collection of legal contracts. Each contract is a structured PDF averaging 40 pages, with clearly defined sections such as ''Definitions,'' ''Obligations,'' and ''Termination Clauses.'' The embedding model in use has a 512-token context window. User queries are highly targeted, such as ''What are the termination conditions in the indemnification clause?'', and require precise, clause-level retrieval rather than broad document summaries.
Which chunking strategy should the context engineer use?
Answer : A
Structure-aware chunking is the most suitable strategy because the source documents contain meaningful organizational boundaries that should be preserved during indexing.
Legal contracts organize obligations, definitions, indemnification provisions, termination rights, and exceptions into sections and subsections. Arbitrary chunking can separate a contractual provision from its governing language, resulting in incomplete or misleading retrieval.
Databricks recommends semantically coherent chunking strategies that consider the original document's structure, section headings, and topic boundaries.
Option A initially divides the document according to its logical sections. Longer sections are subsequently subdivided into smaller chunks that remain within the embedding model's supported context window.
Using approximately 400 tokens per chunk provides a reasonable margin below the stated 512-token limit, leaving room for relevant headings or metadata.
Option B may create excessively fragmented chunks and separate closely related legal conditions. Option C ignores structural boundaries and risks splitting clauses or definitions across arbitrary token positions. Option D can exceed the embedding model's maximum input length, resulting in truncation or processing failures.
An effective implementation should preserve document identifiers, section headings, clause references, and page numbers as retrieval metadata.
The engineer should then evaluate chunk-level retrieval recall and answer faithfulness against known contract clauses.
Official Databricks reference: Build an unstructured data pipeline for RAG --- Chunking, Data Chunking Strategies, Semantic Coherence, and Structural Metadata.