Lesson 2 of 4 Advanced Prompt Engineering for Agents

Managing the Prompt Lifecycle

This lesson describes how prompt lifecycle management applies software release discipline to prompts, which in a multi-agent system determine behaviour as much as code does, and the Foundry features that support it.

Learning outcomes

After completing this lesson, you will be able to:

  • Store prompts as versioned assets.
  • Describe the stages of a prompt change.
  • Use contracts between agents' prompts to prevent downstream breakage.

Prompts as versioned assets

Prompts are stored in source control, not edited in a portal in production. Common formats are plain template files, Prompty files (a Markdown format with YAML front matter that records the model, parameters and inputs) and agent definition files (YAML or JSON) deployed by the pipeline. Foundry Agent Service creates a new agent version every time an agent's definition changes, which gives a history and a target for rollback.

True or false

Prompts as assets

Exam skills 2.1.1

Check how prompts are stored and versioned.

Log in to try this activity Interactive activities are free with an account.

Lifecycle stages

A prompt change moves through the stages below, each with a clear owner and evidence.

  • Author: write or edit the prompt in a branch, with the reason for the change.
  • Review: a pull request reviewed by an engineer and, for behaviour changes, a domain owner.
  • Evaluate: run the regression dataset and evaluators; compare with the current version.
  • Release: deploy through environments (development, test, acceptance, production), optionally as a canary.
  • Monitor: compare production metrics and continuous evaluation scores with the previous version.
  • Roll back or retire: restore the previous version when metrics regress; remove unused prompts.
Put in order

A prompt change from idea to retirement

Exam skills 2.1.1

Arrange the lifecycle stages of a prompt change.

Log in to try this activity Interactive activities are free with an account.

Coupling between agents' prompts

In multi-agent systems, an agent's output is another agent's input. Changing the triage agent's output format can break the specialist that parses it. Contracts between agents are therefore defined as structured output schemas, and evaluations test the whole workflow, not only the changed agent. Prompt versions of agents that depend on each other are released together or kept backward compatible.

The following table compares ad hoc and managed prompt handling.

Ad hoc
StorageEdited in code or portal
Quality checkManual spot checks
ReleaseImmediate to production
RollbackRewrite from memory
Managed lifecycle
StorageVersioned files and agent versions
Quality checkRegression dataset and evaluators
ReleasePromoted through environments, canary optional
RollbackRedeploy the previous version
Scenario questions

Prompts that depend on each other

Exam skills 2.1.1 · 2.1.2

Protect downstream agents when one agent's prompt changes.

Log in to try this activity Interactive activities are free with an account.
Worked example

A silent regression

A product manager edited a summarization agent's instructions in the portal to make summaries shorter. The next day, the downstream escalation agent stopped escalating urgent cases, because the shorter summaries omitted the urgency field it relied on.

Prompts should be changed through source control and the pipeline, with an output schema that makes the urgency field mandatory and a workflow-level regression evaluation that includes urgent cases. The previous agent version is redeployed immediately as the rollback.

Check yourself

What should happen before a prompt change is released?

Show answer

It should be evaluated on a regression dataset, with the prompt versioned in source control so it can be rolled back.

Exam Tips

Remember for the exam

  • Version prompts in source control; Foundry agent versions support rollback.
  • Evaluate every prompt change on a regression dataset before release.
  • Use structured schemas as contracts between agents.