Skip to content

openai-on-aws/prompt-optimizer

v0.2.2MIT-0

Compare invoice extraction or support-ticket triage with one fixed prompt on two models, locally or in AgentCore, and inspect quality, cost and latency.

Prompt Optimizer

Compare two models on a customer workflow with one fixed prompt, then inspect quality, model cost and latency in an HTML dashboard. Start with invoice extraction or support-ticket triage. Run the evaluator on your laptop or in Amazon Bedrock AgentCore using the same prepared study.

Codex guides the setup and asks what the evidence needs to prove. You choose which errors matter, what a correct answer looks like and whether the result justifies a model change.

Prompt Optimizer evaluation flow through AgentCore, Bedrock and S3

One reusable evaluation workflow. Prepare your inputs and fixed prompt, run the study locally or on AgentCore, then explore the saved evidence in a browser. The cloud path above applies to any supported structured-output workflow. Open the editable AWS diagram and six numbered steps.

Follow these six steps:

  1. Install and verify the plugin, then open a new session.
  2. Choose a starter, or bring your own evaluation records.
  3. Agree what the study should measure.
  4. Choose local, AgentCore, or both.
  5. Review the preview, then run.
  6. Inspect the evidence and decide.

For a first look without model calls, complete steps 1–2 using the recorded demo, then go straight to step 6. Fresh studies use all six steps.

Start hereWhat you getWhat you need
Explore the invoice demoInteractive results from a recorded local and AgentCore run, plus an AWS architecture diagramPython; no credentials or new model calls
Prepare a starterInputs, expected answers, a request preview and a reproducible study planPython 3.12 and plugin dependencies; no live AWS calls during preparation
Run locallyFresh model answers and a decision dashboardModel access, verified prices and authorization for model calls; no AgentCore deployment
Run on AgentCoreCloud coordinator and workers, durable artifacts and a downloaded dashboardModel access plus a matching AgentCore runtime, IAM role and private S3 bucket

1. Install in Codex

1.1. Add or refresh the marketplace

For a first installation, add the feature-branch marketplace:

codex plugin marketplace add openai-on-aws/benchmarks-openai --ref feature/customer-eval-plugin

If this marketplace already uses the feature branch, refresh it instead:

codex plugin marketplace upgrade openai-on-aws

If openai-on-aws is already registered from main, Codex rejects a second source with the same marketplace name. Switch the registration first:

codex plugin marketplace remove openai-on-aws
codex plugin marketplace add openai-on-aws/benchmarks-openai --ref feature/customer-eval-plugin

This changes the marketplace source; existing installed plugin caches and settings are separate. After merge, the default branch can be used. This repository marketplace is separate from the universal plugin directory.

1.2. Install and verify

codex plugin add prompt-optimizer@openai-on-aws
codex plugin list --marketplace openai-on-aws --json

Check that installed contains prompt-optimizer@openai-on-aws with installed: true and enabled: true. A marketplace registration by itself does not install the plugin.

1.3. Open a new session

Open a new Codex app chat in your workspace and choose Evaluate Workflows, or start the CLI:

mkdir -p ~/prompt-optimizer-work
codex -C ~/prompt-optimizer-work

You can also install Prompt Optimizer from OpenAI on AWS in Codex's plugin directory. The numbered new-session quickstart includes copyable prompts and a terminal-only demo.

Updating a preview installed under the former name

Refresh the catalog and install the renamed plugin:

codex plugin marketplace upgrade openai-on-aws
codex plugin add prompt-optimizer@openai-on-aws

After Prompt Optimizer works in a new chat, remove the old cached preview with codex plugin remove customer-eval@openai-on-aws. Your study directories and reports remain in your workspace, outside the plugin cache.

2. Choose a starter

Use caseExample decisionIncluded material
Invoice extractionCan a different model extract invoice fields at acceptable quality, cost and latency?Recorded interactive comparison, per-case answers, cost/latency charts, AWS diagram; reusable OCR-text logs in engine/examples/log-replay/logs/
Support-ticket triageCan a model assign the right category, priority, queue and human-review flag?60 synthetic tickets, a fixed triage policy, expected JSON answers and a decision template; no recorded live results

