
Weekend Creative Agent Challenge: The Cartographer
The Cartographer is an always-on agent that wakes up every night, picks a random coordinate somewhere on Earth, asks Amazon Location Service what genuinely exists at that spot, and writes a short poem grounded strictly in those real facts.
There is a particular kind of disappointment in AI-generated art that I wanted to design my way out of.
You ask a model for "a misty coastal village at dawn," you get something competent and atmospheric, and then you notice it means nothing. It is not a place. Nobody has ever stood there. The image has the grammar of a landscape without any of the facts of one, and once you see that, you cannot unsee it in anything else the model makes.
So for this weekend's challenge I set myself a harder constraint than "make an agent that produces art." I wanted an agent whose creative output was anchored to something real that I did not choose — a place that actually exists, with a name somebody uses, weather that was genuinely happening at the moment of writing, and things nearby that a person who lives there would recognise. Then I wanted to hand those facts to a language model and let it do only the part it is genuinely good at: finding the language.
The result is The Cartographer. Every night it surveys one point on Earth, and by morning there is a new page in the atlas. I never open it to make that happen. That was the whole point of the brief — the best tool is the one you never have to open.

Vision & What It Does
The Cartographer treats the surface of the planet as an inexhaustible source of specificity. Roughly 30% of it is land, most of that land has been named by somebody, and almost none of it has ever had a poem written about it.
Each night the agent runs one survey:
- It samples a random coordinate inside weighted continental land boxes.
- It asks Amazon Location Service to reverse-geocode that point, and only accepts the result if it resolves to a genuinely named place — a locality or street — within 15 km. Ocean, ice cap, and unnamed desert picks are discarded and resampled.
- It asks Location Service what points of interest are actually nearby, widening the radius from 2 km to 10 km to 30 km when a rural coordinate has nothing close.
- It fetches the live weather at that exact spot, and computes tonight's moon phase with plain arithmetic.
- It chooses one of twelve cartographic styles using a bandit informed by real community votes.
- It hands the assembled facts — and only those facts — to Amazon Bedrock to write a title, a short poem, a single key line, and a prose field note.
- It renders a map procedurally in Python, narrates the poem with Amazon Polly, and publishes.
Here is what that actually produces. This is a real survey, unedited, from a street in Ventspils, Latvia:
Latvian EveningWet pavement glimmers under sodium lamps, seventeen degrees holds the damp air tight. First quarter moon cuts pale above rooftops, silhouettes climb down to the streetlight. Each drop traces old cracks in the concrete, roads remember footsteps long since faded.
The seventeen degrees is real. The drizzle was real. The first-quarter moon was real. The model did not choose any of them — it was told them, and its only job was to find the words around them.
And here is Madurai Junction railway station, in Tamil Nadu:
Madurai Junction at First QuarterConcrete platforms sweat under 37° steel shadows Train breath cuts through mostly clear night air First quarter moon lights the Mangesh Kerana sign Selvaraj's tire smoke mingles with Platform 1 coffee Mythilisaran's shelves hum with silent Hindi Madurai's pulse runs on these iron veins
Mangesh Kerana Ice Cream Center. Selvaraj Puncher Workshop. Mythilisaran Gupt Hindi Library. I did not write those names into a prompt. They came back from Amazon Location Service as real points of interest within a few hundred metres of the station, and the model wove them in. That is the difference between a poem about a place and a poem about the idea of a place.

The featured Madurai collection
Because the agent's whole value is specificity, I wanted to prove it on somewhere I actually know. So alongside the random nightly surveys, the atlas features a curated collection: six Madurai landmarks, each pinned to a deliberate cartographic style.
The temple quarter around West Pattar Street. Tirumalai Nayak Palace. Vandiyur Mariamman Teppakulam. Koodal Azhagar Temple. Thiruparankundram. Madurai Junction. Same agent, same pipeline, same grounding — the only difference is that I pointed it instead of letting it choose. The Teppakulam poem names Neerazhi Mandabam; the palace poem names Poddar Tyres and PS Infotech on 3rd Street. All of it came back from Location Service, in 36–37°C Madurai heat, with light drizzle on the Thiruparankundram night.

