• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
Friday, October 9, 2026
newsaiworld
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us
No Result
View All Result
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us
No Result
View All Result
Morning News
No Result
View All Result
Home Artificial Intelligence

Put Your Personal Logic Contained in the Codex Agentic Loop

Admin by Admin
August 24, 2026
in Artificial Intelligence
0
Codex hooks.jpg
0
SHARES
2
VIEWS
Share on FacebookShare on Twitter

READ ALSO

Your Mannequin’s MSE Is Mendacity to You III: Time Collection Diffusion

Everybody Is Promoting AI at You — Right here’s Easy methods to Hold Your Judgement


by means of prompts.

We are able to describe the duty, give directions, and inform Codex what sort of consequence we anticipate. This permits us to regulate how the agent approaches its work.

However generally, prompting shouldn’t be sufficient.

We might wish to additional customise the execution by operating our personal logic at totally different phases of a Codex session.

So, how can we try this?

The reply is Codex hooks.

On this publish, we’ll discover the idea of hooks and perceive the place they match into the agentic loop. Then, we’ll undergo a concrete case research to show the idea.


1. Understanding Codex hooks

When Codex works on a activity, it goes by means of an agentic loop.

For a brand new session, the person varieties in a immediate, Codex analyzes the issue, calls instruments, and completes the duty. You’ll be able to consider this entire problem-solving trajectory as a lifecycle, and at totally different factors on this lifecycle, Codex emits occasions with totally different occasion names:

  • SessionStart: emitted when a session begins;
  • PreToolUse: emitted when Codex is about to name a device;
  • PostToolUse: emitted after the device finishes;
  • Cease: emitted when Codex is able to end its response;
  • SessionEnd: emitted when the Codex session ends.

A Hook is the mechanism that permits us to connect our personal logic to those occasions.

For instance, we may use SessionStart hook to load further context, or PreToolUse hook to examine a command earlier than it runs, or Cease hook to validate a consequence.

So, what does it imply to connect logic to an occasion?

Suppose we configure a hook for PreToolUse. Each time Codex is about to name a device, the hook runs a script. Codex passes details about that device name to the script as a part of the context.

Selecting PreToolUse solely identifies some extent within the lifecycle. Many various device calls can happen at that time. Because of this, we’d additionally want an identical rule to allow us to choose those we truly care about. For instance, we may run the script solely when Codex is about to execute a shell command.

Due to this fact, there are three fundamental decisions when configuring a hook:

  • At which level within the lifecycle ought to it run?
  • Below what situations ought to it run at that time?
  • What motion ought to it execute?

In Codex, these correspond to the occasion, matcher, and handler. And that is the essential sample behind Codex hooks.


2. Case research: Including a top quality gate to deep analysis

On this case research, we construct a small deep analysis workflow with Codex.

Particularly, we’ll ask Codex to analysis latest traits in a given subject. Codex will conduct internet searches and establish three necessary traits from the previous 90 days. On the finish, it ought to return a structured analysis temporary.

To showcase the hook idea, we’ll add a top quality verify simply earlier than Codex finishes. It’ll confirm that the temporary incorporates sufficient sources and that these sources come from an inexpensive number of domains.

If the temporary passes, Codex can end. If it fails, the hook will ship the issues again to Codex, and Codex will proceed researching throughout the identical run till it satisfies our checks.

2.1 Making ready the Analysis Process

We’ll begin by getting ready a immediate template:

# Deep analysis activity

Analysis **{{TOPIC}}**.

Use sources printed from **{{WINDOW_START}}** by means of **{{WINDOW_END}}**,
inclusive. Establish the three most necessary traits in that interval and put together
a concise, source-backed temporary.

Return a concise, source-backed analysis temporary that follows the equipped schema.

To make sure structured output, we additionally put together a JSON schema:

{
  "kind": "object",
  "additionalProperties": false,
  "required": ["summary", "trends"],
  "properties": {
    "abstract": {
      "kind": "string"
    },
    "traits": {
      "kind": "array",
      "objects": {
        "kind": "object",
        "additionalProperties": false,
        "required": ["title", "summary", "sources"],
        "properties": {
          "title": {
            "kind": "string"
          },
          "abstract": {
            "kind": "string"
          },
          "sources": {
            "kind": "array",
            "objects": {
              "kind": "string"
            }
          }
        }
      }
    }
  }
}

We save this as schemas/research_brief.schema.json. Be aware that that is additionally the construction our hook expects.

