Harness Engineering Made EASY: Fix an AI Stuck in 2023

From the creator

Harness engineering, explained simply, then built and run in 26 lines of free, open-source code. Same AI, same question: "What is today's date?" On its own, the AI said October 2023. With a harness around it, it gave the real date, every time. What you'll learn - What a harness is (the old meaning, and the AI meaning: everything you build around the model) - Why an AI guesses the date, and why a guess sounds as sure as a fact - The four parts in our harness: instructions, a tool, a check and a limit - How to install PraisonAI and run your own harness, with every line explained - Why the check is the part most people skip, and what it does when the AI is wrong Try it yourself 1. Install Python 3.10 or newer (free, from python.org). On Windows, tick "Add Python to PATH" in the installer. 2. Get an OpenAI API key at platform.openai.com and add a few dollars of credit (the key will not work with no credit). Each run of this code cost under a tenth of a cent in my tests. 3. Open the Terminal app (Mac: Command + Space, type Terminal) or PowerShell (Windows) and install PraisonAI: pip install praisonai (On a Mac without a virtual environment, use pip3 and python3 instead of pip and python.) 4. Tell your computer your key. This lasts for this terminal window only: Mac: export OPENAI_API_KEY="your-key-here" Windows PowerShell: $env:OPENAI_API_KEY="your-key-here" 5. Copy the code below into a plain-text file called agent_harness.py (not a Word or TextEdit rich-text file), in the folder your terminal is in. Keep the spaces at the start of the lines exactly as they are. 6. Run it: python agent_harness.py The code (agent_harness.py) from datetime import date from praisonaiagents import Agent def today(): """Get today's date from the computer's clock.""" return date.today().strftime("%A %d %B %Y") def check(output): if str(date.today().year) in output.raw: print("CHECK: passed") return True, output print("CHECK: failed, sending it back") return False, "Wrong year. Use the today tool." agent = Agent( name="Assistant", instructions="Answer in one sentence. Never guess a date: use the today tool.", tools=[today], guardrails=check, execution={"max_iter": 3}, model="gpt-4o-mini", ) answer = agent.start("What is today's date?") print("WITH HARNESS SAYS:", answer) print("REAL DATE IS: ", today()) What you should see - A box that says "Tools: today", then "CHECK: passed", then the real date. The answer is printed twice: once in PraisonAI's box, and once by the last lines of the code. - If the check ever fails, you will see "CHECK: failed, sending it back" and a WARNING line. That is the harness working. - Stuck for more than a minute? Press Ctrl+C and run it again. In my tests, about 1 run in 8 waited on an OpenAI request until it timed out. My tests (5 November 2026) - Fresh install: pip install praisonai gave praisonai 4.7.23 and praisonaiagents 1.7.21, with Python 3.12, in about 30 seconds (some packages were already cached). - Model: OpenAI gpt-4o-mini. The AI alone said a date in October 2023 in all its runs. With the harness, it gave Thursday, 5 November 2026 in every run. - Without the clock tool but with the check, the check sent the answer back three times, then PraisonAI blocked it. - Keep the name="Assistant" line: in this version, the check does not run without a name. - The Windows commands were not tested on Windows. Timestamps 0:00 Same AI, two answers 0:22 What a harness is (and why the AI said 2023) 1:17 Set it up: pip install praisonai 2:02 The code, line by line 3:24 Run it, and why the check matters 4:32 Harnesses you already use 4:57 What it means for you Sources - Mitchell Hashimoto, "My AI Adoption Journey" (5 Feb 2026): https://mitchellh.com/writing/my-ai-adoption-journey - LangChain, "Improving Deep Agents with harness engineering" (17 Feb 2026): https://www.langchain.com/blog/improving-deep-agents-with-harness-engineering - LangChain, "The Anatomy of an Agent Harness" (10 Mar 2026): https://www.langchain.com/blog/the-anatomy-of-an-agent-harness - OpenAI, "Harness engineering: leveraging Codex in an agent-first world": https://openai.com/index/harness-engineering/ - PraisonAI: https://github.com/MervinPraison/PraisonAI · docs: https://docs.praison.ai - Claude Code: https://docs.claude.com/en/docs/claude-code/overview · Codex: https://github.com/openai/codex · Cursor: https://cursor.com Disclosure: I built PraisonAI. Which AI app would you like to see opened up next? Tell me in the comments. Follow for more AI news, explained simply. #HarnessEngineering #AIAgents #PraisonAI

Stop watching · start building
Matched to AI Agents

AI Maker Residence 4

Your idea can be anything. At our last workshops, people built plant-based nutrition businesses, a way to measure planetary resilience, crochet headwear and a way to connect lonely people living in the same building. This fourth workshop is a full day at KOKO with Nick Sarafa, learning to build with Claude Code. Bring the thing you keep meaning to start. We’ll bring the pizza.

◆ Fri 13 Nov 2026 ◆ KOKO, London ◆ With Nick Sarafa
AI Maker Residence 4
Live event
AI Maker Residence 4
Fri 13 Nov 2026

More like this

Running one yourself?

List your AI event,
wherever it is.

A meetup, a workshop, a hackathon, a conference. Any city, or online. Tell us about it and it lands in front of people already learning this stuff.