The prompt regression test suite every agent engineering team maintains
Installs an automated test harness that runs every prompt change against fixed input sets and halts merges on output drift.
Tool setup checklist
Clone your agent repo and install pytest plus the langchain evaluators package. Point the test runner at your LangGraph state machine entry point. Store the golden input-output pairs in a json file under tests/agent_prompts. Run the suite locally once to confirm it executes in under four minutes.
Create a dedicated service account in your GitHub organization with read access to the agent repo and write access only to the test results bucket in S3. Configure the pytest command to output both JSON logs and similarity scores computed via langchain evaluators cosine similarity on embeddings from the text-embedding-ada-002 model. Schedule a weekly cron job inside the repo that refreshes the local golden set by replaying the five production scenarios against the live LangGraph endpoint and stores any new outputs only after manual approval by the engineering lead.
The play, step by step
- Engineering lead adds the test job to the GitHub Actions workflow so every pull request that touches a prompt file triggers it.
- Prompt author updates the system or user prompt file and pushes the branch.
- CI runs the regression suite against the five golden scenarios stored in tests/agent_prompts/golden.json.
- If any output deviates beyond the 0.05 similarity threshold the job fails and blocks merge.
- On failure the author opens a ticket in ServiceNow tagged agent-prompt-regression and attaches the diff.
- Senior engineer reviews the change and either updates the golden file with sign-off or reverts the prompt.
- Merge only occurs after the job passes and the ticket is closed.
Each step names concrete artifacts: the GitHub Actions workflow file at .github/workflows/prompt-regression.yml, the golden.json file with exact input strings and expected embedding vectors, and the ServiceNow ticket template that auto-populates the changed prompt diff.
Workflow diagram
flowchart TD
A["Update prompt file"] --> B["Trigger GitHub Actions"]
B --> C["Run pytest suite"]
C --> D{"Similarity below 0.05?"}
D -->|Yes| E["Fail job and block merge"]
D -->|No| F["Close ticket in ServiceNow"]
E --> G["Open ServiceNow ticket"]
G --> H["Senior engineer reviews"]
H --> I["Update golden or revert"]
I --> F
When to run this play
Execute this play on every pull request that modifies any prompt file or LangGraph node logic. Also run it after any dependency update to langchain or openai packages.
Set the trigger in the GitHub Actions workflow to watch paths tests/agent_prompts/ and langgraph/nodes/.py. After a langchain version bump from 0.1.4 to 0.1.5, the play must run within the same business day using the exact five golden inputs to verify that embedding drift stays under the 0.05 threshold.
Watch-outs
If the similarity threshold produces false positives on valid rephrasings, pause the play and raise the threshold in a documented change request. If the test job exceeds ten minutes, stop and escalate to the platform team for parallel execution. Never bypass the gate for time pressure; route urgent changes through the human-veto path instead.
Track false-positive incidents in a shared dashboard inside ServiceNow. When three consecutive failures occur on rephrasings that preserve intent, the senior engineer must file a change request to adjust the threshold or swap the evaluator model before the next merge window opens.
Your first week
Run the initial suite against the current production prompts and store the outputs as the first golden set.