2.2 Designing the High quality Gate

Subsequent, we outline what the hook ought to verify.

Right here, we verify three issues:

  • Every pattern ought to comprise not less than two sources.
  • The temporary ought to comprise not less than ten distinctive sources in whole.
  • These sources should come from not less than 5 distinctive domains.

We are able to solely apply the checks after Codex has completed getting ready it. Meaning a Cease hook is appropriate right here.

We first create the validation script in .codex/hooks/validate_research.py:

import json
import sys
from urllib.parse import urlparse


MIN_PER_TREND = 2
MIN_SOURCES = 10
MIN_DOMAINS = 5

occasion = json.load(sys.stdin)
temporary = json.hundreds(occasion["last_assistant_message"])

errors = []
all_urls = set()

for quantity, pattern in enumerate(temporary["trends"], 1):
    urls = set(pattern["sources"])
    all_urls.replace(urls)

    if len(urls) < MIN_PER_TREND:
        errors.append(f"Development {quantity} wants not less than {MIN_PER_TREND} sources.")

domains = {
    urlparse(url).netloc
    for url in all_urls
}

if len(all_urls) < MIN_SOURCES:
    errors.append(f"Add not less than {MIN_SOURCES} distinctive sources.")

if len(domains) < MIN_DOMAINS:
    errors.append(f"Use not less than {MIN_DOMAINS} supply domains.")

if errors:
    message = "Analysis temporary verify failed:n- " + "n- ".be part of(errors)
    consequence = {"choice": "block", "cause": message}
else:
    consequence = {}

print(json.dumps(consequence))

When the Cease occasion is emitted, Codex passes in last_assistant_message, which follows the schema we outlined earlier. Our script can then parse this response right into a Python dictionary and iterate over the traits and gather their sources in a set.

Subsequent, we use urlparse to extract the area from every distinctive URL. After that, we are able to apply our checks.

If any verify fails, the script would return a block choice along with the errors:

{
  "choice": "block",
  "cause": "Analysis temporary verify failed:n- Add not less than 10 distinctive sources."
}

Be aware that for the Cease occasion, block doesn’t terminate the run; it simply prevents Codex from ending. Codex can use the suggestions to enhance the temporary throughout the identical run.

Now we have to outline the hook to inform Codex when and learn how to execute it. We do that in .codex/hooks.json:

{
  "hooks": {
    "Cease": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "python3 .codex/hooks/validate_research.py",
            "commandWindows": "python .codexhooksvalidate_research.py"
          }
        ]
      }
    ]
  }
}

Codex at present doesn’t apply matchers to the Cease occasion. So we didn’t outline any within the configuration above.

2.3 Working a Concrete Analysis Process

As a check, I requested Codex to analysis latest traits in data-center infrastructure:

{
  "subject": "latest traits in data-center infrastructure",
  "as_of": "2026-08-01",
  "lookback_days": 90
}

After inserting these values into our immediate template, we save the rendered immediate to outputs/research_prompt.md.

Earlier than the primary run, you’ll be able to open Codex within the mission listing and use /hooks to evaluate the hook.

On this case, we’ll run the duty in headless mode with exec:

codex --search exec 
  --model gpt-5.6-sol 
  --json 
  --output-schema schemas/research_brief.schema.json 
  -o outputs/research_brief.json 
  - 
  < outputs/research_prompt.md 
  > outputs/run.jsonl

A few issues price mentioning:

  • exec: runs Codex non-interactively.
  • --search: provides the agent entry to internet search.
  • --model: selects the mannequin used for the run.
  • --output-schema: that is the place we provide our pre-defined schema to constrain the agent output.
  • -o: this implies we save the agent’s response to the goal location.
  • --json: this makes Codex emit its execution occasions as JSONL. We redirect this occasion stream to outputs/run.jsonl, which supplies us a hint of the run.
  • -: tells Codex to learn the immediate from customary enter.
  • <: This operator provides outputs/research_prompt.md as that enter.

Throughout my check, I see that Codex first produced three traits supported by seven distinctive sources. Every pattern had greater than two sources, however the temporary didn’t meet our total requirement of ten.

Our Cease hook labored, as Codex obtained this suggestions:

The temporary wants broader corroboration. I’m including not less than three
impartial, in-window sources whereas preserving the identical three
evidence-supported traits.

After one other spherical, Codex lastly produced an up to date temporary with 12 distinctive sources from 10 domains.

