Agent Atlas / Chapter 1

Before the First Model Request

A prompt reaches the model only after the runtime has restored state, resolved permissions, selected tool behavior, run interception hooks, and decided which hidden instructions belong in the request.

Learning objective

Use public evidence to answer: What has the runtime already decided when the model receives its first request?

Working question

What has the runtime already decided when the model receives its first request?

An agent begins when the runtime commits an operating envelope, not when the model produces text.
A six-step flow shows thread restoration, tool-mode resolution, pending input, prompt hooks, policy decisions, and the assembled model request.
Before the first model request The visible prompt is one input to a runtime sequence that resolves identity, control state, and hidden instructions. Open full-size diagram
Case file 01 / A prompt before acceptance

The prompt that had not yet entered the conversation

In Codex, submitted text can wait in pending input while a UserPromptSubmit hook inspects the session, turn, working directory, transcript, model, permission mode, and prompt. Only after that inspection does the runtime commit the message into the turn.

The hook can allow the prompt, block it with a reason, stop processing, or attach context. Plain-text hook output can become DeveloperInstructions, placing machine-supplied material above ordinary user text. The first model request can therefore differ materially from the sentence visible in the composer.

Latest newsroom receipts

What changed since the first Atlas draft

Mechanism trace

What actually happens

  1. Restore thread

    goal, lineage, permissions

  2. Resolve tool mode

    model-specific action surface

  3. Buffer prompt

    pending input

  4. Run hooks

    inspect, block, add context

  5. Commit turn

    record accepted state

  6. Invoke model

    assembled decision envelope

The first request carries a contract

Codex commit a1ecf0cf replaces thread-store SandboxPolicy fields with canonical PermissionProfile fields. The runtime persists the profile as JSON, continues reading legacy values, and propagates it through local storage, in-memory storage, live metadata synchronization, and rollout extraction. Permission is durable session data rather than a transient prompt label.

Commit 5577a9e1 resolves model tool behavior into direct, code_mode, or code_mode_only. The selected ToolMode lives on TurnContext and participates in turn creation, model switches, review turns, tool planning, and code execution. Two turns with identical visible prompts can receive different action surfaces.

The prompt crosses an execution boundary

Codex places prompt inspection before history is finalized. That ordering lets policy or project automation reject malformed work, add repository-specific instructions, or prevent a turn from starting. It also creates a privileged boundary where invisible software can rewrite the effective request before the model sees it.

Gemini CLI exposes a comparable boundary through BeforeAgent. Hook output can block execution or return additionalContext, which is appended inside a delimiter. Tests escape delimiter-like text, acknowledging that injected context is itself an input-security surface.

The task gets a record separate from the message

Codex PR 21981 fixed threads that began with a goal but failed to appear in resume lists because discovery depended on a normal first user message. The design added a separate thread preview field so the goal can supply display metadata without pretending the objective was literally the first message.

Separating goal, preview, and user-message fields prevents one value from carrying incompatible meanings. A runtime can preserve the objective, render a useful session label, and retain the original conversation without quietly rewriting one into another.

A delegated worker has another first moment

Codex commit d661ab70 adds SubagentStart, which runs after a child is created but before its first model request. The hook receives the child agent ID and resolved agent type, and its output can add context to the child conversation. The child begins inside a separately assembled envelope.

Later lineage fields make that envelope traceable. parent_thread_id identifies the spawning thread, subagent_kind records the child's role, and forked_from_thread_id records copied history. Parentage and inherited history are distinct facts; collapsing them makes permission, recovery, and audit records tell the wrong story.

Failure modes

Where the contract breaks

Invisible instruction escalation

Hook output can enter the request with more authority than ordinary user text.

Failure signalThe model follows a rule absent from the visible conversation.

Control state disappears at a boundary

A resume, model switch, worker, or child falls back when permission context is not propagated.

Failure signalThe same task gains different tools or sandbox access after a transition.

Lineage fields collapse distinct relationships

Parentage and copied history describe different inheritance paths.

Failure signalAudit or recovery attributes work to the wrong originating thread.
Release tests

What the product must prove

  1. Show the resolved PermissionProfile, ToolMode, model, working directory, and hook results before the first request.
  2. Distinguish submitted text, blocked text, and hook-added instructions in the input history.
  3. Expose parent thread, fork source, child kind, and effective child context before delegated work starts.

Projects In This Lesson

21 projects

Recent Reporting For This Lesson

6 articles