liveBook · Manning

Prompt

As explained in Machine Learning Platform Engineering

A system prompt is an instruction supplied to a language model to establish its role, behavioral constraints, and response requirements.

A system prompt sets an LLM application’s role, response requirements, and behavioral boundaries. In a documentation assistant, it tells the model to answer from retrieved documents, state when information is missing, and use a consistent format. These instructions help standardize responses, but they are not a substitute for input validation or application-level error handling. section 13.1.1 section 12.3

Specify the rules that matter to the application:

  • Role and scope: identify the intended audience and limit answers to documented features. section 13.1.1
  • Uncertainty and safety: prohibit speculation and disclosure of credentials or internal instructions; say when the documentation lacks an answer. section 13.1.1 section 12.3
  • Output: require a direct answer, relevant steps or code, and source citations in a predictable format. section 13.1.1
  • Runtime context: provide retrieved documentation, the user’s question, and relevant session or environment information. section 13.1.1

From a vague instruction to an operational prompt

“You are a helpful assistant that answers questions about company documentation” leaves scope, uncertainty, and output format unspecified. A more useful documentation-assistant prompt defines a technical audience, restricts answers to provided context, redirects out-of-scope questions, and requires document-and-section citations. section 13.1.1

In a retrieval-augmented application, format retrieved documents consistently before inserting them into the prompt. Numbered documents and source metadata make the context easier to interpret and support citations in the response. Return sources and errors as structured results so the interface can display them separately from answer text. section 12.3

Listing 13.1 Creating managed prompts in Langfuse with versioning
langfuse.create_prompt(
    name="dakkabot-system",  #1
    type="chat",  #2
    prompt=[
        {
            "role": "system",
            "content": """You are DakkaBot, DataKrypt's expert 
developer assistant. Based on the provided DataKrypt documentation, 
answer the user's question accurately and helpfully.

            **Documentation Context:**
            {{context}}

            **User Question:** {{query}}

            **Instructions:**
            - Provide accurate, detailed answers based on the documentation
            - Include specific steps, code examples, or configurations 
            when relevant
            - If the question requires multiple services or 
            procedures, explain the complete workflow
            - Use proper formatting for code blocks and lists
            - If you're not sure about something, say so rather than guessing
            - Stay focused on DataKrypt-specific information

            **Answer:**"""
        }
    ],
    labels=["production"],  #3
    config={
        "model": "gemini-2.5-flash",
        "temperature": 0.0,
        "max_tokens": 1000
    },  #4
    tags=["dakkabot", "rag", "documentation"]  #5
)

The managed chat-prompt listing shows a system-role message with {{context}} and {{query}} placeholders, keeping task instructions together while supplying retrieval results and the question at runtime. section 13.1.2

Treat production prompts as versioned application logic rather than hardcoded strings. Langfuse can store a prompt by name, label versions for environments, and attach model configuration. The application fetches the selected version, compiles its runtime variables, and records the version with the response. This permits prompt updates without redeploying application code and makes changes traceable. section 13.1 section 13.1.2

How Machine Learning Platform Engineering covers it

How deep it goes
Develops five prompt functions, contrasts a vague baseline with explicit rules, and shows managed-template integration.
Examples
Contrasts a generic documentation-assistant instruction with a scoped prompt and creates a templated Langfuse chat prompt.
What you can do after
Apply it via Langfuse to version, fetch, compile, and track a documentation assistant’s system prompt.
How it connects
Connects system prompts to retrieval-augmented generation, guardrails, source attribution, prompt versioning, and response observability.

Also explained in

Compare how 50 books explain prompt →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.