Subscribe free
Morning Merge Architecture · Monday, November 23, 20264 min read

Nango treats refresh tokens like money, not cache

Also: agents as distributed systems, one model call per burst, keying by DID

A thin Monday with one rule running through it: state you can't recreate gets one owner and a durable write first. Start with Nango's OAuth scar tissue.

The main thing

A new key set into a filing drawer while tongs drop an old key into a bin

Nango on what operating auth for 1,000 APIs taught it. In May 2025, Nango merged a PR with an if condition that never fired, so refreshed credentials weren't saved to the database. The team reverted it in just under two hours.

In those two hours, scheduled jobs refreshed and discarded tokens for hundreds of connections. Where the old refresh token still worked, the next scheduled refresh repaired the connection.

Airtable and Atlassian invalidate the old refresh token the moment they issue a new one, and Salesforce and Slack can when rotation is enabled. Those connections were gone, and customers had to send their users back through the consent screen.

That's the weird part: rotation is a security win that turns an ordinary bug into permanent data loss. Nango now treats refresh tokens "like money, not cache." The new token is persisted before anything else can fail, the persistence path has its own regression tests, and refresh anomalies page on-call.

Concurrency is the next trap. Send Airtable the same refresh twice after its short grace period and it can revoke the user's whole authorization. Nango now serializes refreshes per connection behind a distributed lock. Xero is kinder: you can retry with the previous refresh token for up to 30 minutes.

Timing is just as uneven. RFC 6749 makes expires_in optional. Zendesk sends it only if you ask, and Salesforce sends no expiry at all, so Nango checks its introspection endpoint first. Exact Online rejects refreshes made more than 30 seconds before expiry, which broke Nango's "refresh 15 minutes early" rule.

Failures hide too. Zoho CRM's token endpoint returns HTTP 200 with the error in the body, and Workday and Dayforce return empty data when a permission policy is missing. Nango's credential check for LastPass searches the response for the string "Authorization Error".

What to do: if you store third-party tokens, write the new refresh token before any other step, lock refreshes per connection, and keep expiry buffers per provider. Google refresh tokens can die after six months without use, so Nango refreshes stale credentials on a cron.

Agents are distributed systems

A robotic arm inside a scaffold frame, beside a drafting compass

QCon SF keynote: the harness is the new operating system. Manju Rajashekhar, founder and CEO of Mad Labs, argued that the harness, "everything in an agent that isn't the model," decides what an agent can do and how safely. Each part maps to an OS job: context as virtual memory, the tool interface as system calls, execution as processes and permissions.

The case for structure is arithmetic. A 20-step task at 95% per step succeeds 36% of the time; catch 80% of errors and it rises to 82%. So the harness keeps "tests failed," "could not run" and "outcome unknown" apart instead of making the model guess.

Rajashekhar's QCon AI Boston 2026 talk went further: production agents "are just distributed systems in disguise." Each agent task owns its state, receives events through a mailbox, writes each state change to a durable store and runs under a supervisor. Any complicated enough agent loop, the talk suggested, contains half of an actor system.

Permissions belong in the same design. "Instructions guide. Boundaries enforce," so give the agent a test database with no production access instead of a prompt asking it to be careful. Rajashekhar also cited a DeepSeek model card in which one model scored between 65.5% and 74.2% on DeepSWE across eight harnesses, and the minimal harnesses scored highest.

Try this: on a task your agent fumbles, keep the model and change one part of the loop. If it holds long-running state, check that each change is written down before the next step runs. It's the same rule Nango learned about tokens.

Worth a look

Rows of carts on parallel rails merging onto one track into a single machine

A safer RAG system lost throughput under load. The author's system, The Relay, answers only from three research papers and checks every sentence against the passage it cites before the user sees it. First sentences arrived sooner, but under heavy overload it delivered 62.8% of requests, against 67.4% before, and the author blames the safety feature.

The reusable part is burst handling. With SingleFlight, a request for a question already being answered waits for that answer. In one test, 30 requests in 2 seconds covering 6 distinct questions made 6 model calls. With Redis shared between workers, 10 identical requests across two workers made exactly one.

The slowest request spent 29.2 of its 29.8 seconds waiting in a queue, so measure queue time before blaming the model. And the cheapest correct refusal never calls it: with reranking on, five of the six unanswerable questions were refused before any model call.

Falsehoods programmers believe about ATProto. A data-modeling checklist dressed as a listicle, with each item backed by the spec or by live requests made in November 2026. Handles change, a domain can be pointed at a different DID, and a handle stops resolving when its DNS record disappears. Key users by DID, keep the handle for display, and never use a cached handle for permissions.

DIDs need care too: they're URIs, so normalize to lowercase and store and compare only that form. Plan for accounts with no valid handle, which APIs may return as handle.invalid. Re-resolve handles periodically and watch the firehose for #identity events.

If a piece of state can't be rebuilt, give it one owner and write it down before you do anything else.

← All Morning Merge Architecture issues

Get this in your inbox every morning.

Free. Five minutes. Unsubscribe in one click.

Subscribe free →