The ultimate temporary recognized three main traits: the rise of gigawatt-scale AI campuses, energy entry and allowing as infrastructure constraints, and the shift towards liquid cooling.

The hook ran once more, however this time it allowed Codex to complete. The result is saved to outputs/research_brief.json.


3. When Hooks Are Helpful

In our case research, we confirmed learn how to use a Cease hook to validate a accomplished consequence. The identical design course of additionally applies to different lifecycle occasions.

For SessionStart hook, it’s helpful when we have to load context when a session begins. If we have to examine an operation earlier than it occurs, we are able to use PreToolUse hook. If we wish to course of the results of a device name, we are able to use PostToolUse hook.

When designing a hook, ask your self three questions:

  • At which level within the lifecycle ought to it run?
  • Below what situations ought to it run at that time?
  • What motion ought to it execute?

That is how one can add deterministic logic across the Codex execution.

Tags: AgenticCodexLogicloopput

Related Posts

1791140478650 0dj25w.webp.webp
Artificial Intelligence

Your Mannequin’s MSE Is Mendacity to You III: Time Collection Diffusion

October 9, 2026
1791302608959 1bd04h.webp.webp
Artificial Intelligence

Everybody Is Promoting AI at You — Right here’s Easy methods to Hold Your Judgement

October 8, 2026
1791066627880 jzi55s.jpg
Artificial Intelligence

How Incorrect Is Your Advertising Combine Mannequin (MMM)?

October 8, 2026
Mlm build a vector database from scratch in 10 easy steps feature.png
Artificial Intelligence

Construct And Perceive a Vector Database From Scratch in 10 Straightforward Steps

October 7, 2026
1790865088683 sy52zz.webp.webp
Artificial Intelligence

A Google Crew Measured Half of My Argument, and Left the Different Half Open

October 7, 2026
Mlm monitoring embedding drift in production scikit llm pipelines feature.png
Artificial Intelligence

Monitoring Embedding Drift in Manufacturing Scikit-LLM Pipelines

October 7, 2026
Next Post
Cleveland Fed Study Finds Crypto Ownership is Driven by Price Optimism and FOMO 1024x576.webp.webp

Cleveland Fed Examine Finds FOMO As Crypto Possession Driver

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

POPULAR NEWS

Gemini 2.0 Fash Vs Gpt 4o.webp.webp

Gemini 2.0 Flash vs GPT 4o: Which is Higher?

January 19, 2025
Chainlink Link And Cardano Ada Dominate The Crypto Coin Development Chart.jpg

Chainlink’s Run to $20 Beneficial properties Steam Amid LINK Taking the Helm because the High Creating DeFi Challenge ⋆ ZyCrypto

May 17, 2025
Image 100 1024x683.png

Easy methods to Use LLMs for Highly effective Computerized Evaluations

August 13, 2025
Blog.png

XMN is accessible for buying and selling!

October 10, 2025
0 3.png

College endowments be a part of crypto rush, boosting meme cash like Meme Index

February 10, 2025

EDITOR'S PICK

Nisha cert to degree 1.png

9 Skilled Certificates That Can Take You Onto a Diploma… If You Actually Need To

August 14, 2024
0fmwc6jstkjhw7 V7.jpeg

Past RAG: Precision Filtering in a Semantic World | by Daniel Kulik | Nov, 2024

November 12, 2024
10 awesome ocr models for 2025.png

10 Superior OCR Fashions for 2025

June 9, 2025
ETH CB 10.jpg

Ethereum (ETH) Units a Historic Unfavourable Report: Extra Ache Forward?

July 1, 2026

About Us

Welcome to News AI World, your go-to source for the latest in artificial intelligence news and developments. Our mission is to deliver comprehensive and insightful coverage of the rapidly evolving AI landscape, keeping you informed about breakthroughs, trends, and the transformative impact of AI technologies across industries.

Categories

  • Artificial Intelligence
  • ChatGPT
  • Crypto Coins
  • Data Science
  • Machine Learning

Recent Posts

  • Bridging Algorithmic Design and Regulatory Requirements in Enterprise AI
  • Your Mannequin’s MSE Is Mendacity to You III: Time Collection Diffusion
  • Submit-Quantum Custody Platform Strongpoint Provides Quantus As Improvement Associate
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy

© 2024 Newsaiworld.com. All rights reserved.

No Result
View All Result
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us

© 2024 Newsaiworld.com. All rights reserved.

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?