For the quickest first look, ask Codex:

Use Prompt Optimizer to open the recorded invoice comparison and AWS diagram. Explain what the results establish, and ask me which errors would matter in my own workflow.

To prepare the new example, ask:

Use Prompt Optimizer to start the support-ticket triage example. Show me the policy and ambiguous cases, and help me challenge the expected answers. Prepare a local study first; stop before paid model calls.

Both starters use the same skill and entrypoint. The triage example evaluates routing decisions; it does not create tickets or call a support platform. The invoice example starts with OCR text; it does not extract text from PDFs.

3. Agree what the study should measure

The skill inspects your records, explains exclusions and preserves the chosen prompt. It asks for decisions in small steps:

  • Which two model routes should be compared, and who owns the study?
  • Which fields determine success? Should a wrong priority count differently from an unnecessary human review?
  • Are the expected answers independently reviewed, synthetic, or historical model outputs? What evidence would change your mind about them?
  • How many distinct cases and repetitions are useful? What cost and latency tradeoffs would justify switching models?

The default keeps the prompt fixed and needs two models only. It does not require a third optimizer model. Synthetic labels remain marked unreviewed; matching them is not proof of production accuracy.

4. Choose local, AgentCore, or both

The workflow asks about infrastructure only if you choose AgentCore. Before freezing the study, it establishes whether you already have a matching runtime and bucket, or want help creating them in your chosen AWS account and Region.

ResourcePurposeWhen needed
Amazon Bedrock model access and credential referencesInvoke the selected modelsFresh local and cloud runs using Bedrock
AgentCore RuntimeHost the coordinator and worker sessionsCloud runs
Scoped IAM execution roleGive the runtime access to models, artifacts and worker invocationCloud runs
Private S3 artifact bucketStore frozen inputs, checkpoints and reportsCloud runs
CloudWatch LogsInspect runtime execution logsCloud runs

Installing the plugin, opening a demo and preparing a draft do not deploy resources. The run command also does not provision missing infrastructure. The skill guides the separate AgentCore setup when needed, using your existing authorization or obtaining it for the concrete deployment. Model calls and infrastructure have separate charges.

A matching deployment can be reused across both starters and later studies; you do not need a new runtime for each run. An engine update requires a matching runtime update. Cloud references must be set before prepare. If you later add AgentCore to an already frozen local study, create a new study revision.

5. Review the preview, then run

5.1. Prepare the study

For fresh studies, Codex creates a Python 3.12 environment and project in your workspace, outside the installed plugin cache. It uses a copy of the connection template for model IDs, endpoints, AWS profile references and verified prices, including their source, verification date and priced context bound. Never place credential values in it.

5.2. Review the frozen plan

Review input-preview.html, the expected answers and the plan's case counts, repetitions and budget before paid execution. Resolve any input, model or deployment changes in a new study revision before proceeding.

5.3. Run the chosen backend

Use your existing authorization or authorize the reviewed live run. run --backend local --live runs local workers; run --backend agentcore --live uses your deployed runtime. AgentCore also makes two model calls to qualify the source and target routes.

The support-ticket guide provides copyable preparation and execution commands. The workflow reference covers custom invoice logs, connection settings and the common commands: start, inspect, configure, prepare, plan, run, status, results and dashboard.

6. Inspect the evidence and decide what to do next

6.1. Retrieve the existing results

Open the returned decision.html for quality checks, per-case failures, model cost, timing and prompt evidence. Each backend produces its own report:

  • Local: <project>/local/decision.html and report.json.
  • AgentCore: <project>/results/decision.html and report.json after retrieval.

status and results inspect the existing job; they do not submit another study. Add --backend local to inspect local evidence.

6.2. Build and open the dashboard

