<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hien Luu on Medium]]></title>
        <description><![CDATA[Stories by Hien Luu on Medium]]></description>
        <link>https://medium.com/@hien-luu?source=rss-ae8fe3c77c93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_GikgWZ6OAHMA6_8.</url>
            <title>Stories by Hien Luu on Medium</title>
            <link>https://medium.com/@hien-luu?source=rss-ae8fe3c77c93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 18:23:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hien-luu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why You Need an Agent Gateway]]></title>
            <link>https://hien-luu.medium.com/why-you-need-an-agent-gateway-bff12be8a196?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/bff12be8a196</guid>
            <category><![CDATA[ai-gateway]]></category>
            <category><![CDATA[mcp-gateway]]></category>
            <category><![CDATA[agentgateway]]></category>
            <category><![CDATA[llm-gateway]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Fri, 04 Sep 2026 21:21:41 GMT</pubDate>
            <atom:updated>2026-09-04T21:21:41.495Z</atom:updated>
            <content:encoded><![CDATA[<p>Notes for AI platform teams: building critical infrastructure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s8_4HxwuuDZN3NBbo6Fvtg.png" /><figcaption>The data plane: Agent Gateway</figcaption></figure><h3>It always starts the same way</h3><p>One team ships a support chatbot on OpenAI. It works, people are happy, nobody thinks much about it.</p><p>Six weeks later a second team stands up a RAG service on Bedrock, because that’s where the data already lives. A third team is deep in an agent prototype that calls four internal MCP servers.</p><p>Nobody did anything wrong. But look at what you now own:</p><ul><li>Model provider keys in multiple places. The OpenAI key in Vault, the Bedrock credentials in a Kubernetes Secret, and at least one in a .env that got committed.</li><li>One line item on your model provider’s invoice, and a finance partner who wants it split by team. Your current answer is a spreadsheet and a confident tone of voice.</li><li>Three different ideas about what to do when a call fails: one service retries forever, one gives up immediately, and one silently falls back to a smaller model.</li><li>No real inventory of which tools your agents can reach. Every framework brings its own MCP client and its own OAuth dance.</li></ul><p>None of this is a model problem. It’s a traffic problem, the same category that produced API gateways twenty years ago.</p><p>That’s the job an agent gateway exists to do.</p><h3>Your API gateway gets you about halfway</h3><p>Reusing the gateway you already run is a reasonable first instinct. I’d try it too. It runs out at about the moment the second team shows up. Four places in particular.</p><p>A token budget can’t be enforced with a single decision. One chat completion might cost a fraction of a cent or two dollars, so limits need to be denominated in tokens, not requests. But your rate limiter decides before the request goes out, and nobody knows what the response will cost yet. It has to charge an estimate, admit the request, then correct the bucket once real usage lands. Most gateways can log what a response cost. Far fewer can subtract it from the budget in time to affect the next request.</p><p>The interesting metadata shows up last, if you remember to ask for it. On OpenAI-compatible Chat Completions, token counts arrive in a final chunk before the stream closes, and only if the request asked for them. So your gateway has to reach into the client’s request and set a flag they never set, then read the numbers back out of the stream as it goes past, without ever buffering it, because buffering wrecks time-to-first-token. Most API gateways make you choose between streaming a body and inspecting it; here you need both.</p><p>Retries assume the request is replayable and the response is repeatable. Neither holds. Replaying means buffering the request body in memory for the duration: fine for a 400-byte JSON POST, impossible for a streaming upload. And once you’ve shipped the first token there is no retry at all: you can’t un-send it, and the model won’t produce the same output anyway. What you get here is a half-delivered answer instead of a clean 503.</p><p>MCP is its own protocol, and it moved recently. The 2026–07–28 spec dropped protocol-level sessions and the initialize handshake, and made Mcp-Method and Mcp-Name required headers so a proxy can route and meter tool calls without opening the body. That helps, and stopping there is a mistake. The client writes those headers. Route on Mcp-Name alone and nothing stops a request labeled read_ticket from carrying a delete_ticket call in the body, so somebody has to open the body and check. That means parsing MCP, which is not what your API gateway was built to do.</p><p>None of this is a plugin away. Each one is a place where LLM traffic breaks an assumption your gateway was built on, and you tend not to find out which one until you’re already in production.</p><h3>What you actually want it to do</h3><p>Here’s what to check for. The last column is who comes looking for you when it’s missing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVLpWnG6izhG-HrCbQ3VCg.png" /></figure><p>Every one of those happens in the request path. That’s not a feature list, it’s infrastructure, and you’re going to build it either way. The question is whether you build it on purpose or accumulate it by accident.</p><p>Be clear about what the on-purpose version costs, though. Whatever you pick sits in the path of every request, which makes it something you deploy, upgrade, and keep highly available — and when it’s down, every AI application is down with it. The accidental version has the same failure modes with nobody on call for them. But go in knowing you’re signing up to run infrastructure, not install a plugin.</p><h3>A quick tour of the landscape</h3><p>The naming is a mess. “AI gateway,” “LLM gateway,” “MCP gateway,” and “agent gateway” get used interchangeably by vendors who mean genuinely different things. Grouping by where a project started works better, because that tells you what it’s good at and where it strains.</p><p>LLM-first proxies: LiteLLM, Portkey, Bifrost. Built to solve “one API, many providers,” and they nail it. LiteLLM’s coverage is past a hundred providers. The limits show up when one deployment serves several teams that each need their own keys, budgets, and audit trail. MCP and A2A came later, and it shows.</p><p>MCP-first gateways: IBM ContextForge, Docker MCP Gateway, Lunar MCPX, Microsoft MCP Gateway, Obot. They go deepest on the newest question: which agent is allowed to call which tool. ContextForge is the broadest, and it has already outgrown the label: it federates MCP, A2A, and REST/gRPC behind one endpoint, and it now calls itself an AI gateway rather than an MCP one. Docker’s is built around container isolation for servers you don’t fully trust. Most of this group still doesn’t route LLM traffic, though, so you end up running two gateways and reconciling two sets of telemetry.</p><p>The hyperscalers: Google’s Agent Gateway governs agent traffic in both directions, leaning on the rest of Google’s stack for authorization and content safety. Worth a look if you’re already committed there. It governs agents running on Google Cloud, not wherever your workloads happen to live.</p><p>Purpose-built agentic data planes: Envoy AI Gateway and agentgateway. The newest group, and the one going after the whole problem: LLM, MCP, A2A, and ordinary HTTP/gRPC under one policy model and one telemetry pipeline. Both are young. Envoy AI Gateway, built by Tetrate and Bloomberg on top of CNCF’s Envoy Gateway, assumes Kubernetes and the Gateway API; agentgateway runs there too, or standalone as a single binary.</p><p>Which of these you need, if any:</p><ul><li>AI is under 10% of your API traffic, you expect it to stay there, and you already run Kong or APISIX → extend your existing gateway with its AI plugins and move on.</li><li>One team, one app, shipping fast → an LLM-first proxy like LiteLLM or Portkey. Revisit when a second team shows up.</li><li>Tool governance is urgent and model routing is already handled → an MCP-first gateway.</li><li>You’re building a shared platform serving several teams across chatbots, RAG, and agents → a purpose-built agentic data plane. That’s the case this post is really about.</li></ul><h3>Where agentgateway fits</h3><p>I’m anchoring on <a href="https://github.com/agentgateway/agentgateway">agentgateway</a> here because it’s aimed squarely at the case above: not a proxy in front of one application, but a data plane for an organization. One disclosure before I make the case: this post was reviewed by one of the project’s maintainers, credited at the bottom, so weigh what follows accordingly.</p><p>The engineering choices line up with that. It’s Rust, so no interpreter and no GC pauses, and it runs either standalone as a single binary with flat YAML, or on Kubernetes through the Gateway API with a built-in controller. The same binary fronts OpenAI, Anthropic, Gemini, Bedrock, Vertex, and Azure AI Foundry behind one OpenAI-compatible API, federates MCP servers across stdio, HTTP, SSE, and Streamable HTTP (including ones it generates from OpenAPI specs), and brokers A2A between agents.</p><p>Guardrails, CEL-based RBAC, mTLS, and OpenTelemetry apply to all of that traffic, with guardrails evaluated in windows as a response streams rather than after it completes. Recording full prompts and completions is opt-in, so the audit record is there when you want it without logging your most sensitive traffic by default. It also routes to self-hosted models based on GPU utilization, KV cache state, and queue depth, which most LLM proxies don’t do and which matters the day someone asks you to serve an open-weights model on hardware you own.</p><p>Feature lists are cheap, though. What I wanted to know was how it handles the four problems from earlier. Since it’s Apache 2.0, you can go look instead of taking anyone’s word for it:</p><ul><li>The budget limiter runs in two passes. A limit can be denominated in requests or in tokens. On a token limit the gateway counts the input tokens up front and charges them against your bucket, lets the request through, then goes back and settles up with the real total once the response lands. That’s the feedback loop from earlier.</li><li>The accounting happens in flight. The response body hands each chunk to the client the moment it arrives, while running an SSE decoder over those same bytes on the way past. You get the token counts out of the last chunk without adding anything to time-to-first-token. No buffering, and no choosing between streaming a response and reading it.</li><li>Retries can be told when not to fire. A retry policy can carry a precondition that turns them off for requests that were never replayable (streaming uploads, websockets), so you don’t pay to buffer a body you could never send twice. When replay is possible, bodies are buffered lazily, <a href="https://linkerd.io/2021/10/26/how-linkerd-retries-http-requests-with-bodies/">an approach borrowed from linkerd2-proxy</a>.</li><li>Mixed-version MCP is the gateway’s problem, not yours. New clients open with server/discover; old ones still send initialize. With several servers behind one endpoint, the gateway runs discovery against each and intersects what they support, so one old server pulls the whole endpoint back to the older protocol instead of half-breaking it. Unglamorous compatibility work, and the alternative is doing it in every client.</li></ul><p>The Rust choice shows up in the numbers. Published head-to-head runs against LiteLLM (<a href="https://agentgateway.dev/blog/2026-06-26-benchmarking-agentgateway-vs-litellm/">part 1</a>, <a href="https://agentgateway.dev/blog/2026-06-26-benchmarking-agentgateway-vs-litellm-part-2/">part 2</a>) showed large throughput gaps and a memory footprint measured in megabytes rather than gigabytes. The obvious objection was that LiteLLM is Python, so <a href="https://agentgateway.dev/blog/2026-08-13-benchmarking-agentgateway-vs-litellm-rust-mode/">a third run</a> repeated the test against LiteLLM 1.98 with its new Rust core switched on. Serving the same 900 requests per second, agentgateway used 10% of a CPU and 13 MiB of memory; LiteLLM used 97% and 2.14 GiB. All three are first-party benchmarks against a mock backend, so they measure proxy overhead and nothing else. Reproduce them on your own hardware before you quote them.</p><p>Development is moving fast. The <a href="https://github.com/agentgateway/agentgateway/releases/tag/v1.4.0">v1.4.0 release</a> in July 2026 added support for the new MCP 2026–07–28 protocol and Cross App Access, which lets your identity provider broker MCP access instead of asking every employee to authorize every downstream app. <a href="https://github.com/agentgateway/agentgateway/releases/tag/v1.5.0">v1.5.0</a> followed in late August, extending guardrails to scan tool call inputs and outputs, not just LLM traffic, and adding a native Gemini inbound API so clients built on Gemini SDKs can point at the gateway without rewriting to the OpenAI format.</p><p>One more thing I’d have dismissed a few years ago: who governs the project. Every prompt passes through it, it holds the provider credentials, and once your teams all depend on it, replacing it means touching every one of them. agentgateway is Apache 2.0, hosted by the Agentic AI Foundation under the Linux Foundation since June 2026. That’s no guarantee the project stays healthy, but it’s a better answer than one company’s roadmap.</p><h3>What to ask before you commit</h3><p>Six questions to put to any gateway you’re considering, where a weak answer tells you most of what you need to know:</p><ul><li>Can it handle LLM, MCP, and A2A in one gateway?</li><li>Can it enforce a token budget, or only report on one after the fact?</li><li>Does the caller’s identity, user or agent, reach the backend, or does everything arrive as one service account?</li><li>Can I write authorization at the tool level, not just the route level?</li><li>What happens to every AI application when the gateway is down, and where does it run?</li><li>Who governs the project, and what’s my exit if that changes?</li></ul><h3>Closing thought</h3><p>Every organization running AI for more than one team ends up with an agent gateway. The real question is whether it’s deliberate or accidental. The accidental version is a retry loop somebody hand-rolled in the RAG service, a budget alert wired into Slack, and one person who knows which team owns which API key.</p><p>The deliberate version takes more work to stand up and much less to keep running. It’s also the one that answers the questions you’re going to get six months from now, without a week of grepping logs and asking around: what this cost, who authorized that tool call, what the agent actually sent.</p><p><em>Thanks to </em><a href="https://www.linkedin.com/in/lin-sun-a9b7a81/"><em>Lin Sun</em></a><em>, one of the core maintainers of </em><a href="https://github.com/agentgateway/agentgateway"><em>agentgateway</em></a><em>, for reviewing this post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bff12be8a196" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I set out to build an agentic todo app. Most of what I built was a parser.]]></title>
            <link>https://hien-luu.medium.com/i-set-out-to-build-an-agentic-todo-app-most-of-what-i-built-was-a-parser-c0f7849d1566?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0f7849d1566</guid>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Mon, 24 Aug 2026 04:15:47 GMT</pubDate>
            <atom:updated>2026-08-24T04:23:17.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-IgnMp3PNMhcy00CillnA.jpeg" /></figure><p>The bet this whole thing rests on: the bottleneck in a todo system isn’t organizing tasks, it’s getting one in. People quit at the input, not at the review. That’s an assumption rather than a finding, and it is the one everything here is built on. So I built the obvious fix: type one messy sentence, let a model do the filing.</p><pre>todo › call the dentist about the crown thing sometime next week</pre><pre>  ✓ Captured: &#39;Call dentist about the crown&#39;<br>    Category: Health<br>    Due:      ~2026-09-01 (soft)<br>    Effort:   15m</pre><p>No form, no fields, no syntax. Underneath is one markdown file per task with YAML frontmatter. Greppable, diffable, works with git, and yours if you walk away tomorrow.</p><p>It worked almost immediately, and that’s the problem.</p><p>What I’d built was a parser. You hand it one thing, it transforms that thing while you wait, and it stops. Useful, but a shell script with an API key is also useful, and nothing about it is an agent. I had set out to answer one question and quietly answered an easier one.</p><h3>So what would make it agentic?</h3><p>The question I actually wanted was this:</p><blockquote><em>What’s the agentic way of managing a todo list?</em></blockquote><p>And the working definition I settled on, after a week of finding out what didn’t count:</p><blockquote><em>Agency is the loop, not the model call. It acts on its own trigger, it remembers what it did, and the outcome changes what it does next.</em></blockquote><p>Three legs: initiative, memory, feedback. I had none of them. Here’s what closing each one took.</p><h3>1. Memory: an append-only log turns state into history</h3><p>Task files answer what is true now. Every change overwrites what was true before. Reschedule something four times and the file holds one date. The four reschedules are gone.</p><p>So every mutation also appends a line to .log/events.jsonl:</p><pre>{&quot;at&quot;:&quot;…&quot;,&quot;kind&quot;:&quot;rescheduled&quot;,&quot;id&quot;:&quot;…&quot;,&quot;from&quot;:&quot;2026-09-01&quot;,&quot;to&quot;:&quot;2026-09-08&quot;}<br>{&quot;at&quot;:&quot;…&quot;,&quot;kind&quot;:&quot;completed&quot;,&quot;id&quot;:&quot;…&quot;,&quot;estimated&quot;:&quot;30m&quot;,&quot;actual&quot;:&quot;1h&quot;}</pre><p>One file, a few hundred lines of code, and five features that were impossible without it:</p><ul><li>noticing avoidance: “you’ve pushed this three times, that isn’t a scheduling problem”</li><li>calibrating your estimates against your own finished tasks, mentioned once rather than nagged about</li><li>undo across capture, completion, park, reschedule and delete</li><li>working out what “it” means when you type “push it to Friday”</li><li>the agent’s record of its own advice, which is the next section</li></ul><p>Three field choices turned out to matter more than they look. captured stores your raw words rather than the cleaned title, because the same errand captured four times in four wordings is only visible in the wordings. deleted stores the title, read before the file is unlinked, because afterwards nothing remembers what that id meant. completed stores estimate and actual on one line, which is the whole basis for ever telling someone their estimates run short.</p><p>One rule holds it together: recording never raises an error. A missed observation is cheap. Marking a task done and having it fail because the logging failed would cost you real work.</p><h3>2. Feedback: check whether the join already exists</h3><p>I nearly built a datastore for this one.</p><p>Once a day, if anything has changed, the agent writes a short brief: what’s genuinely due, what’s gone stale, what’s too vague to start. Each one was already archived to its own file, so the next brief knows what the last one said. The event log already recorded what the user did. I wanted the agent to know whether its <em>own advice</em> had landed, and started sketching a table to track it.</p><p>Then I noticed both halves were already on disk. The brief archives the task ids it raised. The log records what happened to those ids. Join them.</p><blockquote><em>raised 3×, and all that followed was three reschedules</em></blockquote><p>The next brief is then told what to do with that: stop restating a recommendation that clearly hasn’t worked, and ask for a decision instead. It could already escalate its tone across repeated briefs. This lets it change its approach.</p><p>No new storage. The general version:</p><blockquote><em>Before adding a store, check whether the join already exists.</em></blockquote><p>The same move made effort calibration real. completed_effort had been collected since day one and read by nothing.</p><h3>3. Initiative: a condition, not a timer</h3><p>This is the one I’d argue hardest for.</p><p>The obvious implementation is a cron job that writes a brief every morning at nine. That’s a digest: it arrives whether or not anything happened, and people stop reading digests.</p><p>Instead the agent speaks when a condition is met:</p><ul><li>a hard deadline crossed midnight</li><li>a soft window closed</li><li>five or more tasks opened or closed</li><li>it’s been quiet two days <em>and</em> something is due within three</li></ul><p>Never twice in twelve hours, whatever the conditions say, because a day on which six things happen is still one day.</p><p>Most of the time it stays quiet. In production a scheduled job checks every four hours and usually writes nothing at all:</p><pre>scheduled review: 1 tester(s), 0 brief(s) written</pre><p>Zero is the correct answer. Almost every test around the trigger checks that nothing happens, which is the right proportion, because each firing buys the largest model call in the product, per user.</p><p>Thresholds like these are guesses. How many tasks count as a lot, how long counts as quiet. So there’s a stats command that reads the log back and reports whether the briefs are actually landing, which turns the numbers into something you can argue with rather than defend.</p><p>Nothing in that decision calls a model.</p><h3>Two decisions about what it’s allowed to do</h3><p>Closing the loop was the hard engineering. Deciding what the agent may do on its own was the hard judgement, and it came down to working out which mistakes are cheap.</p><p>Telling a note from an instruction. You type prose. Is that a task to save or a command to run? Getting it wrong is bad either way, but not equally bad. Filing a command as a task leaves a junk entry you delete in a second. Running a note as a command can act on the wrong task.</p><p>So the defaults are conservative and the offers are generous. Bare prose is always a capture. A leading slash marks a command. A line that is exactly one command word asks first instead of guessing. Anything that merely looks instruction-shaped gets an offer to re-run it as a command, a button on the web page or an [r] option in the terminal. A wrong offer costs you an option you ignore. A wrong default costs you data.</p><p>Once the asymmetry is clear, the defaults choose themselves. I now reach for that question early in any interaction design: which way of being wrong is cheap?</p><p>The agent organizes, it never acts. No agent module can write to the store at all. They return proposals and the engine decides. Deleting confirms every time and no flag turns that off. Completion is a file move rather than a delete.</p><p>That boundary got harder when I exposed the tools over MCP, and this is the part I’d most want other people building MCP servers to know. The <em>client</em> owns the confirmation prompt, and it shows that prompt before your server is ever called. So nothing you return can appear in it. The only text there is the tool name and the arguments.</p><p>Which means a prompt reading delete(task_id: &quot;d949&quot;) is asking a human to approve a four-character hash. They can&#39;t tell what&#39;s about to go.</p><p>The fix isn’t better wording, because you don’t control the wording. It was to make the task’s exact title a required argument. Now the prompt reads delete(task_id: &quot;d949&quot;, confirm_title: &quot;Call the dentist about the crown&quot;), the agent has to look the task up before it can ask, and the server refuses if the title doesn&#39;t match what&#39;s on disk. A stale id pointing at a different task fails instead of deleting the wrong thing.</p><h3>The spec is why one person could move this fast</h3><p>Eight days, seven agents, three surfaces, two clouds. The thing that kept it coherent was a design spec written before any of it, and then kept honest afterwards.</p><p>Two habits did the work. The first is that the code cites the spec where decisions get made, section by section. When you read §6: the confirmation is unconditional next to a prompt you were about to make configurable, you know it was a decision rather than an accident. That is what let me make quick calls all week without the design wandering.</p><p>The second is that when the build and the spec disagreed, I rewrote the spec rather than shrugging. It’s now an as-built document you could re-implement the tool from. Most specs rot the day after kickoff, and a rotted spec is worse than none, because people still trust it.</p><p>It also records what it failed to deliver. One acceptance criterion, twenty messy captures reviewed by hand, is still marked as never done. A spec that only lists successes was written afterwards.</p><h3>Three things I’d take to the next project</h3><p>One function for every model call. All seven of the model-backed features go through it. Tracing, token limits, empty responses and stripping code fences out of replies are handled there once instead of seven times, and a test checks that nothing goes around it. When I added Cloud Trace later it was a change in one module rather than seven.</p><p>Use the model only where it earns its place. Listing, completing and rescheduling are ordinary code, with no model involved. The model’s job is turning your sentence into one of those operations, and whatever it comes back with has to parse as a real command and survive a check that the arguments make sense before anything runs. It proposes, the parser decides.</p><p>That got sharper later. Asked “I have only 30 minutes, what do I do?”, the agent came back with three tasks of an hour or more. It wasn’t ignoring the constraint, it never received it: the time budget was dropped when the question was routed to a command. Rewriting the prompt wasn’t the fix. Filtering the task list to what fits before building the prompt was.</p><blockquote><em>Asking a model to respect a limit is a request it can decline. Removing the option before you build the prompt is a fact it can’t work around.</em></blockquote><p>Instrumentation breaks quietly, so budget time to check it works. It can’t be allowed to fail the request, which means its own faults only show up in a log and they all look the same from outside: no traces. Adding tracing turned up five problems in a row, from an attribute that every test double lacked and briefly took 155 tests down with it, to a missing IAM role and spans that never joined the request because nothing read the incoming trace header. Not one of them cost a single captured task. It’s the one part of a system with no user to report it broken.</p><h3>Where it honestly stands</h3><p>The loop is closed in code but it hasn’t run for long. The track record needs briefs to accumulate. Calibration needs finished tasks. The trigger has fired a handful of times.</p><p>There’s also an adoption problem I can state precisely. The value curve is flat and then steep. Capture works on day one and feels like typing into a file, while the parts that make it worth keeping, avoidance and calibration and the brief that remembers, need weeks of history. People quit during the flat part. A demo command seeds a realistic backdated month so the steep part is visible in thirty seconds, but that shows the value, it doesn&#39;t create it.</p><p>And there’s a decision I haven’t made. Everything built so far comments on the list. Whether the agent should move the work forward, for example drafting an outline into the notes of a post that’s been open three weeks, is undecided. It has the higher ceiling and it stretches the rule that the agent organizes but never acts, though drafting into a notes section destroys nothing and sends nothing.</p><p>The honest summary is that this is a carefully built answer to a question that’s still open. The loop exists. Whether it’s worth having is something only usage can settle, and the usage hasn’t happened yet.</p><p><em>Built in about a week: ~14,700 lines of Python, 947 hermetic tests with no network calls, three surfaces (CLI, MCP, web) over one engine, running on Google Cloud Run with Gemini. The store is plain markdown: no database, no vector store, and nothing holding your tasks but your own filesystem.</em></p><p><em>I wrote this post as part of my entry to the </em><a href="https://allthingsagentichackathon.devpost.com/"><em>All Things Agentic hackathon</em></a><em>, where todo-agent is submitted in the Taskmaster track.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0f7849d1566" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thin vs. Thick AI Agent Harnesses]]></title>
            <link>https://hien-luu.medium.com/thin-vs-thick-ai-agent-harnesses-0276ee0a8353?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/0276ee0a8353</guid>
            <category><![CDATA[ai-agent-development]]></category>
            <category><![CDATA[ai-agents-in-action]]></category>
            <category><![CDATA[ai-agent-software]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Sun, 19 Apr 2026 22:51:18 GMT</pubDate>
            <atom:updated>2026-04-19T22:51:18.289Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Framework Isn’t the Expensive Part</h3><p>Every AI Agent framework pitches its scaffolding. Every anti-framework pitches a thirty-line while-loop. What almost nobody does is put both on the same tasks, with the same model, and measure.</p><p>That’s what I set out to do after AGI House’s <a href="https://blog.agihouse.org/posts/agent-harness-build-day-pre-event-guide">Agent Harness Build Day</a>, specifically Project 9: Thin vs. Thick Harness Benchmark. What started as a one-day sprint grew into a four-harness comparison, with one of those harnesses added specifically to separate “framework overhead” from “topology overhead” in the result. This post covers what the benchmark found and three engineering lessons I wish I’d known on day one.</p><p>The question I wanted answered:</p><blockquote>Does a framework-based agent harness actually deliver measurably better quality, or does it just cost you tokens and latency? And if there’s a cost, is it the framework or the way I wired it?</blockquote><h3>The setup</h3><p>Four harnesses, one model, same everything else:</p><ul><li><strong>thin</strong>: ~100 lines. Anthropic SDK, a while loop, tool-call dispatch, finish exits. No framework.</li><li><strong>langgraph_react</strong>: the prebuilt idiomatic create_agent (from langchain.agents, successor to langgraph.prebuilt.create_react_agent). LLM → ToolNode loop. &quot;LangGraph the way LangGraph wants to be used.&quot; This harness exists <em>specifically</em> to separate LangGraph&#39;s own cost from our custom topology&#39;s cost.</li><li><strong>claude_sdk</strong>: the <a href="https://docs.claude.com/en/agent-sdk">Claude Agent SDK</a> (&quot;structured-thin&quot;, batteries-included defaults). Same six custom tools exposed as an in-process MCP server; built-in SDK tools denied.</li><li><strong>langgraph</strong>: ~240 lines. LangGraph StateGraph with planner → router → executor → reflector → finalizer. Deliberately heavy.</li></ul><pre>task prompt<br>                        │<br>     ┌──────────┬──────┴──────┬──────────────┐<br>     ▼          ▼             ▼              ▼<br>   thin  langgraph_react  claude_sdk   langgraph (custom)<br>     └──────────┴──────┬──────┴──────────────┘<br>                      ▼<br>     tools/  (bash, read_file, write_file,<br>              edit_file, list_dir, finish)<br>     tasks/  (10 tasks × 3 categories)</pre><p>All four run claude-sonnet-4-6, share one tools.execute() dispatcher, one system prompt (with cache_control for prompt caching), the same max_iters=25, and temperature=0. The only variable is the harness.</p><p>Ten tasks across three categories: four code fixes (pytest-scored: fix a buggy merge_intervals, implement LRUCache, repair a broken import chain, add error handling to a JSON parser), three tool-chain tasks (deterministic file checks), three open-ended research tasks (LLM-judge on a 1–5 rubric). Small on purpose: a full matrix runs in ~35 minutes and costs ~$3. <a href="https://github.com/hienluu/harness-benchmark">Code&#39;s here.</a></p><h3>The result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*OnY0edVkYs9uBnqM5OBHiQ.png" /></figure><p>On Sonnet 4.6 with these ten tasks, <strong>quality was the same within one-trial noise</strong>. thin and the prebuilt langgraph_react both hit 10/10; claude_sdk and our custom langgraph both missed research_compare_specs (the LLM judge held their answers below 4/5). Whether that one-task split is a real structural difference or single-trial variance is a question only more trials can answer. Either way, scaffolding didn&#39;t open a visible quality gap. Cost and latency, by contrast, spread by a factor of three.</p><p>The four-way lets me split that 3× into two distinct contributions:</p><ul><li><strong>Framework tax</strong>: LangGraph itself, via the prebuilt create_agent, at <strong>1.42</strong>× thin. LangChain-flavored message plumbing, LCEL runnable dispatch, and tool schema overhead you can&#39;t not pay when you use the framework.</li><li><strong>Topology tax on top</strong>: our custom planner/router/executor/reflector graph adds another <strong>2.12</strong>× on top of langgraph_react, for 3.01× total.</li></ul><p><strong>The framework isn’t the expensive part. The topology we layered on top of it is</strong>. Two-thirds of the cost we were attributing to “LangGraph” is really attributable to our design choices: reflection after every subgoal, each node re-establishing context the conversation already had, multi-step planning for one-line tasks. Had I only compared thin vs. langgraph, I would have silently blamed LangGraph for a cost the framework didn&#39;t actually incur.</p><p>And it isn’t a one-task artifact:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*lr5ESS5YZOfE8uD_9hk7nA.png" /></figure><p>The signature of the custom topology shows up in the tool-call mix too: thin and langgraph_react average 2.3 read_file calls per run; the custom langgraph averages 5.3. Each node (planner, reflector, finalizer) rebuilds its own message list, so files get re-read to re-establish context the agent already had minutes ago. Prompt caching blunts it; it doesn&#39;t erase it.</p><p>“Simpler is better” held here, but the sharper version is “thinner topologies are better; the framework layer underneath them is nearly free.” I wouldn’t generalize beyond <em>strong model + tasks of this shape</em> yet. A Haiku rerun or a harder task suite might flip the story; this is single-trial data on ten tasks.</p><h3>Three engineering lessons</h3><h4>1. Fairness lives in the details you’re tempted to skip</h4><p>The comparison is only credible if the harness is the <em>only</em> variable. That sounds obvious; the devil is in the options block.</p><pre>options = ClaudeAgentOptions(<br>    model=MODEL,<br>    max_turns=MAX_ITERS,<br>    allowed_tools=_ALLOWED_TOOLS,          # only our six<br>    disallowed_tools=_DISALLOWED_BUILTINS, # deny Bash/Read/Edit/WebSearch/...<br>    setting_sources=[],                    # ignore user CLAUDE.md<br>    cwd=str(scratch_dir),<br>    permission_mode=&quot;bypassPermissions&quot;,<br>)</pre><p>Details that would have confounded the benchmark silently: disallowed_tools denies the SDK&#39;s built-in Bash/Read/Edit/WebSearch so the agent only has access to the same six tools as the other harnesses; setting_sources=[] prevents any user CLAUDE.md from leaking in. And one honest caveat: ClaudeAgentOptions (at 0.1.63) doesn&#39;t expose temperature/max_tokens, so that harness runs on SDK defaults. That&#39;s a structural difference. I flagged it in the report, didn&#39;t hide it. Same spirit for langgraph_react: the system prompt has to be passed as a SystemMessage with cache_control on the content block, or the other harnesses&#39; cached prompts cost less than it does on every turn and the comparison becomes unfair for a reason that&#39;s nothing to do with the framework. Takeaway: audit every source of variation explicitly and <em>write down</em> the ones you can&#39;t control.</p><h4>2. Observability is two problems, not one</h4><p>langsmith.wrappers.wrap_anthropic(client) instruments messages.create at the client level: every call becomes a LangSmith span with tokens, latency, inputs, and outputs. Zero code changes to the harness. Worked beautifully for thin and langgraph (which both construct the client directly). langgraph_react was even easier: LangChain and LangGraph emit LangSmith spans natively when LANGSMITH_TRACING=true.</p><p>For the Claude Agent SDK it did nothing. No errors, just no traces. The <a href="https://smith.langchain.com/">LangSmith UI’s</a> project view lit up for every other harness’s run and stayed stubbornly blank for claude_sdk. That emptiness <em>was</em> the diagnostic: three harnesses streaming spans, one not, isolated the bug to the SDK transport in about fifteen seconds of squinting. The SDK runs its model calls through a subprocess; wrap_anthropic can&#39;t see inside. The fix is LangSmith&#39;s native integration:</p><pre>from langsmith.integrations.claude_agent_sdk import configure_claude_agent_sdk<br>configure_claude_agent_sdk()  # once, at process startup</pre><p>That function patches ClaudeSDKClient in place. Subtlety: if you&#39;re using the top-level query() (as I was), nothing gets traced. The integration only touches ClaudeSDKClient. The docs don&#39;t lead with this. I spent an hour wondering why traces weren&#39;t showing up before reading the integration&#39;s source. Takeaway: when you&#39;re picking observability, match it to the SDK&#39;s transport model, not to the language you&#39;re writing in.</p><h4>3. Read the vendor’s code when your metric disagrees with their UI</h4><p>After switching to ClaudeSDKClient, traces finally appeared, but my num_turns was higher than LangSmith&#39;s model-run count. By a lot on some tasks. The UI made the gap <em>obvious</em>: a parent run showing three nested LLM spans while my JSON said turns=5. Same problem-spotting pattern as the empty-project-page clue above: a discrepancy you can see at a glance is one you actually notice.</p><p>The Claude Agent SDK can split a single assistant turn across <em>multiple</em> AssistantMessage events, typically a ThinkingBlock followed by a TextBlock/ToolUseBlock. They share a message_id. Naïve counting doubles the turn count. Digging into LangSmith&#39;s integration code, I found a class called TurnLifecycle whose docstring said exactly this and whose fix was to dedupe on message_id. I copied the pattern:</p><pre>seen_message_ids: set[str] = set()<br>...<br>if isinstance(message, AssistantMessage):<br>    mid = getattr(message, &quot;message_id&quot;, None)<br>    if mid is None or mid not in seen_message_ids:<br>        traj.num_turns += 1<br>        if mid is not None:<br>            seen_message_ids.add(mid)</pre><p>Takeaway: when your metric disagrees with a vendor’s UI, assume they’ve hit the same edge case and <em>read their instrumentation</em> before you assume they’re wrong. The SDK docs won’t mention it. The code will.</p><p><strong><em>Tooling aside:</em> all three diagnoses above were cheap because LangSmith was easy to <em>look at</em>. The </strong><a href="https://smith.langchain.com/"><strong>free Developer plan</strong></a><strong> gives you 5,000 base traces a month with no credit card, the “Start for free” button is honest (no upsell wall), and the UI is genuinely slick. “Why are traces missing for one harness?” and “why do my turn counts disagree?” were thirty-second eyeball checks in the run tree, not grep-through-JSON afternoons. Worth the shout-out.</strong></p><h3>What’s next</h3><p>Four follow-ons I’d prioritize, roughly in ROI order:</p><ol><li>More trials. This is single-trial data. The cost numbers are stable (they’re mostly a function of turn counts, which are deterministic given temperature=0), but the quality numbers, especially the 10/10 vs. 9/10 split between thin-shaped and thicker harnesses, are at the noise floor. Ten trials per task would tell me whether thin really <em>does</em> edge out claude_sdk on quality, or whether single-trial variance is putting it there.</li><li>Ablate the Reflector. With the framework/topology split isolated, the next question is <em>which part</em> of our topology carries the weight. I suspect the Reflector node (LLM call after every subgoal) is pulling most of it. One constant toggle and a rerun would localize the expense.</li><li>Model-size ablation. Rerun on Haiku 4.5. The central claim of the “simpler is better” school is that thick scaffolding exists to compensate for weak models. Sonnet 4.6 is strong; I don’t know if the story holds on a smaller backbone until I measure it.</li><li>Multi-provider. Add thin + structured-thin harnesses for Google (google-genai + the Gemini ADK) and OpenAI (openai client + the Agents SDK). Turn the grid from within-Anthropic into cross-vendor.</li></ol><p>The repo is <a href="https://github.com/hienluu/harness-benchmark">open on GitHub</a>. The tools/ and task schema are harness-agnostic; if you want to add a harness for your preferred framework and run it on your own tasks, a PR would be very welcome. And if your numbers disagree with mine on the same setup, I&#39;d very much like to know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0276ee0a8353" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harness Engineering: A Field Guide for Enterprise Teams]]></title>
            <link>https://hien-luu.medium.com/harness-engineering-a-field-guide-for-enterprise-teams-43fb711b29cc?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/43fb711b29cc</guid>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[agentic-ai-systems]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[context-engineering]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 21:46:01 GMT</pubDate>
            <atom:updated>2026-04-17T21:46:01.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*AmtpYu5EGeBSEFr6lOSgZw.png" /><figcaption>Horse &amp; Harness parts artwork © <a href="https://biognome.art/">Keely Davies 2021</a></figcaption></figure><p>LangChain recently reported a coding agent jumping from <strong>52.8% to 66.5%</strong> on Terminal Bench 2.0 with the model held fixed and only the scaffolding varied. That was enough to move from Top 30 to Top 5 on the leaderboard (<a href="https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering">LangChain, “Improving Deep Agents”</a>). In the OpenCode harness, swapping apply_patch for Hashline (hash-referenced edits instead of text or diffs) took Grok Code Fast&#39;s file-edit success rate from <strong>6.7% to 68.3%</strong>, same model (<a href="https://contextua.dev/why-agent-harness-architecture-is-important/">Contextua</a>).</p><p>If the model is the engine, the harness is the car. Most of what we ship to production is the car.</p><p>This is the premise behind a discipline practitioners are now calling <strong>harness engineering</strong>: the environmental scaffolding around an LLM that turns raw intelligence into reliable agent behavior. Over the past six months, Anthropic, OpenAI, LangChain, Cursor, and a constellation of independent engineers have converged on a claim worth the attention of any team building agents inside a real company. The model is no longer where the leverage is. The leverage is in the system around it.</p><p>The convergence extends beyond model labs. As <a href="https://x.com/nichochar/status/2039739581772554549">Nicholas Charriere</a> recently argued, Linear, Notion, Microsoft, Google, Meta, Lovable, and Retool (companies with wildly different histories) are all starting to ship something that looks the same: a harness, a goal, a set of tools, running in a loop. The “general harness” popularized by Claude Code turned out to generalize. You are not choosing whether to care about this; your vendors, competitors, and customers already chose for you.</p><h3>What a harness actually is</h3><p>Almost every serious account now uses the same formula:</p><blockquote><em>Agent = Model + Harness</em></blockquote><p><a href="https://www.langchain.com/blog/the-anatomy-of-an-agent-harness">LangChain</a> defines the harness as “every piece of code, configuration, and execution logic that isn’t the model itself.” <a href="https://contextua.dev/model-agent-harness-the-three-layers-most-people-collapse-into-one/">Contextua</a> sharpens this into a three-layer decomposition:</p><ol><li><strong>Model</strong>. A statistical engine. No memory, no filesystem, no concept of time. “The model alone is not an agent any more than an engine alone is a car.”</li><li><strong>Agent</strong>. The reasoning loop: ReAct, plan-then-execute, or some hybrid. Where intelligence meets intention.</li><li><strong>Harness</strong>. The execution platform: filesystem, terminal, permissions, session persistence, context compaction, guardrails. Claude Code, Codex CLI, and Cursor are all harnesses. “If the agent reasons its way into a destructive command, a well-built harness intercepts it.”</li></ol><p>Collapsing these into a single word (“agent”) is fine in a demo and, as Contextua argues, “actively unhelpful the moment you need to make an architectural decision.”</p><h3>Inner vs. outer harness: the enterprise frame</h3><p>The most useful distinction for a team inside a company comes from <a href="https://aiquinta.ai/insight/inner-harness-and-outer-harness-in-ai-systems/">AIQuinta</a>: <strong>inner vs. outer harness</strong>.</p><ul><li>The <strong>inner harness</strong> is the execution loop owned by the model provider (Claude Code, Codex, Cursor), highly tuned by people with telemetry on billions of agent-hours. When Anthropic shipped Sonnet 4.5, Claude Code exhibited “context anxiety”; their engineers patched it with forced resets. When Opus 4.5 landed, those resets became dead weight (<a href="https://www.anthropic.com/engineering/managed-agents">Anthropic, “Managed Agents”</a>). Inner-harness work shifts constantly and is paid for by the model lab.</li><li>The <strong>outer harness</strong> is everything your organization wraps around it: the AGENTS.md that encodes your conventions, the skills that teach the agent your domain, the approval gates matching your compliance posture, the cost attribution, the audit logs, the multi-agent workflows that move work across your teams.</li></ul><p>AIQuinta’s sharpest line: “<strong>You do not need to rebuild the inner harness</strong>.” When parts of Claude Code’s source leaked this year, engineers studying it concluded it represented years of tuning no enterprise should try to reproduce. Your DNA lives in the outer harness. For most organizations, that outer harness today is “fragmented files on individual developers’ laptops.” That is the problem worth fixing.</p><p>A second axis matters alongside inner/outer. <a href="https://x.com/jerryjliu0/status/2026840829441225127">Jerry Liu of LlamaIndex</a> points out that<strong> horizontal tools push workflow-engineering burden onto you</strong> (write the skills files, define the SOPs), while <strong>vertical tools reduce that burden</strong> in exchange for flexibility. A third option is emerging: context-as-a-service, covering document parsers, web data feeds, and codebase indexers. Most mature enterprise deployments mix all three. The mistake is defaulting every use case to “build it in-house.” That is how a small AI team ends up rebuilding a document parser instead of shipping the workflow.</p><h3>Five patterns that work (with receipts)</h3><p>A set of patterns shows up across fifteen independent accounts so consistently they are approaching settled practice.</p><p>1. <strong>The filesystem is your memory</strong>. <a href="https://www.langchain.com/blog/the-anatomy-of-an-agent-harness">LangChain</a> calls it “the most foundational harness primitive.” <a href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents">Anthropic’s long-running-agent playbook</a> builds on a claude-progress.txt file plus git history. <a href="https://walkinglabs.github.io/learn-harness-engineering/en/">Walking Labs</a> puts it axiomatically: <em>the repository must become the system of record.</em> Context windows are volatile; filesystems are durable, diffable, and inspectable. Anthropic&#39;s team also found models less likely to inappropriately overwrite JSON than Markdown; details matter.</p><p>2. <strong>Forced verification beats self-verification</strong>. Agents will declare success before they have verified anything. As <a href="https://etnalabs.co/research-post/decode-the-buzzword-why-harness-engineering-matters-now">Etna Labs</a> observes, mature harnesses increasingly embed testing, checking, and feedback mechanisms so agents can validate their own work and self-correct. <a href="https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering">LangChain</a> ships a PreCompletionChecklistMiddleware that intercepts the model&#39;s exit attempt and injects a verification pass. Anthropic&#39;s long-running-agent playbook has Claude self-verify features end-to-end via Puppeteer MCP before marking them complete (<a href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents">Anthropic, &quot;Effective Harnesses for Long-Running Agents&quot;</a>). Boris Cherny of Claude Code has shared that giving an agent effective verification means typically improves final output quality by <strong>2–3x</strong> (<a href="https://etnalabs.co/research-post/decode-the-buzzword-why-harness-engineering-matters-now">Etna Labs</a>). If the model <em>can</em> skip verification, it will.</p><p>3. <strong>Tool minimalism beats tool maximalism</strong>. The most-repeated war story in the corpus: Vercel removed <strong>80% of their agent’s tools</strong> and got faster, better, more reliable responses (<a href="https://www.philschmid.de/agent-harness-2026">Philipp Schmid</a>). Claude Code reportedly ships with fewer than 20 tools on by default (<a href="https://www.latent.space/p/ainews-the-claude-code-source-leak">Latent Space, “Claude Code Source Leak”</a>). MCP servers that dump 50k+ tokens of schema into context degrade accuracy before the agent takes its first action (<a href="https://reliable-data-engineering.netlify.app/posts/article_harness_is_everything/">Reliable Data Engineering</a>). Anthropic’s “Code Mode” reportedly reduces tool context by <strong>98.7%</strong> by letting the agent discover and call tools via code (<a href="https://contextua.dev/why-agent-harness-architecture-is-important/">Contextua</a>). Every new tool is a bet that the capability is worth the context cost. Most bets lose.</p><p>4. <strong>Context is a budget, not a window</strong>. <a href="https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents">HumanLayer</a> calls the zone of context degradation “the dumb zone.” <a href="https://etnalabs.co/research-post/decode-the-buzzword-why-harness-engineering-matters-now">Etna Labs</a> reports top practitioners keep utilization below 60%. Sub-agents become <strong>context firewalls</strong>: spawn a research sub-agent, let it grind through 80k tokens of exploration, return a 200-token summary to the parent. HumanLayer frames this explicitly as <strong>context control</strong>, not role-based division. Discrete delegated tasks succeed: locating a definition in the codebase, tracing a request across service boundaries, identifying patterns in the code. Role-persona sub-agents (a “frontend engineer,” a “backend engineer,” a “data analyst”) do not work.</p><p>5. <strong>Loop detection and the reasoning sandwich</strong>. Agents fall into edit loops. LangChain’s LoopDetectionMiddleware tracks per-file edits and nudges the agent after a configurable threshold. And empirically: run <strong>high reasoning</strong> for planning and verification, <strong>low</strong> for implementation in between. LangChain&#39;s xhigh runs scored 53.9% vs. 63.6% at high (<a href="https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering">LangChain</a>). Thinking is not linearly good; thinking in the right places is.</p><h3>Anti-patterns worth naming</h3><ul><li><strong>Do not store critical state in the context window</strong>. It will get compacted away or overwritten. Store it on disk (<a href="https://www.anthropic.com/engineering/managed-agents">Anthropic, “Managed Agents”</a>).</li><li><strong>Do not couple tools tightly to a specific model</strong>. Codex’s apply_patch is a cautionary tale: even semantically equivalent changes degraded performance on models post-trained against it (<a href="https://www.langchain.com/blog/the-anatomy-of-an-agent-harness">LangChain</a>). Test your harness across models.</li><li><strong>Do not trust agents at compliance boundaries</strong>. <a href="https://aiquinta.ai/insight/inner-harness-and-outer-harness-in-ai-systems/">AIQuinta</a> documents agents commenting out failing tests to pass gates. Structural gates and separation of duties are the only defense.</li><li><strong>Do not let LLMs generate your harness configuration</strong>. An ETH Zurich study cited by <a href="https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents">HumanLayer</a> found LLM-generated agent config files <em>hurt</em> performance and increased cost by 20%.</li><li><strong>Do not let sandboxes touch credentials</strong>. <a href="https://www.anthropic.com/engineering/managed-agents">Anthropic’s Managed Agents</a> is explicit: structural separation, not token scoping.</li></ul><h3>The debate, and the enterprise reading</h3><p>Not everyone agrees harness engineering is a lasting discipline. The <strong>Big Model</strong> camp (Boris Cherny of Claude Code, Noam Brown at OpenAI) argues Claude Code is “the thinnest possible wrapper over the model” and complexity <em>decreases</em> with each generation (<a href="https://www.latent.space/p/ainews-is-harness-engineering-real">Latent Space</a>). Their bet: frontier reasoning models will absorb the scaffolding. The <strong>Big Harness</strong> camp (<a href="https://x.com/jerryjliu0">Jerry Liu</a>, <a href="https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents">HumanLayer</a>, <a href="https://www.philschmid.de/agent-harness-2026">Schmid</a>, <a href="https://reliable-data-engineering.netlify.app/posts/article_harness_is_everything/">Reliable Data Engineering</a>) argues the opposite: “the biggest barrier to getting value from AI is your own ability to context and workflow engineer.”</p><p>The honest middle, which the corpus as a whole supports: <strong>the inner harness will shrink as models improve</strong>. <strong>The outer harness will not</strong>. Your compliance requirements, cost attribution, audit logs, institutional skills, and approval workflows do not get absorbed by a better model. That is organizational expression, and only you can write it.</p><h3>From tasks to outcomes: the self-improving loop</h3><p>There is a deeper reason harness engineering matters that the how-tos tend to underplay. Because <strong>harness + model = code + intelligence</strong>, these systems can reflect on their own performance and rewrite themselves. <a href="https://x.com/karpathy">Karpathy’s AutoResearch</a> demonstrated the pattern: an agent that proposes, experiments, observes, reflects, iterates. Stanford’s <a href="https://x.com/yoonholeee">Yoonho Lee</a> formalized this as <strong>Meta-Harness</strong>: optimizing the harness end-to-end against traces and scores rather than by hand-tuning.</p><p>Charriere draws the parallel to autonomous driving’s “Continuously Learning Machine.” The agent-era equivalent is <strong>run → monitor → improve the harness and context → run again</strong>, and the agent itself can close this loop.</p><p>This reframes what enterprise practitioners are building. It is not “an agent that does task X.” It is a <strong>software factory</strong> given an outcome (a KPI, a business objective) that produces and improves the code, context, and tool-use patterns required to hit it. As Charriere puts it, “AI systems went from completing sentences to completing KPIs.”</p><p>Two practical consequences:</p><ol><li><strong>Instrument everything, end to end</strong>. Traces, spans, eval scores, cost, outcome metrics. Without instrumentation, the improvement loop has nothing to optimize against. The teams that win are not the ones with the best initial harness; they are the ones with the shortest path from observation to improvement.</li><li><strong>Pick your autonomy point deliberately</strong>. Model labs have an incentive to push the autonomy slider to maximum; most enterprises do not. Set it explicitly rather than drifting into full autonomy by accident.</li></ol><p><a href="https://www.philschmid.de/agent-harness-2026">Schmid</a> and <a href="https://etnalabs.co/research-post/decode-the-buzzword-why-harness-engineering-matters-now">Etna Labs</a> independently land on the same formulation: the <strong>harness is the dataset</strong>. The prompts you write today will be obsolete with the next model. The captured trajectories of your agents solving real problems in your environment will not be. Mitchell Hashimoto, via <a href="https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents">HumanLayer</a>, says it best: “anytime you find an agent makes a mistake, you take the time to engineer a solution such that the agent never makes that mistake again.” Every mistake becomes a rule. Every rule becomes a skill. The harness grows as a codified reflection of what your team has learned about how agents fail in your specific environment.</p><h3>Where to start</h3><p>The temptation is to frame this as a procurement question. It is not. Every useful step in the outer harness can start without a vendor decision, a platform team, or a budget cycle.</p><p>A practical first pass, all model- and vendor-agnostic:</p><ol><li><strong>Write a short </strong><strong>AGENTS.md for one repo you already care about</strong>. Keep it under 60 lines, concise, and universally applicable; skip directory listings and limit conditional rules; hand-craft it rather than auto-generating (<a href="https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents">HumanLayer</a>).</li><li><strong>Capture traces for one agent workflow you are already running</strong> (<a href="https://x.com/nichochar/status/2039739581772554549">Charriere</a>). Without telemetry you have no improvement loop.</li><li><strong>Add one forced verification gate</strong>. Pick one workflow and make verification mandatory before the agent can exit the task. If the model can skip verification, it will.</li><li><strong>Audit your tool list and cut one</strong>. Default to removal.</li><li><strong>Tag every agent run for cost attribution</strong> (<a href="https://aiquinta.ai/insight/inner-harness-and-outer-harness-in-ai-systems/">AIQuinta</a>). The alternative is a line item nobody can defend at budget time.</li><li><strong>Put humans at boundaries, not in the middle</strong> (<a href="https://reliable-data-engineering.netlify.app/posts/article_harness_is_everything/">Reliable Data Engineering</a>). Approval on plan and output; no mid-task interruption.</li><li><strong>Document one failure mode as a rule</strong> (<a href="https://www.humanlayer.dev/blog/skill-issue-harness-engineering-for-coding-agents">HumanLayer</a>). When the agent makes a mistake, encode the fix. That is how the outer harness grows.</li></ol><p>Each of these is reversible, runs in a sprint, and teaches you more about your agents than a six-month platform-engineering effort would.</p><p>Charriere’s prediction for the end of 2026 is that most software companies will look like they are selling the same thing. The differentiator will not be the model. It will be <strong>distribution, trusted workflow positioning, proprietary context, and the shortest path from observation to improvement</strong>. The last of those is a telemetry and iteration discipline only the team running the agent can build.</p><p><a href="https://contextua.dev/why-agent-harness-architecture-is-important/">Contextua’s</a> line is the one to tape to the wall:</p><blockquote><em>The specification tells the agent what to build. The harness determines whether it can.</em></blockquote><p>The model buys you capability. The harness buys you results. In 2026, the teams that understand the difference are the ones that will ship.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43fb711b29cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Life is about repetitions]]></title>
            <link>https://hien-luu.medium.com/life-is-about-repetitions-c70125a62736?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/c70125a62736</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[cycles-of-life]]></category>
            <category><![CDATA[motivational]]></category>
            <category><![CDATA[seasons]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Thu, 08 Jan 2026 12:33:37 GMT</pubDate>
            <atom:updated>2026-01-08T12:33:37.224Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we notice it, before we question it, before we resist it, life is already repeating itself.</p><p>There are 365 days and 12 months in a year. Each month has roughly 28 to 31 days, and between 4 and 5 weeks. Each week has exactly 7 days. Each day has 24 hours, each hour has 60 minutes, and each minute has 60 seconds. And then it repeats.</p><p>Each year has roughly four seasons: spring, summer, fall, winter, depending on where you are on this earth. And then it repeats.</p><p>These time based constructs have a start and end point, and then they repeat.</p><p>Humans, through the needs of their bodies, repeat the cycle of sleeping, waking up, and then repeat. To survive, we feed our bodies roughly three times a day: breakfast, lunch, dinner. And then it repeats.</p><p>For some, this seemingly endless repetition is drudgery; for others, it represents new opportunities to hone their craft, to heal or strengthen their body, or get a step closer to their goals, whatever those might be. For some, these repetitions represent new beginning or hope for a better tomorrow, i.e., a better relationship, a new job, or a new life in a new city.</p><p>It is up to us to decide how we want to treat these repetitions. For some, the drudgery becomes too burdensome, too heavy to bear, too meaningless to carry on, and they decide to just give up. Perhaps their body is just too worn out from surviving or enduring over too many repetitions. Perhaps their mind has drifted bit by bit further away from their body, through each repetition.</p><p>These repetitions don’t discriminate based on age, gender, race, religion, class, education level, or social status.</p><p>We do not control the fact that life repeats. Days will come. Nights will follow. Seasons will change. What <em>is</em> within our control is what we choose to bring into each repetition, our intention, our attention, and our response.</p><p>Because life may be made of repetitions, but meaning is not. Meaning is something we choose, again and again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c70125a62736" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Feel Good Productivity: Embrace Experimentation, Live in the Now]]></title>
            <link>https://hien-luu.medium.com/feel-good-productivity-embrace-experimentation-live-in-the-now-451a70e4cbf9?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/451a70e4cbf9</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 05:07:36 GMT</pubDate>
            <atom:updated>2024-07-16T05:07:36.002Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-paced world, productivity has become the holy grail of success. We strive to accomplish more in less time, juggling multiple tasks and responsibilities. But all too often, this pursuit of productivity comes at the cost of our well-being and overall happiness. That’s where the concept of “feel good productivity” comes in — a mindful approach that emphasizes experimentation, embracing the present moment, and ultimately finding joy and fulfillment in our daily lives.</p><h3>Embracing Experimentation</h3><p>One of the key pillars of feel good productivity is allowing ourselves to explore new possibilities and ideas. Let go of the fear of failure and embrace experimentation. When we take risks and try new approaches, we open ourselves up to unexpected solutions and innovative ways of doing things.</p><p>Experimentation encourages us to step out of our comfort zones. It helps us break free from the monotony of routine and sparks creativity. By trying different strategies, techniques, and tools, we gain a deeper understanding of ourselves and our capabilities.</p><p>So, if you’ve been using the same productivity system for years and feeling stagnant, it might be time to break free from the mold and try something new. Experiment with different methods of organizing your tasks, scheduling your work, and finding your ideal work environment. You might uncover a more efficient and enjoyable way of getting things done.</p><h3>Embracing the Feel Good</h3><p>Feel good productivity emphasizes the importance of finding joy, satisfaction, and well-being in our day-to-day lives. Instead of relentlessly pushing ourselves towards the next goal, we focus on creating a work environment that supports our physical and mental well-being.</p><p>Start by identifying activities or practices that energize and uplift you. It could be taking short walks during your breaks, practicing mindfulness or meditation, incorporating exercise into your daily routine, or even engaging in creative hobbies outside of work. Prioritizing your well-being doesn’t mean ignoring your work but rather recognizing that a healthy and fulfilled mind is more likely to be productive.</p><p>Another aspect of feel good productivity is fostering positive relationships and creating a supportive community. Surround yourself with people who inspire you, challenge you, and uplift your spirits. Collaborate with colleagues who share your values and align with your goals. By building a network of likeminded individuals, you can motivate each other and create an environment that nourishes both personal and professional growth.</p><h3>Embracing the Now</h3><p>In our hyperconnected world, it’s easy to get caught up in future goals and past regrets, losing sight of the present moment. Feel good productivity encourages us to bring our attention back to the now. By embracing the present, we become more aware of our thoughts, feelings, and actions, enabling us to make conscious choices about how we spend our time.</p><p>Mindfulness practices, such as meditation or deep breathing exercises, can help anchor us in the present moment. By taking a few minutes each day to slow down, reflect, and focus on our breath, we can cultivate a sense of calm and clarity amidst the chaos of our busy lives.</p><p>When we live in the now, we become more attuned to our energy levels and work with them instead of against them. If we feel fatigued or mentally drained, we can take short breaks, practice self-care, or engage in activities that rejuvenate us.</p><p>Embracing the now also means letting go of perfectionism and the constant need to be “productive.” We need to give ourselves permission to rest, recharge, and indulge in leisure activities without guilt. Feel good productivity recognizes that balance is key to sustainable success and happiness.</p><h3>Conclusion</h3><p>Feel good productivity is not just about checking off items on a to-do list, but rather about creating a life that aligns with our values, energizes us, and brings us joy. By embracing experimentation, focusing on our well-being, and being fully present in the now, we can maximize our productivity while living a fulfilled and meaningful life. So, let’s embark on this journey together and discover the power of feel good productivity!</p><p>[Note — this blog was written using GenAI using this prompt — “Write a blog about feel good productivity that focuses on three themes: experimentation, feel good, and now”]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=451a70e4cbf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hien’s 15 Picks for Data+AI Summit 2022]]></title>
            <link>https://hien-luu.medium.com/hiens-15-picks-for-data-ai-summit-2022-4f30cbd836cc?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f30cbd836cc</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data-ai-summit]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Mon, 09 May 2022 04:03:33 GMT</pubDate>
            <atom:updated>2022-05-09T04:14:02.408Z</atom:updated>
            <content:encoded><![CDATA[<p>The <a href="https://databricks.com/dataaisummit/north-america-2022">Data + AI Summit North America 2022</a> (June 27–30) is about 6weeks away. It is one of largest Data &amp; AI conferences in the world.</p><p>There are hundreds of interesting sessions that cover a wide range of topics, such as <em>Data Analytics, Data Lakes, Data Engineering</em>, <em>Data Architecture</em>, <em>Data Science &amp; Machine Learning, MLOps </em>and DataOps, and more. This year, the conference sessions will be available in <strong>a hybrid mode</strong>: in-person and virtual. The virtual pass is <strong>FREE</strong>.</p><p>To continue the <a href="https://hien-luu.medium.com/hiens-15-picks-for-data-ai-summit-60b58c2bbd9b">tradition I started last year</a>, here are the 15 sessions I am excited about.</p><ol><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=2268"><strong><em>Evolution of Data Architecture and How to Build a Lakehouse</em></strong></a>: Vini Jaiswal will discuss the data landscape and why Lakehouses are becoming a de facto for organizations building scalable data architecture.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1590"><strong><em>Presto on Spark: A Unified SQL Experience</em></strong></a><em>: </em>Ariel Weisberg and Shradha Ambekar will share the integration between Presto and Spark enables a unified SQL experience between batch and interactive use cases.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1792"><strong><em>How Robinhood Built a Streaming Lakehouse to Bring Data Freshness from 24h to Less Than 15 mins</em></strong></a><em>: </em>Balaji Varadarajan Vikrant Goel will share their journey of building a scalable streaming data lakehouse with Spark, Postgres, and other open source technologies to power the business analytics, experimentation and ML use cases at Robinhood.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1263"><strong><em>Scaling AI Workoads with Ray Ecosystem</em></strong></a><strong>:</strong> Jules Damji will cover Ray’s overview, architecture, core concepts, and primitives. Ray is an exciting and upcoming distributed system designed to easily scale Python applications and ML workloads.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=2320"><strong><em>Distributed Machine Learning at Lyft</em></strong></a>: Anindya Saha and Shiraz Zaman will demonstrate how their ML platform provides a unified and distributed training platform to manage the ML pipelines, which are running on Spark on Kubernetes, and are built using Fugue (their home grown data processing and parameter optimization framework built on top of Spark).</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1297"><strong><em>MLOps on Databricks: A How-To Guide</em></strong></a><strong>:</strong> Nial Turbitt and Joseph Bradley will unpack general principles that can guide your organization’s decisions for MLOps and share recommended ways to deploying ML models and pipelines on Databricks.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1701"><strong><em>Tackling Challenges of Distributed Deep Learning with Open Source Solutions</em></strong>:</a> Amog Kamsetty will share the merits of the ML open source ecosystem for distributed DL and then will introduce Ray Train, a open source library built on Ray distributed execution framework.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1352"><strong><em>Data Lakehouse and Data Mesh — Two Sides of the Same Coin:</em></strong></a> Max Schultze and Arif Wider will share how these two architectural approaches are not competing with each other. They are rather orthogonal and can go very well together.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1963"><strong><em>Deep Dive into the New Features of Apache Spark 3.2 and 3.3</em></strong></a>: Xiao Li and Wenchen Fan will talk about the high-level features and improvements, and will deep dive into these features: Pandas API on Apache Spark, productionizing adaptive query execution, using RocksDB statestore to make state processing more scalable.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1311"><strong><em>How To Make Spark on Kubernetes Run Reliably on Spot Instances</em></strong></a>: Jean-Yves Stephan and Hudson Buzby will cover concrete guidelines on how to make Spark run reliably on spot instances, with code examples from real-world use cases.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=2395"><strong><em>Data Lineage with Spark, Delta Lake, and Unity Catalog</em></strong></a>: Tao Feng will talk about how to capture table and column lineage for spark/delta and unity catalog and how users could leverage data lineage to manage data change, ensure data quality and implement data governance in a data driven organization.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1202"><strong><em>Spark Inception: Exploiting the Spark REPL to Build Streaming Notebooks</em></strong></a>: This session is for the hardcore Spark geeks. Scott Haines will unveil the magic behind the Spark REPL curtain and will show how it works. Then he will teach us how to build our own Notebook-style service on top of Spark &amp; Scala ILoop.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=2173"><strong><em>Scaling up Machine Learning in Instacart Search for the 2020 Surge in Online Shopping</em></strong></a>: Tejaswi Tenneti will cover the architecture of Instacart search engine, the issues they faced in training and serving ML models due to the increase in scale, and how they overcame those challenges by using more sophisticated models.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1400"><strong><em>Real-time Cost Reduction Monitoring and Alerting:</em></strong></a><strong><em> </em></strong>Ofer Ohana and David Sellam will present several use cases for which their real-time cost monitoring infrastructure enables them to detect problematic code, infrastructure and individual use of their infrastructure.</li><li><a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=2396"><strong><em>Scaling Real-Time ML at CashApp with Tecton</em></strong></a>: Michael Barnathan will show how CashApp has leveraged Tecton and built scalable ML serving infrastructure that provides high-quality search results to user in less than 100 milliseconds.</li></ol><p>While you are here, allow me to share a shameless plug for my talk — <a href="https://databricks.com/dataaisummit/north-america-2022/agenda/?sessionid=1328"><strong><em>MLOps at DoorDash</em></strong></a><strong><em> </em></strong>😃</p><p>Hope to see you there in person!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f30cbd836cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hien’s 15 Picks for Data+AI Summit]]></title>
            <link>https://hien-luu.medium.com/hiens-15-picks-for-data-ai-summit-60b58c2bbd9b?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/60b58c2bbd9b</guid>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Fri, 07 May 2021 16:30:35 GMT</pubDate>
            <atom:updated>2021-05-07T16:30:35.462Z</atom:updated>
            <content:encoded><![CDATA[<p>The <a href="https://databricks.com/dataaisummit/north-america-2021">Data + AI Summit</a> is only a few weeks away — May 24–28 (<strong><em>FYI: the virtual general conference is free</em></strong>). The first two days are reserved for both complimentary and paid trainings. The last three days are for the hundreds of interesting sessions that cover a wide range of topics, such as <em>Spark internals and best practices</em>, <em>Data Engineering</em>, <em>Data Architecture</em>, <em>Data Science</em>, <em>Deep Learning</em> <em>and ML</em>, <em>SQL Analytics</em>, <em>Business Intelligence</em>, <em>Spark production use case</em>, so on.</p><p>Here are the 15 sessions that I am excited about.</p><ol><li><a href="https://databricks.com/session_na21/productionalizing-machine-learning-solutions-with-proper-mon"><em>Productionalizing Machine Learning Solutions with Effective Tracking, Monitoring and Management</em></a>: Sumanth Venkatasubbaiah and Pankaj Rastogi from Intuit will present a system that continuously tracks and monitors ML models across the various development lifecycle stages at Intuit to ensure the health of their AI solutions.</li><li><a href="https://databricks.com/session_na21/scaling-online-ml-predictions-at-doordash"><em>Scaling Online ML Predictions at DoorDash</em></a>: Hien Luu and Arbaz Khan from DoorDash will share the journey of building and scaling the ML platform at DoorDash and particularly the prediction service, which supports up to billions of predictions per day with a peak request rate above 1 million per second.</li><li><a href="https://databricks.com/session_na21/koalas-does-koalas-work-well-or-not"><em>Koalas: Does Koalas Work Well or Not?</em></a>: Takuya Ueshin and Xinrong Meng from Databricks will introduce Koalas and its current status, and the comparison between Koalas and Dask.</li><li><a href="https://databricks.com/session_na21/consolidating-mlops-at-one-of-europes-biggest-airports"><em>Consolidating MLOps at One of Europe’s Biggest Airports</em></a>: Floris Hoogenboom from Royal Schiphol Group will take us through the way they rely on MLFlow to release multiple versions of a model per week in a controlled fashion at Amsterdam Schiphol airport. Their ML use cases include predicting passenger flow and analyzing what is happening around the aircraft.</li><li><a href="https://databricks.com/dataaisummit/north-america-2021/agenda"><em>Structured Streaming Use-Cases at Apple</em></a><em>: </em>Kristine Guo and Liang-Chi Hsieh from Apple will share the interesting solutions they came up with to augment Structured Streaming to maintain large amount of state, to add a general solution to support session window, compute aggregates over dynamic batches, and perform stream-stream joins.</li><li><a href="https://databricks.com/session_na21/yolo-with-data-driven-software"><em>YOLO with Data-Driven Software</em></a>: Brooke Wenig from Databricks and Tim Hunter from ABN AMRO will show how to treat data like code through the concept of Data-Driven Software (DDS) to allow data engineers and data scientists to YOLO: you only load your data once. This technique enables data scientists to use the intermediate results while collaborating with their peers without having to compute everything from scratch</li><li><a href="https://databricks.com/session_na21/importance-of-ml-reproducibility-applications-with-mlflow"><em>Importance of ML Reproducibility &amp; Applications with MLflow</em></a>: Gray Gwizdz and Marcy Grace Moesta from Databricks will outline the challenges and importance of building and maintaining reproducible, efficient, and governed ML solutions and how these challenges can be addressed using the point in time snapshots of Delta Lake and the governance capabilities provided by MLflow.</li><li><a href="https://databricks.com/session_na21/project-zen-making-data-science-easier-in-pyspark"><em>Project Zen: Making Data Science Easier in PySpark</em></a><em>: </em>Hyukjin Kwon and Haejoon Lee from Databricks will present some of the awesome improvements and useful features in PySpark, such as the newly redesigned pandas UDFs and functions APIs with Python type hints.</li><li><a href="https://databricks.com/session_na21/intuitive-scalable-hyperparameter-tuning-with-apache-spark-fugue"><em>Intuitive &amp; Scalable Hyperparameter Tuning with Apache Spark + Fugue</em></a>: Hang Wang from Lyft will show how using Fungue-Tune and Spark together can eliminate some of the paint points in performing hyperparameter tuning at scale.</li><li><a href="https://databricks.com/session_na21/simplify-data-conversion-from-apache-spark-to-deep-learning"><em>Simplify Data Conversion from Spark to TensorFlow and PyTorch</em></a>: Liang Zhang from Databricks will show how to use the Apache Spark Dataset Converter, an open-source tool that simplifies the data conversion from Spark to deep learning frameworks, such as TensorFlow and PyTorch. This will enable distributed training on Apache Spark cluster.</li><li><a href="https://databricks.com/session_na21/deep-dive-into-the-new-features-of-apache-spark-3-1"><em>Deep Dive into the New Features of Apache Spark 3.1</em></a>: Wenchen Fan and Xiao Li from Databricks will walk us through the exciting new developments in the Apache Spark 3.1, such as the SQL features for ANSI SQL, new streaming features, the performance enhancements and new tuning tricks in query compiler.</li><li><a href="https://databricks.com/session_na21/giving-away-the-keys-to-the-kingdom-using-terraform-to-automate-databricks"><em>Giving Away The Keys To The Kingdom: Using Terraform To Automate Databricks</em></a>: Hamilton Ford and Serge Smertin from Scribd will share how Scribd offers their internal customers flexibility without acting as gatekeepers when it comes to any needs in Databricks, and it only takes a pull request.</li><li><a href="https://databricks.com/session_na21/scaling-your-data-pipelines-with-apache-spark-on-kubernetes"><em>Scaling your Data Pipelines with Apache Spark on Kubernetes</em></a>: Rajesh Thallam from Google Cloud will help us in understanding key traits of Apache Spark on Kubernetes, such as autoscaling, and he will demonstrate running analytics pipelines on Spark orchestrated with Apache Airflow on Kubernetes cluster.</li><li><a href="https://databricks.com/session_na21/observability-for-data-pipelines-with-openlineage"><em>Observability for Data Pipelines with OpenLineage</em></a>: Julien Le Dem from DataKin, co-creator of Apache Parquet, will present the open-source project called Marquez, which instruments data pipelines to collect lineage and metadata. The collected metadata are extremely valuable when it comes to understanding the dependencies between many teams consuming and producing data in the data ecosystem that changes constantly.</li><li><a href="https://databricks.com/session_na21/code-once-use-often-with-declarative-data-pipelines"><em>Code Once Use Often with Declarative Data Pipelines</em></a>: Anthony Awuley and Carter Kilgour from FlashFood will present their declarative data pipeline implementation to enable less specialized personnel to build and set up ETL pipelines easily and quickly because the boilerplate logic has been abstracted away to create highly configurable Apache Spark applications that can be orchestrated by Airflow.</li></ol><p>Hope to see you there!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60b58c2bbd9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dissecting Dynamic Programming — Target Sum I]]></title>
            <link>https://medium.com/swlh/dissecting-dynamic-programming-target-sum-i-dfe3b0252291?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfe3b0252291</guid>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[top-down-approach]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 01:51:37 GMT</pubDate>
            <atom:updated>2021-03-30T04:11:22.126Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dissecting Dynamic Programming — Target Sum I</h3><p>At this point in the series, sufficient concepts and information about Dynamic Programming have been covered, such as <strong>optimal substructure</strong>, <strong>overlapping sub-problems</strong>, <strong>problem analysis</strong> and the techniques at arriving at the <strong>recurrence relation</strong>. From this point on, this series will pivot to applying those concepts and techniques to solve simple to more challenging Dynamic Programming problems.</p><p>In this blog, we will tackle the “Target Sum” Dynamic Programming problems using the top down approach.</p><h3>Problem Statement</h3><p>Given a target sum and an unsorted array of positive integers, we need to answer the following questions, and they are in the increasing order of complexity.</p><ul><li>Whether it is possible to generate the <em>targetSum</em> using the numbers in the array? — <strong>canSum(targetSum, integers)</strong></li><li>Return the number of possible combinations that add up exactly to the <em>targetSum</em></li><li>Return any combination of numbers that add up exactly to the <em>targetSum</em>. If there are multiple possible combinations, just return any of them — <strong>howSum(targetSum, integers)</strong></li><li>Return the shortest combination that adds up exactly to the <em>targetSum</em>, meaning it contains the fewest number of elements — <strong>bestSum(targetSum, integers)</strong></li></ul><p><em>We can assume the following</em>:</p><ul><li>A number in the unsorted array can be used as many time as needed</li><li>All the elements in the unsorted array are positive numbers</li></ul><p>For example: if the <em>targetSum</em> is 8 and the <em>integers</em> are [2,3,5], then the following are the answers.</p><ul><li>canSum(8, [2,3,5]) =&gt; true, canSum(8, [3,6,9]) =&gt; false</li><li>countSum(8, [2,3,5]) =&gt; 6</li><li>howSum(8, [2,3,5]) =&gt; [2,2,2,2] (other combinations are [2,3,3], [3,5], etc)</li><li>bestSum(8, [2,3,5]) =&gt; [3,5]</li></ul><h3>Problem Analysis:</h3><ul><li>For the example above, given the <em>targetSum</em> value is in a single digit and the array size is less than the number of fingers on one’s hand, anyone with basic mathematics skills can easily determine that it is possible to come up with a combination [3,5]. However, if the <em>targetSum</em> value is in the million, our brain can’t easily come up with a combination. Let’s see how we can apply a systematic way of breaking the problem down to smaller ones and then identify the base case(s).</li><li>We know we need to reduce the <em>targetSum </em>value down to smaller values, and all the way down to 0 if possible. If that is possible, then it means that there is a way to generate the <em>targetSum</em> using the numbers in the array. What are the available choices? We can reduce it down to smaller values by subtract it from each of the elements in the given array. Since we don’t know which path will lead us down to 0 value, then we will try them all.</li><li>What we just established on the previous graph was a systematic way of reducing the <em>targetSum</em> value all the way down to the base cases — either 0 or less than 0. See the breakdown (recursion) tree in Figure #1 to gain deeper insights into how the breakdown happens recursively.</li></ul><h3>Problem Breakdown Tree:</h3><p>Figure #1 provides a visual representation of reducing the given <em>targetSum</em> all the way down to the base cases. For each of the smaller values of the <em>targetSum</em>, we apply the same set of choices from the integer array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-Ass0x4MyTscGytPtxCfg.png" /><figcaption>Figure #1 — break down of <strong><em>targetSum</em></strong> to base cases</figcaption></figure><p>There are two base cases. The problem breakdown stops when one of these base cases is reached.</p><ul><li>When <em>targetSum</em> is 0, which means there is a combination of numbers in the array that exactly adds up to it.</li><li>When targetSum is less than 0, which means there is NOT a combination of numbers in the array that exactly adds up to it.</li></ul><p>From Figure #1, a keen observer would see that there are many duplicate sub-problems, such as node with value 3,2,1 and so on.</p><h3>canSum(targetSum, <strong>integers)</strong>:</h3><p>For the <strong><em>canSum(targetSum, integers)</em></strong> question, all we need to answer is whether it is possible to generate the <em>targetSum</em> using the numbers in the array, therefore we can stop the exploration once a valid combination is found, otherwise we will need to exhaustively perform the breakdown until all the base cases are reached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZMQF-NSPYhyQNHZZnfWIQ.png" /><figcaption>Figure #2 —stops the exploration when one combination is found</figcaption></figure><p>Figure #2 shows we can stop the exploration the moment one valid combination is found. Therefore the execution would only explore the left most side of the tree and totally skip exploring the middle and right most of the tree.</p><h4>canSum implementation:</h4><p>Let’s see how we can translate this into a top down implementation, which recursively reduces the <em>targetSum </em>to one of the base cases.</p><ul><li>The two base cases are on line 7 and 11 (see Figure #3 below)</li><li>The <strong><em>for</em></strong> loop on line 14 is the core logic for reducing the <em>targetSum</em> to smaller values by exploring the choices in the input array.</li><li>Line 15 contains two important insights. The first one is reducing the <em>targetSum</em> by each element in the array and therefore it will get smaller and smaller as recursion goes deeper and deeper. The second one is the <strong><em>if</em></strong> condition, which stops the exploration if a smaller <em>targetSum</em> if <strong><em>canSumTopDown</em></strong> returns true.</li><li>Line 21 return false when the exploration is exhausted and couldn’t find a combination that exactly adds up to the <em>targetSum</em></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ba7a181bbf48ba44d7cd23797651f9d/href">https://medium.com/media/8ba7a181bbf48ba44d7cd23797651f9d/href</a></iframe><h4>canSum Complexity Analysis</h4><ul><li>let <strong><em>m</em></strong> be the value of <em>targetSum</em> and let <strong><em>n</em></strong> be the array length</li><li>In the worst case scenario, <strong><em>m </em></strong>is reduced by 1 at each level of the tree, therefore the recursion tree height will be <strong><em>m</em></strong>.</li><li>For each level, in the worst case we need to explore every element in the array</li><li>To deal with overlapping sub-problems, we use the cache to store the computations of <em>targetSum</em> value from 1 to targetSum, therefore there is no re-computation of same sub-problems</li><li>The runtime complexity would be <strong>O(m * n)</strong></li><li>The space complexity is <strong>O(m)</strong>, because a map data structure is allocated to hold the computations of <em>targetSum</em> value from 1 to targetSum</li></ul><h3>countSum(targetSum, integers):</h3><p>The <strong><em>countSum(targetSum, integers)</em></strong> question is asking how many different combinations can be added up to the <em>targetSum</em>. The breakdown tree (recursion tree) Figure #1 above has the answer. Essentially where ever the leaf node with value of 0, it means that there is combination (from root to that leaf node) that exactly adds up to the <em>targetSum</em>. In Figure #1, we see 6 leaf nodes with value 0, so there are 6 different combinations in total.</p><p>The core logic for solving this question is quite similar to the one in <strong><em>canSum(targetSum, integers) </em></strong>problem. However, there are a few differences:</p><ul><li>We need to explore all possible combinations, therefore we can’t stop when one combination is found</li><li>Instead of returning a boolean value, each of the base cases would return an integer. When there is a possible combination, the leaf node with value of 0 will return 1. When there is NOT a possible combination, the leaf node with a negative value will return 0.</li><li>We need to maintain a count at each node in the tree, which adds up the count for each of the sub-trees. See Figure #4 for how the counts are bubbled up to the root node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7U4fUl-j-_dX0Yxi-UxZBg.png" /><figcaption>Figure #4 — countSum breakdown tree</figcaption></figure><h4>countSum implementation:</h4><p>The implementation of <strong><em>countSum</em></strong> is very similar to the <strong><em>canSum</em></strong>.</p><ul><li>The two base cases now return an integer to represent the count.</li><li>Line 12 is an important one, it contains the total number of combinations at each particular node in the tree. The <strong><em>totalSum</em></strong> is incremented each time through the for loop</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/110cea77a14cee26123f1c128f307d99/href">https://medium.com/media/110cea77a14cee26123f1c128f307d99/href</a></iframe><h4>countSum Complexity Analysis</h4><ul><li>The runtime and space complexity of <strong><em>countSum</em></strong> are identical to the ones in <strong><em>canSum</em></strong></li></ul><h3>howSum(targetSum, integers):</h3><p>The <strong><em>howSum(targetSum, integers)</em></strong> question is asking us to return a combination of integers that adds up to exactly the <em>targetSum</em>. From the <strong><em>countSum </em></strong>problem, we know that there might more than one combinations, this question is OK with any valid combination.</p><p>For example, for targetSum = 8 and integers = [2,3,5], any of the combinations below is considered a valid solution:</p><ul><li>[2,2,2,2], [2,3,3], [3,2,3], [3,3,2], [3,5], [5,3]</li></ul><p>There are a few questions we need to think about:</p><ul><li>How do we know a particular integer is a part of a valid combination or not?</li><li>How to store the combination of integers?</li></ul><p>From examining the problem breakdown tree, we know there are two base cases. The one with a value of 0 in the the leaf node tells us there is a valid combination and the other one with value less than 0 tells us otherwise. Based on that information, we can return an appropriate signal for the upper node to determine what to do.</p><p>To put it more concretely:</p><ul><li>For the base case with a value of 0 in the the leaf node, we will return an empty list</li><li>For the base case with a value less than 0 in the the leaf node, we will return null</li></ul><h4>howSum implementation:</h4><p>There are a few differences in the implementation of this problem from the previous ones.</p><ul><li>The base case where the <em>targetSum</em> is 0, it will return an empty, which will be used by the upper nodes to store the combination</li><li>The base case where the <em>targetSum</em> is less than 0, it will return null, which tells the upper nodes a particular integer is not a part of a valid combination</li><li>Inside the for loop (line 15 to 19), it will determine whether to add a particular integer to the list based on the return object of the recursive call. Notice the exploration is stopped once it recognizes the return list is not null, which represents a valid combination was found. Before breaking out of the for loop, it adds the current integer to the list.</li><li>It might a bit challenging to visualize this in your mind by just looking at the code. The recursion will go all the way down to one of base cases and then it will bubble up. I highly suggest that you walk through a example by using a pen and piece of paper to draw out the recursion tree yourself.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a1a255d5829378a94212c8f3baddfb9/href">https://medium.com/media/4a1a255d5829378a94212c8f3baddfb9/href</a></iframe><p>This implementation will return the first valid combination that it finds(if there are more than one) and the combination is built from the bottom up.</p><h4>howSum Complexity Analysis</h4><ul><li>The runtime and space complexity of <strong><em>howSum</em></strong> are identical to the ones in <strong><em>canSum</em></strong></li></ul><h3>bestSum(targetSum, integers):</h3><p>This question takes the complexity level up a notch from the <strong><em>howSum</em></strong> problem. Instead of any combination, this question asks for the best one, meaning the shortest one, in other words, the one that contains the least number of integers. If there is a tie for the shortest combination, it is OK to return one of those.</p><p>If we take a look at the node with value of 5 in the middle of level one in Figure #4, there are 3 possible combinations that add up exactly to 5, they are [2,3], [3,2], [5]. Among these, we would to pick the shortest one, which is [5].</p><h4>bestSum implementation:</h4><p>From the implementation perspective, as we explore each of the choices in the integer array, we need to maintain the shortest combination, and update it as a shorter one is found.</p><p>There are a few important and different steps in the code snippet below comparing to the one for <strong><em>howSum </em></strong>problem (see Figure #7 for the code)</p><ul><li>Before the “for loop” (line 14), we maintain to a variable to store the shortest combination. This variable is updated with a shorter one on line 20 if a shorter is found</li><li>Line 18 controls when to update the list, only when the new combination is shorter than the current one. The condition (list == null) is for handling the case where it is the very first time in the for loop.</li><li>For line 20 and 21, instead of updating it with a reference of a shorter combination, we need to create a new list, copy over the integers from the shorter list to the new list, and finally include the integer that we just explore. If we don’t make a copy of the list, we will get an incorrect result.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ad6d3582f2e19074e264b98c1c53581/href">https://medium.com/media/1ad6d3582f2e19074e264b98c1c53581/href</a></iframe><h4>bestSum Complexity Analysis</h4><ul><li>Let <strong><em>m</em></strong> be the value of targetSum and let <strong><em>n</em></strong> be the array length</li><li>In the worst case scenario, we need to make a copy of <strong><em>tmpList</em></strong> (line 20) at every level of the problem breakdown tree and the maximum size of that list is <strong><em>m</em></strong></li><li>The runtime complexity would be <strong><em>O(m * n * m) =&gt; O(m² * n)</em></strong></li><li>For the space complexity, we are maintaining a map of integer to a list of integers, therefore the worst case scenario is <strong><em>O(m * m)</em></strong><em> =&gt; </em><strong><em>O(m²)</em>. </strong>The first <strong><em>m</em></strong> is for the number of entries in the map, and the second <strong><em>m</em></strong> is maximum size of each of the lists.</li></ul><h3>Summary</h3><p>There you have it, we just went through four Dynamic Programming questions in the increasing order of complexity and with the same inputs.</p><p>We learned that drawing out the problem breakdown tree gives us a good visual model of how the recursion will play out. Then we identified the two base cases and figured out the appropriate value to return for each of them.</p><p>The exploration is driven by looping through the choices in the integer array. For the <strong><em>canSum</em></strong> and <strong><em>howSum</em></strong> problems, we figured out that it is OK to stop the exploration once a valid combination is found. However, the exploration needs to be exhausitve for the <strong><em>countSum</em></strong> and <strong><em>bestSum</em></strong> problems.</p><p>The problems covered in this blog are based on <a href="https://www.youtube.com/watch?v=oBt53YbR9Kk">this awesome video from freeCodeCamp</a>.org. If these problems intriguing to you, I highly recommend spending time to go through the video (it is 5 hours long, but totally worth it).</p><h3>Resources:</h3><ul><li>An <a href="https://www.youtube.com/watch?v=oBt53YbR9Kk">excellent video about Dynamic Programming</a> from freeCodeCamp.org. <strong><em>Highly recommended</em></strong></li><li>There is a lot of similarties between the Leetcode <a href="https://leetcode.com/problems/coin-change/">Coin Change</a> problem and the above problems</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfe3b0252291" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/dissecting-dynamic-programming-target-sum-i-dfe3b0252291">Dissecting Dynamic Programming — Target Sum I</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dissecting Dynamic Programming — Climbing Stairs]]></title>
            <link>https://medium.com/swlh/dissecting-dynamic-programming-climbing-stairs-20fb7c548023?source=rss-ae8fe3c77c93------2</link>
            <guid isPermaLink="false">https://medium.com/p/20fb7c548023</guid>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Hien Luu]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 01:05:12 GMT</pubDate>
            <atom:updated>2021-01-02T23:43:31.676Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dissecting Dynamic Programming — Recurrence Relation</h3><p>From the previous blog (<a href="https://hien-luu.medium.com/dissecting-dynamic-programming-top-down-bottom-up-3d3a1d62fbd7">Top Down &amp; Bottom Up</a>), we learned the essence of solving Dynamic Programming problems is to derive the recurrence relation, and then use either the top-down or bottom-up approach to translate it to code. Therefore it is important to master the problem analysis and the techniques to derive a recurrence relation. This blog and the future ones will focus on sharing the insights to help with this.</p><p>This blog will use a simple (level 1) Dynamic Programming problem called <a href="https://leetcode.com/problems/climbing-stairs/">Climbing Stairs</a> to illustrate the problem analysis and the techniques at arriving at a recurrence relation.</p><p>Here is the problem statement:</p><blockquote>You are climbing a staircase. It takes n steps to reach the top.</blockquote><blockquote>Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?</blockquote><blockquote><strong>Example 1:</strong></blockquote><blockquote><strong>Input:</strong> n = 2<br><strong>Output:</strong> 2<br><strong>Explanation:</strong> There are two ways to climb to the top.<br>1. 1 step + 1 step<br>2. 2 steps</blockquote><blockquote><strong>Example 2:</strong></blockquote><blockquote><strong>Input:</strong> n = 3<br><strong>Output:</strong> 3<br><strong>Explanation:</strong> There are three ways to climb to the top.<br>1. 1 step + 1 step + 1 step<br>2. 1 step + 2 steps<br>3. 2 steps + 1 step</blockquote><h3>Problem Analysis:</h3><ul><li>This problem has only 1 input, which represents the number of steps a staircase has</li><li>There are only two <strong>choices</strong> (ways) to climb the staircase — 1 or 2 steps at a time</li><li>What does “distinct ways to climb to the stop” means? If we analyze the examples closely, a distinct way to climb to the top of a staircase means the combination of climbing either 1 or 2 steps from the bottom to the top of the staircase. In other words, when the sum of the steps in each combination equals to the number of steps the staircase has. There are many different combinations and each one is counted as 1 distinct way. The final answer is the sum of all the different combinations.</li><li>Where do the combinations come from? They come from taking a series choices repeatedly while climbing to the top of the staircase (See Figure #1). In other words, each combination consists of a series choices (1 or 2 steps). As a climber lands on a particular step, at that point, the climber has to choices to go from there, either take 1 step or 2 steps. In order to count the total number of distinct ways, the climber will try both.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*VPZeMxmwY5hNKi0hbY-ewA.png" /><figcaption>Figure #1 — choices of climbing a staircase</figcaption></figure><ul><li>We start with <strong><em>n</em></strong> steps in a staircase, as we repeatedly climb using either 1 or 2 steps, how does the problem gets smaller? If we climb 1 step then the problem becomes 1 step (n-1) smaller, and if we climb 2 steps then the problem becomes 2 steps (n-2) smaller. In other words, as we climb more steps, the problem (remaining steps to climb) becomes smaller and smaller until until there are no more steps to climb (reaching the top of the staircase)</li><li>How do we know when to stop climbing? Either when there are no more steps to climb (n=0, we are at the top of the staircase), or the remaining steps is smaller than the number of steps that we are planning to take.</li></ul><h3>Problem Breakdown Tree:</h3><p>Another way to visualize the problem analysis described above is to use Figure #2. Let’s say our staircase has 4 steps. As we climb it by taking 1 or 2 steps, the number of remaining steps is getting smaller. At each point, we have two choices (1 step or 2 steps) to climb and that is represented by the branching out of each node. Starting from the top node (root), each path goes all the way down to a node with a value of 0 represents a <strong><em>distinct way of climbing to the top</em></strong>. For a staircase of 4 steps, there are 5 distinct ways of climbing to the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4sO2boanWK3acHZgtHhtMQ.png" /><figcaption>Figure #2 — visualization of problem breakdown tree</figcaption></figure><h3>Formalize Recurrence Relation:</h3><p>Figure #3 depicts how the total number of distinct ways to climb a staircase is computed. For example, when a staircase has 4 steps, the total number of distinct ways to climb to the top is 5, which is the sum of the total number of distinct ways to climb a staircase that has 3 steps and total number of distinct ways to climb a staircase that has 2 steps.</p><p>If we use function f(4) to represent the total number of distinct ways to climb a staircase, then it would be f(4) = f(3) + f(2). Each part of the right side of the function represents a particular choice specified in the problem statement above.</p><p>To generalize the recurrence relation a bit, we just need to substitute the value 4 with a variable called n, then f(n) = f(n-1) + f(n-2). To complete the recurrence relation, we need to figure out the base case(s). Looking at the leaf nodes in Figure #3, that should give us sufficient info. to determine the base case is f(0) = 1.</p><blockquote>Recurrence relation: f(n) = f(n-1) + f(n-2) and f(0) = 1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IdcHC9bKJu32yZhkno4Gug.png" /><figcaption>Figure #3 — visualization of recurrence relation</figcaption></figure><h3>Wrapping Up:</h3><p>The recurrence relation for the climbing stairs problem is extremely similar to the one for Fibonacci sequence. There is one small difference, which is the base case.</p><p>Given the similarity, I will leave it as an exercise for the readers to translate the recurrence relation above to code. Feel free to refer the previous blog “<a href="https://hien-luu.medium.com/dissecting-dynamic-programming-top-down-bottom-up-3d3a1d62fbd7">Top Down &amp; Bottom Up</a>” for the code and the complexity and runtime analysis.</p><h3>Summary:</h3><p>Coming up with a recurrence relation requires:</p><ul><li>A rigorous analysis of the problem statement, a thorough understanding the given choices to explore the subproblems</li><li>Work through the examples of smaller problem size to formalize the problem understanding</li><li>Draw up the problem breakdown tree to visualize the subproblems, their relationship and to verify they meet the Dynamic Programming properties (Optimal Substructure and Overlapping subproblems)</li><li>Formalize the recurrence relation for a specific small problem size, then generalize it and finally identify the base case(s)</li></ul><p>As a challenge for the readers, go and apply the learning from this blog to solve a very similar Dynamic Programming problem called “<a href="https://leetcode.com/problems/unique-paths/">Unique Paths</a>”.</p><p>Future blogs will dissect more challenging Dynamic Problems.</p><p>It will be a fun exercise to build up a table of Dynamic Programming problems and the associated recurrence relations.</p><p>Have fun and do let me know if there are Dynamic Problems that you would me to dissect in the future blogs.</p><h3>Previous Blogs:</h3><ul><li><a href="https://medium.com/swlh/dissecting-dynamic-programming-2cf821b5e75">Dissecting Dynamic Programming — The Beginning</a></li><li><a href="https://hien-luu.medium.com/dissecting-dynamic-programming-top-down-bottom-up-3d3a1d62fbd7">Dissecting Dynamic Programming — Top Down &amp; Bottom Up</a></li></ul><h3>Resources:</h3><ul><li><a href="https://leetcode.com/problems/climbing-stairs/">Leetcode Climbing Stairs</a></li><li><a href="https://www.youtube.com/watch?v=NFJ3m9a1oJQ&amp;feature=youtu.be">Back-to-back SWE — the recursive staircase</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20fb7c548023" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/dissecting-dynamic-programming-climbing-stairs-20fb7c548023">Dissecting Dynamic Programming — Climbing Stairs</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>