Get your free personalized podcast brief

We scan new podcasts and send you the top 5 insights daily.

When migrating a large codebase, asking an LLM to perform the translation is risky due to its non-deterministic nature. A better approach is to enlist AI to help write a custom, deterministic translation program. This contains the AI's stochasticness to the tool-building phase, not the execution phase.

Related Insights

To achieve true deterministic AI, transition conditions must be implemented as explicit code with deterministic semantics (e.g., a probability threshold). Relying on natural language instructions in prompts to guide an LLM is merely a simulation of control, not an enforceable structural guarantee.

A practical hack to improve AI agent reliability is to avoid built-in tool-calling functions. LLMs have more training data on writing code than on specific tool-use APIs. Prompting the agent to write and execute the code that calls a tool leverages its core strength and produces better outcomes.

Don't give LLMs full control. Use deterministic code for core logic, validation, and enforcing rules. Delegate only tasks requiring flexibility or understanding of unstructured input to the LLM, treating it as a specialized component, not the entire system.

When tasked with building an AI 'harness,' models like GPT and Opus may instinctively generate purely deterministic code, resisting the inclusion of an AI agent within the structure. Developers must prompt very specifically about the desired workflow and where non-deterministic AI components should be integrated.

A powerful cost-saving strategy is to use AI as a one-time tool to generate complex, deterministic code for a recurring problem. This avoids the high, cumulative cost of running the same reasoning task through a pay-per-use LLM, shifting the expense from operational credits to a one-time development effort.

Tools like LangGraph support state machine patterns, but don't guarantee them. The critical shift is an engineering discipline where orchestration logic is explicitly designed and bounded by developers, rather than being improvised by the LLM at runtime.

Separate AI's role. Use an AI assistant to write reliable, deterministic code for structuring data (e.g., pulling Slack messages via API). Then, apply a live AI model only for the subjective task, like categorizing message urgency. This hybrid approach creates a more robust and controllable system.

A full-codebase rewrite using AI, like Bun's Zig-to-Rust migration, is risky. It exchanges a set of known bugs for new, unknown ones. Users become the unfortunate discoverers of these issues, as even comprehensive test suites can't capture every implicit behavior (Hiram's Law).

For tasks too complex for a single prompt, Krieger uses "dynamic workflows." This involves designing a multi-step plan (e.g., understand, spec, translate, test) which the AI executes autonomously. This allowed Fable to port a complex Python project to TypeScript over a weekend.

For complex, one-time tasks like a code migration, don't just ask AI to write a script. Instead, have it build a disposable tool—a "jig" or "command center”—that visualizes the process and guides you through each step. This provides more control and understanding than a black-box script.