Build an interactive dashboard from either backend, or compare both after retrieving their results into the same project:

python3 /absolute/plugin/scripts/invoice_eval.py dashboard \
  --project /absolute/workspace/my-study \
  --output /absolute/workspace/my-study/dashboard.html

Open the returned HTML file directly in a browser. It has three views:

  • Overview: backend filters, quality checks, cost/latency tradeoffs and the exact comparison table.
  • Trial explorer: search inputs and outputs by case, filter check failures, inspect answers and request receipts, and export filtered evidence.
  • Run integrity: completion, unresolved attempts, price coverage, fingerprints and the frozen prompt.

Preview the results workspace using the recorded example

Prompt Optimizer dashboard showing recorded model cost, latency and quality evidence

Day and night views combine OpenAI-inspired monochrome surfaces, AWS orange and Squid Ink accents, and embedded Open Sans from AWS's Cloudscape design system. Headings use OpenAI Sans if it is installed locally; Open Sans is the offline fallback. Typography sources and font licences.

The dashboard renders saved report.json data in the browser, works offline and needs only Python's standard library to build. It reads a single report directory, or the local/, agentcore/ and results/ report locations within a project. Combined reports must have matching input fingerprints and one report per backend.

This is an interactive snapshot, not a live AWS monitoring service. Run results to retrieve cloud evidence, then rebuild with --force to refresh an existing dashboard. Rendering makes no AWS or model calls. The HTML and exports contain recorded inputs and outputs; share them as evaluation data.

6.3. Decide what the evidence supports

A useful conclusion may be that the data is too easy or the labels need review. Do not choose a winner just because one chart looks better. Repetitions are not additional independent customer cases; sequential local/cloud runs do not isolate hosting overhead. Missing usage stays unknown, and reported model cost excludes infrastructure and human review.

Try the recorded dashboard from a terminal

This is an alternative to using Codex's installed skill. Follow these three steps; none makes model or AWS calls.

T1. Get the repository

git clone --branch feature/customer-eval-plugin https://github.com/openai-on-aws/benchmarks-openai.git
cd benchmarks-openai

T2. Copy the recorded demo

python3 plugins/prompt-optimizer/scripts/invoice_eval.py demo --output invoice-demo

T3. Open and review the dashboard

Open invoice-demo/dashboard.html for the interactive results workspace. The original invoice-demo/index.html remains available with its detailed historical narrative and AWS diagram. The demo uses only Python's standard library and makes no AWS or model calls.

These are the recorded 13 November 2026 live measurements: 96 evaluation trials and two route checks per backend, with a combined estimated model cost of $0.71, excluding infrastructure. Both models matched every synthetic, unreviewed reference. That leaves substantial uncertainty about quality on harder, real invoices. See the recorded evidence.

Development and scope

prompt-optimizer/
├── plugin.json                 Portable plugin identity
├── .codex-plugin/plugin.json   Codex presentation and skill discovery
├── skills/evaluate-invoices/   One shared workflow (stable skill identifier)
├── scripts/invoice_eval.py     One entrypoint for both starters and backends
├── engine/                    Bundled evaluator and AWS runtime
├── examples/                  Recorded invoice report and triage starter
├── docs/                      Deployment and editable AWS architecture
└── tests/                     Installed-package and workflow checks

Live workflows support Python 3.12 on macOS or Linux. The bundled engine retains broader Codex, Strands, Gateway and optimization capabilities for compatibility; these are not required by the two public starters.

Install requirements-test.txt in an isolated environment, then run from the repository root:

python -m unittest discover -s plugins/prompt-optimizer/tests -v
python -m pytest -q plugins/prompt-optimizer/engine/tests \
  plugins/prompt-optimizer/engine/intake/tests

Tests use local fixtures and loopback protocol servers, without live model calls or AWS deployments. Package tests copy the plugin into an isolated cache and invoke it from another directory.

The plugin is MIT-0, with an included MIT-0 importer. Upstream provenance records the source and integration changes.