An assembly function constructs the context supplied to a model before generation. Rather than treating a prompt as a static string, it selects and organizes instructions, knowledge, tools, memory, state, and the current request into a structured runtime artifact. section 12.1.1
The assembly function A maps six context sources to the final context C. section 12.1.1
The six sources play different roles:
- Instructions define behavior, constraints, and role expectations; the query expresses the immediate request. section 12.1.1
- Knowledge supplies external information; tool definitions expose actions and schemas. section 12.1.1
- Memory carries information from previous interactions or long-term stores; state represents the current workflow, environment, or application. section 12.1.1
Assembly is more than concatenation. It determines which sources enter the context, their token budgets, ordering and delimiters, how structured data is verbalized, and how conflicts are handled. A simple implementation might place instructions first, followed by retrieved passages, tool definitions, and the request. A more sophisticated one may use routing, ranking, summarization, schema generation, validation, and feedback from previous runs. section 12.1.1
Return eligibility
A support agent evaluates a return requested 40 days after purchase while a ticket is active. Its context combines operator instructions, retrieved return-policy passages, an order-lookup tool schema, the customer's plan tier, ticket state, and the request. Because the full policy and ticket history exceed the budget, retrieval selects the 30-day rule and premium-plan exception, while compression reduces the ticket history. If the summary drops the plan tier, the agent can incorrectly deny a return allowed by the exception. section 12.1.6
Token accounting can show how much each source contributes to a call; trace spans in Langfuse or LangSmith provide practical instrumentation. Such measurements approximate properties of the context pipeline rather than directly computing its formal quantities. section 12.1.6
