QuestionQ3

VerifiedContext Compression and Compaction

A context engineer is developing a Databricks agent for a retail inventory management system. The system prompt and tool descriptions consume 1,800 tokens of a 4,096-token context window, and the engineer reserves 1,000 tokens for the user turn and model response. The remaining tokens are used for few-shot examples, each costing approximately 250 tokens, so the engineer includes exactly five examples.

The agent uses three tools: inventory_lookup, reorder_check, and supplier_lead_time.

Six candidate examples are available:

  • Example 1: A warehouse manager asks whether a depleted SKU needs reordering; the agent calls inventory_lookup, confirms depletion, calls reorder_check, and returns a binary reorder decision.
  • Example 2: A procurement officer asks when a low-stock item can be replenished; the agent calls reorder_check, calls supplier_lead_time, and returns a replenishment recommendation.
  • Example 3: A store associate asks for the current stock count of a single product; the agent calls inventory_lookup and returns a scalar quantity.
  • Example 4: A store associate asks for the current stock count of a single product; the agent calls inventory_lookup and returns a structured status object containing the quantity and a restocking flag.
  • Example 5: A store associate asks whether a forecasted shortfall requires immediate action; the agent calls inventory_lookup, compares against minimums, calls reorder_check, and returns a binary reorder decision.
  • Example 6: A logistics coordinator asks how long a specific supplier takes to fulfill an order; the agent calls supplier_lead_time and returns a scalar lead-time value.

Which example should the engineer omit to preserve the token budget while maximizing behavioral coverage?

Explanation

The remaining budget is 4,096 − 1,800 − 1,000 = 1,296 tokens, enough for five examples at approximately 250 tokens each. Example 3 shares its user role, request, and inventory_lookup path with Example 4, which also returns the quantity alongside a restocking flag. Excluding Example 3 therefore preserves more distinct tool paths and scenarios, although it removes the scalar stock-count output example. Few-shot examples can guide both response content and format, so the best selection ultimately depends on whether that scalar format is required. (docs.databricks.com)

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!