Prompt engineering is the deliberate revision of instructions and context given to a language model. It is useful when a generative chatbot needs to follow a conversation plan, but a well-written prompt is not a guarantee: the model may ignore an instruction, invent dialogue, or give a wrong answer. section 12.5.2
Keeping a tutor chatbot to one turn
Consider a math tutor that must establish whether it is speaking with a parent or a student and obtain a parent's permission before continuing over WhatsApp. An initial prompt describes that sequence and asks for the tutor's next response. The model nevertheless writes several turns ahead, including a parent's reply. A revision makes the boundary explicit: provide only one response, no more than one or two sentences, and proceed only after explicit permission. Tested replies then ask for permission and wait for the parent's answer. section 12.5.2
>>> onboarding_pt = """
This is a conversation between a math tutor chatbot Rori
and a user who might be a student in Africa or a parent.
The chatbot introduces itself and asks if it's talking
to a student or a parent.
If the user is a parent, Rori asks the parent for
permission for their child to use Rori over Whatsapp.
If the user is a student, Rori asks the student to call
their parents.
Only if the parent gives explicit permission, Rori
thanks them and asks to give the phone to the student.
Provide the tutor's next response based on the conversation history.
Provide only one response.
Do not return more than one or two sentences.
{history}
user:{input}
tutor:
"""
Inspect the revised prompt template: it combines the conversation rules, response-length constraints, conversation history, and the latest user input. section 12.5.2
Test the prompt against actual exchanges, not just its intended wording. In a number-sequence quiz, the tutor praises “12” as correct while also saying the next number after 2, 4, 6, 8 is 10. That contradiction makes prompt revision alone a poor substitute for checking answers. section 12.5.2
Prompts also have to contend with each model's quirks and guardrails, and users can phrase requests in unanticipated ways. For decisions such as choosing which model should receive a request, a semantic router can instead classify prompts using examples of requests that worked well. This separates a discrete routing decision from the generative model's claim that it can handle any request with the right prompt. section 10.1.3





































