AWS Builder Center
Building a latency-tiered agentic race analysis system for Formula 1 data with Amazon Bedrock

Building a latency-tiered agentic race analysis system for Formula 1 data with Amazon Bedrock

Part 1 of a two-part series. Part 2 turns this engine into an interactive f1 race-intelligence dashboard and deploys it on AWS App Runner.

Series: F1 Agentic Intelligence Engine (3 articles)

  1. 1
    Building a latency-tiered agentic race analysis system for Formula 1 data with Amazon Bedrock This article
Senior Solutions Architect | AWS AI Hero | OSS: Strands - robots, harness-sdk, decider, stan, box

Part 1: Building a latency-tiered agentic race analysis system for Formula 1 data with Amazon Bedrock

Companion repository:  https://github.com/Vivek0712/f1-agentic-analysis  . All results in this post are computed from public historical race data and are reproducible from the repository.
About the author: Vivek Raja P S is an AWS AI Hero, a lifelong Sebastian Vettel and Fernando Alonso fan, currently supporting Ferrari and Max.


Formula 1 is the most instrumented sport in the world: each car carries 300+ sensors producing over a million telemetry data points per second, and the sport has run its analytics on AWS since 2018. The 2026 season has pushed the paddock further, with multiple teams announcing production AI partnerships and the FIA itself exploring AI-assisted rule enforcement.
This post takes a deliberately narrow position inside that momentum. Large language model agents are the wrong tool for the pit call itself. The decision to box resolves in sub-second time against precomputed Monte Carlo strategy trees, and an agent adds latency and non-determinism to a path that tolerates neither. Agents earn their place in three slower loops where the scarce resource is engineer attention: explaining anomalies during the race, producing debriefs after it, and synthesizing patterns across a season. We show how to build that system on Amazon Bedrock, with a deterministic analysis layer that computes every number and a fleet of seven narrow agents that are only allowed to reason about numbers the deterministic layer produced.

Solution overview

The architecture separates three concerns.
Deterministic layer. A Python analysis package (pandas/SciPy, one Fargate task per session in deployment) computes stint segmentation, fuel-corrected tyre degradation fits, circuit pit loss, realized undercut swings, degradation anomalies, and counterfactual pit-lap curves. This layer is unit-tested and versioned; the repository carries sixteen tests, ten of them on this layer alone.
Agent layer. Seven agents built with the Strands Agents SDK on Amazon Bedrock (Anthropic Claude: Haiku for the slow loop, Sonnet for the deeper tiers), each defined entirely by a system prompt and a payload contract. Agents receive structured JSON from the deterministic layer and return short briefs. Each agent is constructed with an empty toolset, so there is no path to raw telemetry from inside the model loop. The slow-loop agents deploy as one app on Amazon Bedrock AgentCore Runtime; the post-session and cross-season tiers reuse the same prompts as Amazon Bedrock batch inference records. This payload-in/brief-out contract is the central design decision: it makes groundedness checkable, because every claim in a brief must trace to a number in the payload.
Governance layer. A deterministic compliance rules engine validates every recommendation before a human sees it (compound rules, pit window bounds, stint life limits, and an advisory-only rule under which any recommendation flagged for automatic execution fails closed). Verdicts are written to immutable audit records carrying the payload hash, model ID, and ruleset version. The Compliance Guardian agent explains failures in plain language; it has no authority to pass or overturn anything.

Figure 1: The deterministic layer computes every number; agents in three latency tiers consume fitted parameters through the payload contract; the governance layer gates and audits every recommendation.
Agent work routes into three latency tiers:
Tier
Trigger
Bedrock runtime
Agents
slow_loop
Amazon EventBridge, 60s cadence during a session
Strands Agents on Amazon Bedrock AgentCore Runtime, with AgentCore Memory
Stint Analyst, Rival Watcher, Deg Explainer, Compliance Guardian
post_session
AWS Step Functions on session end
Amazon Bedrock batch inference
Driver Coach, Race Reporter
cross_season
Scheduled batch
Amazon Bedrock batch inference
Track Historian
Live timing enters through Amazon Kinesis Data Streams into an Amazon S3 telemetry lake cataloged with AWS Glue and queried with Amazon Athena. The published results use the offline path: historical lap and pit stop data in the Ergast schema, which keeps the demo fully reproducible without a rights agreement.

The deterministic layer does the math