The style evolution loop
The challenge brief suggested "an agent that improves its style over time," and I did not want to hand-wave that as "it remembers yesterday." Improvement needs a signal, persistent state, and generations.
Each map is drawn in one of twelve styles — Ink Wash, Midnight Atlas, Bathymetric, Copperplate Engraving, Storm Chart, Risograph and so on. The agent picks between them with an epsilon-greedy multi-armed bandit, scoring each style by its Laplace-smoothed like rate:
score = (likes + 1) / (uses + 2)
Three nights in four it draws in the current best performer. One night in four it explores something else. When a visitor votes on a map, that vote increments both the survey's like count and its style's counter — so the next night's choice is measurably different because somebody clicked.
Because
uses sits in the denominator, a style has to keep earning votes to hold its lead. Nothing locks in permanently.
How I Built It
Fully serverless, one CDK app, no servers to patch and nothing running between nightly invocations.
Tech stack:
- Backend: Python 3.12 on AWS Lambda, ARM64. Two functions — the generator (the agent itself) and a read/vote API — sharing a pinned-boto3 Lambda layer.
- AI: Amazon Bedrock via the Converse API, using Amazon Nova 2 Lite.
- Geography: Amazon Location Service Places —
ReverseGeocode,SearchNearby,Geocode.
- Voice: Amazon Polly, neural engine.
- Data: Amazon DynamoDB, single table with a
byCreatedAtGSI. Surveys stored aspk=ENTRY#<id>; per-style counters aspk=STYLE, sk=<styleId>.
- Assets: Amazon S3, public read scoped to a
public/*prefix only.
- API: Amazon API Gateway HTTP API.
- Scheduling: Amazon EventBridge Scheduler, nightly cron.
- Frontend: Next.js 16 (App Router, TypeScript, Tailwind v4) on AWS Amplify Hosting.
- IaC: AWS CDK in Python — one stack,
cdk deploy/cdk destroy.
Decision 1: No image-generation model, on purpose
My first instinct was the obvious one: generate the map with an image model. I got about twenty minutes into that plan before checking the model lifecycle page, and found that Amazon Nova Canvas and Nova Reel both moved to Legacy status in March 2026, with end-of-life on 30 September 2026. Building the entire visual layer of a project on a model with a published expiry date five weeks out would have been shipping something already broken.
That constraint turned out to be the best thing that happened to this build. Instead of generating images, I wrote a procedural SVG renderer in pure Python — a contour field seeded from a hash of the coordinate, an optional graticule, a meandering hydrology line, radiating roads, POI markers in five glyph styles, a compass rose, a scale bar, and a cartouche carrying the poem's key line.
The upsides compounded fast. It costs nothing per render. It is crisp at any size because it is vector. It is deterministic — the same coordinate always produces the same map, which means every map is reproducible from its coordinate alone. And the twelve "styles" became genuinely cheap to add, because a style is just a dict of colours and drawing rules, not a fine-tuned model.
Decision 2: A hard line between deterministic and generated
This is the decision the whole project rests on.
Every fact the model sees — place name, coordinates, POI names, temperature, wind speed, cloud cover, moon phase — is computed in Python from a real API response before the prompt is assembled. The model's system prompt tells it explicitly to invent nothing and to use only what it is given.
The result is that the poem can be evocative without the geography being negotiable. If Nova 2 Lite drifts stylistically, the facts on the page still hold, because they were never the model's to choose. The same principle governs the artwork: the map is drawn from arithmetic, so it cannot hallucinate a river that isn't there.
Decision 3: Verify the coordinate, don't trust it
Reverse-geocoding a random point sounds trivial and is not. More on this in the challenges section — it produced the most instructive bug of the build.
Decision 4: One CDK stack, not several
Two Lambdas, a DynamoDB table with a GSI, an S3 bucket with a scoped public-read policy, an HTTP API with five routes, an EventBridge schedule, a Lambda layer, log groups, and all the IAM — defined in a single Python CDK stack. These resources are tightly coupled (the schedule needs the function, the function needs the table and bucket), and I have been burned before by splitting coupled resources into separate stacks and creating circular references. One stack, one deploy, one teardown.
Challenges Encountered — and How I Overcame Them
The bug that would have invalidated the entire premise
My first successful run produced a poem about "Aleutians West, Alaska." Beautiful, atmospheric, mentioned fishermen and sea cliffs. I almost moved on.
Then I looked at the coordinates it had stored: 52.41°N, -47.62°W. That is the middle of the North Atlantic Ocean. Aleutians West is in the Pacific, roughly 8,000 km away.
What happened: I had called
ReverseGeocode with no radius constraint and no place-type filter, so an ocean coordinate happily matched the nearest thing it could find — a vast administrative SubRegion whose centroid was thousands of kilometres off. The API was not wrong. My usage of it was.This was not a cosmetic bug. The single claim this entire project makes is "the poem is grounded in a real place." A poem about Alaska generated from an Atlantic coordinate makes that claim false, and I had nearly shipped it.
The fix has four parts, all in the acceptance criteria rather than the poem:
- Filter to specific place types only —
Locality,Street,PointAddress— neverRegion,SubRegion, orCountry.
- Pass an explicit
QueryRadiusand reject any result more than 15 km from the sampled point.
- Require the resolved address to carry a real locality or street.
- Sample inside weighted continental land boxes so the retry loop converges instead of burning 25 attempts on open water.
After the fix, the same code returned a real street in Ventspils, Latvia — with a name in Latvian containing characters my Windows console could not even print. That encoding error was the most reassuring failure of the whole weekend.
A geocoding collision I only caught by testing first
Building the Madurai collection, I geocoded
"Meenakshi Amman Temple, Madurai, Tamil Nadu, India" and got back a confident PointOfInterest at 9.8656, 78.0305. The actual Meenakshi Amman Temple is at roughly 9.9195, 78.1193 — about 12 km away. There is more than one temple with that name, and Geocode picked a different one.I caught it only because I had written a throwaway script to print how each candidate query resolved before spending Bedrock calls on them. Without that step, the flagship poem of my featured collection would have described the wrong temple, and I would never have known.
Fix: pin that one landmark to its true coordinate and let
ReverseGeocode supply the label, while keeping text queries for the landmarks that resolve correctly. The lesson generalises — for anything user-facing and specific, verify the resolution, don't assume it.A DynamoDB update expression that cannot work
I originally modelled the style counters as a nested map on a single item, incrementing with:
SET stats.#sid.uses = if_not_exists(stats.#sid.uses, :zero) + :one
This fails with a
ValidationException . DynamoDB will not create intermediate map paths — if stats or stats.<styleId> doesn't exist yet, the whole expression is invalid, and if_not_exists does not help because the parent path is what's missing.I restructured to one item per style (
pk=STYLE, sk=<styleId> ) with top-level numeric attributes, so an atomic ADD uses :one both creates the item on first use and increments it thereafter. Simpler, atomic, and no seeding step on deploy. geo-places is newer than the Lambda runtime SDK
Amazon Location Service's v2 Places APIs use a
geo-places boto3 client that is newer than the SDK baked into the Python Lambda runtime. Rather than gamble on the runtime version, I pinned a known-good boto3 into a Lambda layer, built with a plain local pip install --target (boto3 is pure Python, so no Docker needed) — with a build-time assertion that the geo-places service model is actually present in the layer before it ships.Next.js 16 will not give me a 404
Small honest one. Visiting an unknown entry ID renders the correct "off the edge of the map" page but responds HTTP 200, not 404. Next 16 streams the HTML shell for dynamic routes, so the status is committed before the awaited data resolves and
notFound() runs. I tried moving the check into generateMetadata and removing force-dynamic ; neither helped, and both dev and production behave the same way. Invisible to human visitors, would matter to a crawler. A proper fix needs middleware, and with the deadline in sight I chose to document it rather than chase it.Getting reliable JSON out of the model
Nova 2 Lite occasionally wraps its JSON in markdown fences or adds a sentence of preamble. Same solution as always: a strict system prompt specifying the exact schema, plus a regex fallback parser that strips fences and extracts the object — and a final defensive path that wraps raw text as a single-line poem, so a malformed response degrades the output rather than failing the nightly run.
AWS Services Used / Architecture Overview
Service | Role |
|---|---|
Amazon Location Service (Places) | The grounding layer. ReverseGeocode verifies each sampled coordinate is a real named place; SearchNearby returns genuine POIs; Geocode resolves curated landmarks. |
Amazon Bedrock (Nova 2 Lite) | Writes the title, poem, key line, and field note via the Converse API. Chosen partly because it is Active with no announced EOL. |
Amazon Polly | Neural text-to-speech narration of every poem. |
AWS Lambda | Two Python 3.12 ARM64 functions: the nightly generator agent, and the read/vote API. |
Amazon EventBridge Scheduler | The autonomous nightly trigger. No human in the loop. |
Amazon DynamoDB | Surveys plus per-style vote counters — the bandit's memory. |
Amazon S3 | Serves generated SVG maps and MP3 narrations, public read scoped to public/*. |
Amazon API Gateway (HTTP API) | Five routes for listing, reading, voting, and style stats. |
Amazon CloudWatch | Logs every invocation and records custom generation metrics. |
AWS Amplify Hosting | Hosts the Next.js 16 frontend. |
AWS CDK (Python) | All of the above as code, in one stack. |
How the agent is triggered: one schedule, no user action. EventBridge Scheduler fires
cartographer-nightly on a cron, invoking the generator Lambda directly. The Lambda calls Location Service, the weather API, Bedrock, and Polly, writes to DynamoDB and S3, and exits. Nothing about producing a survey involves the frontend — the website is purely a reading surface for work that already happened. The only human-triggered path is the vote endpoint, and that changes tomorrow's style choice, never whether a survey gets made.Architecture diagram

Nightly run sequence diagram

EventBridge to published survey — full end-to-end process

EventBridge Schedule

What I Learned
A deprecation notice can be a design gift. Discovering the Nova Canvas EOL date felt like losing my visual layer. It forced me into procedural vector art, which turned out cheaper, sharper, deterministic, reproducible, and trivially extensible to twelve styles. I would not have found that path if the easy option had still been available. Checking model lifecycle status before building on a model is now a step I will never skip.
"Grounded in real data" is a claim you have to actively defend. I did not set out to write a poem about Alaska from an Atlantic coordinate — I set out to write grounded poems, and the naive implementation quietly violated that. The guarantee did not come from the prompt. It came from the acceptance criteria on the data: place-type filters, a distance ceiling, a required locality. If a claim matters, something in the code has to enforce it.
Verify how an API resolves your input before you build on the output. The Meenakshi geocoding collision cost me ten minutes because I tested resolution first. Had I trusted it, the centrepiece of my featured collection would have described the wrong temple in the wrong part of the city, confidently and in detail.
Splitting deterministic logic from generative logic makes the whole system easier to trust. Because every number on the page is computed in Python, I never have to wonder whether the temperature was hallucinated. That single boundary is what let me hand the model real creative latitude on language without worrying about factual drift. It also made debugging enormously easier — when output looked wrong, I always knew which side of the line to look at.
"Improves over time" needs a number in a table. It would have been easy to claim style evolution and implement nothing. Making it real took a bandit, a persistent counter, and a vote endpoint — and then I could actually measure it: after four votes on Storm Chart, it won 9 of the next 12 runs, with exactly 3 exploration picks, matching ε = 0.25 almost precisely. Watching a design intention show up as an observable ratio is a much better feeling than asserting it in a README.
Newer AWS APIs may outpace the Lambda runtime SDK.
geo-places is recent enough that I could not assume it existed in the bundled boto3. Pinning it into a layer with an assertion that the service model is present turned a possible mystery runtime failure into a build-time error.
The Result
I ran the pipeline until the atlas held 44 surveys across 25 countries, using all 12 cartographic styles.
The variety is what convinced me. Weld Range in Western Australia, where the only nearby feature was Big Bell Airport and the poem noted empty moonlit runways. A street in Ventspils. Gibson Desert North. Nickelsville, Virginia. Morgongiori in Sardinia. Bongandanga in the DRC. Lake Carnegie. A road in Turkmenistan whose poem mentioned the Ashgabat–Kunya Urgench highway and a school reflecting distant headlights — both real, both retrieved, neither invented.
What genuinely surprised me was not that a model could write a competent poem. It was how much better the poems got when the facts were specific. A survey in an empty desert produces something atmospheric but slightly generic. A survey next to Madurai Junction produces Selvaraj's tire smoke mingling with Platform 1 coffee. The model was the same in both cases. The difference was entirely in how much real texture Location Service handed it.
That reframed what I thought I was building. I assumed the interesting engineering was the prompt. It was not — it was the retrieval. The poem's quality is almost a direct function of how much genuine, specific, local detail I could put in front of the model. Prompt engineering was maybe an hour of this build; grounding was the rest.
The deeper thing I was testing was whether an agent could make something that felt found rather than generated — whether anchoring a model to facts it did not pick would produce output with the particular weight that real things have. Reading the Madurai Junction poem, with its ice cream sign and its puncture-repair shop and its 37-degree platforms, I think the answer is yes. Not because the model got more creative, but because it was finally writing about somewhere that exists.

Link to App or Repo
- GitHub repo: https://github.com/Ajaykumarkv17/The-Cartographer
Final Thoughts
The most useful thing I learned this weekend has very little to do with Bedrock, and quite a lot to do with honesty.
An agent that produces creative output on a schedule is not hard to build — it is a Lambda, a cron, and a model call. What is hard is making the output mean something, and meaning turns out to come almost entirely from constraint. Every constraint I added made the work better: no image model forced deterministic vector art that is reproducible from a coordinate; strict place verification forced poems about places that actually exist; a hard deterministic/generative boundary meant the facts on the page are never negotiable.
The agent does not have creative freedom, in the end. It has one narrow job — find the language for a set of facts it was handed and cannot change. That is a much smaller job than "make art." It is also the reason the output is worth reading.
Made with Kiro.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article