Cut Costs and Boost Accuracy in Flight‑Change Processing with Amazon Nova & Strands Agents
This article details a complete, production‑ready solution for extracting structured flight‑change information from multilingual, unstandardized airline emails using Amazon Nova, Strands Agents, and Amazon Bedrock AgentCore, covering architecture, prompt design, code implementation, model benchmarking, cost analysis, deployment, observability, and continuous evaluation.
Problem
Travel service providers receive large volumes of flight‑change notifications (delays, cancellations, schedule adjustments) via email, SMS, and APIs. The data is multilingual, uses many different HTML templates and time formats, and often contains multiple flight segments in a single message.
Manual handling, regex‑based rule engines, and custom machine‑learning models are costly, hard to scale, and difficult to maintain.
Solution
The system combines the Amazon Nova Pro model, the open‑source Strands Agents framework, and Amazon Bedrock AgentCore to parse airline emails into structured JSON.
Architecture
Amazon Nova Pro model : multilingual understanding, HTML parsing, JSON output; temperature and top‑p tuned for stable inference.
Strands Agents framework : orchestrates the model, tools, and prompts; decorators encapsulate complex logic (e.g., time‑format conversion) as reusable tool functions, reducing prompt token consumption.
Amazon Bedrock AgentCore : serverless runtime, isolated test/production endpoints, full‑stack observability via CloudWatch, and unsupervised result evaluation for a continuous parse‑evaluate‑optimize loop.
Deployment environment
All components run in the AWS us‑east‑1 region. A development/testing pipeline samples anonymized traffic from production, cleans and normalises the data, stores it in Amazon S3, and feeds it to the Agent for iterative prompt optimisation.
Prompt design
The prompt consists of four parts: role definition, input definition, parsing‑rule definition, and output definition. The system processes HTML email content and outputs a JSON array of flight‑change objects. Key extraction points include multi‑flight recognition, flight‑number normalisation, IATA airport‑code extraction, and uniform timestamp conversion to YYYY‑MM‑DD HH:mm:ss.
Extraction rules (example)
你是一个专业的航班信息提取助手。你的任务是从航空公司发出的航班变更通知HTML内容中提取结构化信息。
## 输入格式
- 当前时间(用于推断邮件中缺失的时间信息)
- HTML格式的航班变更通知邮件内容
- 可能包含多种语言(中文、英文等)
- 可能包含各种HTML标签和样式
## 提取规则
- **flightNumber**: 如 "E61234"
- **dep**: 如 "LGW"
- **arr**: 如 "KRK"
- **depDate**: YYYY‑MM‑DD HH:mm:ss
- **arrDate**: YYYY‑MM‑DD HH:mm:ss
- **pnr**: 如 "DFD27Y"Special airline rules
For airlines with unique formats (e.g., flight numbers starting with E4/E6/E9 or specific domain markers), a dedicated date‑conversion tool recognises US, European, three‑letter month, and full‑month formats.
Agent implementation steps
Model initialisation: configure Amazon Nova Pro 1.0 with temperature and top‑p.
Create Agent: inject the model, system prompt, and tools (e.g., example_date_converter).
Invoke Agent: pass the HTML email; the model decides when to call the tool.
Post‑processing: extract the JSON block from the model response using a regular expression.
Code samples
model = BedrockModel(
model_id=config.model_id,
temperature=config.model_temperature,
top_p=config.model_top_p,
)
def parse(content):
"""Parse flight‑change information from HTML content"""
with open("flight_change_prompt.md") as f:
system_prompt = f.read()
agent = Agent(
model,
tools=[example_date_converter],
system_prompt=system_prompt,
callback_handler=None,
)
current = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
result = agent(f"**当前时间:**{current}
**HTML内容:**```html{content}```")
match = re.search(r"```json(.*)```", str(result), re.DOTALL)
return match.group(1) @tool
def example_date_converter(date_str: str) -> str:
"""Convert various date formats to YYYY‑MM‑DD HH:mm:ss"""
# implementation omitted for brevityModel benchmark
Using the same dataset, three Amazon Nova models were evaluated on accuracy, latency, and output quality. Amazon Nova Pro 1.0 achieved the best balance and was selected for production. Inference temperature was set to 0.2 to reduce randomness.
Cost evaluation
For a week of sample data, Nova Pro 1.0 incurred 4,007 invocations, consuming 90.5 M input tokens and 516.3 K output tokens. At US‑East‑1 pricing (input $0.0008/1k tokens, output $0.0032/1k tokens), the average cost per call is $0.01848, yielding an estimated daily cost of $17.01 for ~920 calls.
Service quotas
Nova Pro 1.0’s default limits are 2 M TPM and 500 RPM. With an average of 22.6 K input tokens + 129 output tokens per call, the system can handle ~88 calls per minute; quotas can be increased via the Bedrock console.
Deployment & operations
AgentCore provides serverless hosting, test/production endpoint segregation, and full‑stack observability. Metrics captured in CloudWatch include invocation count, latency, token usage, and resource consumption. Tracing visualises each call’s execution path, aiding performance‑bottleneck identification.
Result evaluation
AgentCore’s unsupervised evaluation automatically scores parsed results and publishes the scores as CloudWatch metrics, creating a closed feedback loop for continuous improvement.
Conclusion
The architecture demonstrates a scalable, accurate, and maintainable flight‑change extraction system that can be extended to other domains such as hotel reservation changes, visa approvals, or customer‑service ticket classification.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Amazon Cloud Developers
Official technical community of Amazon Cloud. Shares practical AI/ML, big data, database, modern app development, IoT content, offers comprehensive learning resources, hosts regular developer events, and continuously empowers developers.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