Three methods carry most of the analytical weight.
Fuel-corrected degradation fits. Historical lap data carries no tyre compound labels, so degradation is computed as a pace-decay proxy: a field fuel-burn slope is estimated per race from clean-lap medians, subtracted from each lap, and a robust Theil-Sen line is fitted per stint against tyre age. The fit returns base pace, a degradation slope with a confidence interval, and a residual IQR that doubles as a traffic-exposure signal. Robust estimation matters here; a single out-of-position lap bends an ordinary least squares slope badly.
Undercut measurement. For each pit stop, rivals within four seconds on track at the in-lap who respond within five laps form a pit battle. The gap swing is measured once both cars are on settled tyres. This is descriptive measurement of realized outcomes, not causal inference, and the Rival Watcher's prompt requires it to keep that distinction.
Counterfactual pit curves. With two fitted stint models per driver, the pit boundary can be shifted and the race time re-priced lap by lap under stated assumptions: fixed pit loss, linear per-stint degradation, no traffic or safety car interaction. The Race Reporter is required by its prompt to state those assumptions in one clause whenever it cites a counterfactual.

Results on the 2024 Spanish Grand Prix

Running the pipeline on real lap data from the 2024 Spanish Grand Prix (66 laps, 20 drivers, 62 fitted stint models):

Figure 2: The race as the deterministic layer sees it. Vertical drops across pit cycles are the undercut swings measured in the ledger.
  • Pit loss measured 22.61s (median over 42 stops, IQR 2.24s), and the undercut dominated: 18 pit battles resolved in the data with swings of 10-16 seconds per cycle. Lewis Hamilton's lap 16 stop swung 15.87s against Oscar Piastri's lap 21 response; he repeated the move on Charles Leclerc late in the race for 10.54s.

  • Figure 3: The twelve largest realized swings of 18 measured pit battles, against the 22.61s measured pit loss.
  • The counterfactual model priced Max Verstappen's first stop (lap 17) within 0.06s of its optimum. Lando Norris, running the race's best tyre life at 0.063 s/lap corrected decay, stopped on lap 23; the same model prices lap 17 at 4.38s of race time. Norris finished 2.22s behind. Under the model's stated assumptions, the win was live at the first stop, which matches the post-race consensus around McLaren's timing.

  • Figure 4: Modeled race-time delta against first pit lap. Verstappen's actual stop sits on the curve minimum; Norris's optimum was six laps before his actual stop.
  • The anomaly desk flagged Valtteri Bottas's second stint at 0.275 s/lap decay (robust z = 4.79 against a 0.069 field median). His own adjacent stints and his teammate's parallel stint were normal, which the Deg Explainer used to rank a set-specific problem above a car-side cause, consistent with his early lap 28 stop.

Figure 5: 62 fitted stint slopes. Flags are robust-z outliers; the Bottas stint is the payload the Deg Explainer receives.
The repository dashboard renders all of this as a timing-screen console: the gap-to-leader trace with pit markers, the counterfactual curve, the undercut ledger, and each agent's brief next to the numbers it was given. Part 2 of this series makes that console interactive: season, race, session, and driver selection, on-demand generation with an S3 output cache, a championship predictor, and deployment on AWS App Runner.

The agent contract, and how it is evaluated

Agent
Tier
Payload in
Brief out
Stint Analyst
slow_loop
stint fits, fuel slope, pit loss
150-word pace and deg briefing
Rival Watcher
slow_loop
undercut events, pit loss
threat assessment
Deg Explainer
slow_loop
anomaly record, context stints
ranked hypotheses, each with confirming data
Compliance Guardian
slow_loop
audit record
violation explanation, smallest legal fix
Driver Coach
post_session
driver metrics vs references
one strength, one cost, one focus
Race Reporter
post_session
full output set, session summary from Memory
strategy narrative
Track Historian
cross_season
25-circuit feature profiles
archetype placement, transfer notes
Each agent is roughly 150 words of system prompt. The Stint Analyst's rules are representative: every claim must quote a payload number, weak fits must be flagged as weak, output is advisory and capped at 150 words. The full prompts ship in the repository and are the entire agent layer; there is no fine-tuning and no retrieval over raw telemetry. Retrieval invites ungrounded synthesis; the deterministic layer is the retrieval.
Continuity through AgentCore Memory. A brief that restates the race every 60 seconds wastes the one resource the slow loop exists to protect. Amazon Bedrock AgentCore Memory carries each agent's state between cadence ticks: before invocation, the runtime retrieves the agent's previous brief for the race session (get_last_k_turns with the agent as actor and the race session as session) and passes it beside the payload, so the Stint Analyst opens with what changed rather than what is. After invocation, the (payload, brief) pair is stored as an event, and a summary memory strategy rolls the session's briefs into a running strategic summary under /summaries/{actorId}/{sessionId}. The post-session tier retrieves that summary by semantic query and embeds it in the Race Reporter's payload, which is how in-race context reaches the post-race narrative without replaying the event stream. Raw memory events expire after 30 days; permanence belongs to the S3 Object Lock audit trail, deliberately outside Memory.
The contract makes evaluation mechanical. A groundedness check extracts every numeric claim from a brief and verifies it appears in the payload within rounding. A brief that cites a number the deterministic layer never computed is a defect regardless of how plausible it reads. This is a substantially stronger bar than generic LLM evaluation and it is only available because the payload boundary exists.
Scoring predictions against outcomes. Groundedness verifies that a brief only states computed numbers; a frozen-clock backtest verifies the numbers were worth stating. Every fit is recomputed as of lap N, its forward statements are scored on laps N+1 onward, and no quantity used for prediction sees post-freeze data. On the 2024 Spanish Grand Prix, both undercut calls open at the tested freeze points priced the realized full-cycle swing within 1.11 seconds, and degradation extrapolation improved from 1.20s MAE at lap 20 to 0.60s at lap 40. The early positive bias is itself a finding the agents now carry: fits younger than ten clean laps over-read tyre warmup as degradation, so their briefs mark those slopes as provisional. The repository also ships an OpenF1 adapter (api.openf1.org: free historical access from 2023, paid real-time tier, roughly 3 seconds behind the track) that emits the same schema, so the identical backtest runs against any race a few minutes after the flag.

Figure 6: The frozen-clock backtest. Degradation extrapolation error falls as fits mature, and both open undercut calls priced the realized swing within 1.11 seconds.
Freeze
Deg stints scored
Deg MAE
Deg bias
Open undercut calls
Swing abs error
Lap 20
8
1.20s
+0.74s
1 (HAM vs PIA)
1.11s
Lap 30
15
0.76s
+0.57s
0
-
Lap 40
9
0.60s
+0.10s
1 (STR vs RIC)
1.10s
For batch tiers, the pipeline emits one JSONL record per agent invocation in the  CreateModelInvocationJob  input format, so a full-season re-analysis (24 races, seven agents plus per-anomaly triggers) runs as a single Amazon Bedrock batch inference job at the 50 percent batch discount. Order of magnitude: the slow loop costs single-digit dollars per session at Sonnet-class pricing, a season re-analysis lands in the low hundreds, and the deterministic layer is a rounding error on Fargate.

Prerequisites and walkthrough

To reproduce: Python 3.11+, and for live agent runs an AWS account with Amazon Bedrock model access to Anthropic Claude Sonnet.
git clone https://github.com/Vivek0712/f1-agentic-analysis && cd f1-agentic-analysis
./scripts/fetch_data.sh
pip install -r requirements.txt
cd src && python -m f1agents.pipeline.run_race_analysis --year 2024 --race Spanish
cd .. && python scripts/build_dashboard.py
python scripts/build_figures.py
pytest tests/ -q
To deploy the slow loop on AgentCore Runtime with Memory:
pip install strands-agents bedrock-agentcore bedrock-agentcore-starter-toolkit
python scripts/create_memory.py # prints MEMORY_ID, export it
agentcore configure -e src/f1agents/agents/agentcore_app.py
agentcore launch
The pipeline writes  results.json  (every number in this post),  batch_input.jsonl  (the Bedrock batch manifest), and the dashboard build injects both into a standalone HTML console. Adding  --invoke  calls Bedrock Converse per agent against your account.

Cleanup

The offline path creates no AWS resources. For live runs, delete the batch inference job outputs from your S3 bucket and any AgentCore Runtime resources you provisioned.

Conclusion

The transferable pattern here is not specific to motorsport. Any domain with a fast deterministic decision core and a human attention bottleneck around it (payments operations, grid management, clinical monitoring) fits the same shape: keep the LLM off the fast path, feed it fitted parameters rather than raw data, gate it with deterministic rules, and audit every brief immutably. The agents become cheap, evaluable, and safe to put in front of an operator precisely because they are narrow.
The full implementation, prompts, tests, results, and dashboard are in the companion repository under an MIT license.

Series: F1 Agentic Intelligence Engine (3 articles)

  1. 1
    Building a latency-tiered agentic race analysis system for Formula 1 data with Amazon Bedrock This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article