Skip to Content
Latch Docs

Hooks and feedback

Understand what triggers a check and where each harness shows its result.

Use after_edit for fast checks after a file edit and turn_end for broader checks after an agent turn. By default, Latch runs them when the workspace changes and stays quiet when they pass.

Choose how the agent receives a turn-end failure with the top-level turn_end_feedback setting in latch.json.

ValueWhat happens after a failed check
"report" (default)The turn ends normally. The harness decides where the report appears and when the agent sees it.
"continue_once"A supported harness gives the agent one automatic chance to act on the failure. You don’t send another message, and Latch does not automatically rerun the check.

When checks run · Default delivery by harness · Enable automatic continuation

When checks run

EventTriggerDefault comparison
after_editA native edit tool finishes.Immediately before and after that edit.
turn_endThe agent finishes a turn.The start and end of the turn, including changes made through shell commands.

Commands come from package scripts, latch.json, or both.

How Latch detects changes

  • Already-dirty files. A file triggers a check only if it changes during the event. When Latch can’t compare Git-visible changes reliably, it runs the commands without change-based filters.
  • File filters. Use path or extension filters to run checks only for matching changes. Paths are relative to the Git worktree root.
  • Git worktrees. Each linked worktree has its own baseline, even inside the main checkout. Changes in an untracked nested checkout stay outside the parent’s check. Start your harness in the directory where the checks should run.

Native file edits by harness

These are local integrations. See Cloud sessions for hosted setup.

HarnessNative edit tools
Codexapply_patch
Claude CodeEdit, Write, MultiEdit, NotebookEdit
GitHub Copilot CLIcreate, edit, str_replace_editor, apply_patch
OpenCode v1edit, write, apply_patch
OpenCode v2edit, write, patch
Piedit, write
OpenHands CLIfile_editor write operations
Kimi Code CLIUse turn_end for automatic checks.
Grok Buildwrite, search_replace, and patch tools

Where reports appear

This table shows the default report behavior in local sessions. “Next prompt” means your next message in the same session and project. See Cloud sessions for verified hosted feedback.

HarnessEdit failure reaches modelTurn-end failure reaches model
CodexSame turnNext prompt
Claude CodeSame turnNext prompt
GitHub Copilot CLISame turnNext prompt
OpenCode v1 and v2Same turnNext prompt
PiSame turnNext model request
OpenHands CLI and SDKNext promptNext prompt
Kimi Code 2.7.2—Next prompt
Grok Build 1.0.92Same turnNo model feedback

Headless output

  • Codex. The tested codex exec --json output omitted the app-server warning.
  • OpenCode v2. opencode --standalone --print-logs run "..." shows the turn-end report on stderr.
  • Grok Build. The failure goes to hook stderr. The tested headless session did not surface it in its terminal output.

Use compact failure output to keep useful lines such as errors and assertions. When a report includes a saved log path, the agent can read the original output directly or use the plugin tool.

Act on a turn-end failure

With Latch v0.1.3 or later, add this top-level option to latch.json.

{
  "turn_end_feedback": "continue_once"
}

Keep your existing check definitions or package scripts. OpenCode v1 uses its default delivery. For sessions without automatic continuation, ask the agent to call run_turn_end before responding.

How supported harnesses continue

HarnessHow the model sees the failure
Claude CodeNative Stop hook context keeps the current turn open without a separate user prompt. Claude makes another model request to act on the report.
OpenCode v2 and PiThe extension adds its report to session context and resumes the current execution.
Codex and Copilot CLIThe host creates a continuation prompt from the stop-hook response.
Grok BuildWith Latch v0.1.4 or later, the Stop hook supplies the failure and Grok continues once in the same turn.
Kimi Code CLIThe interactive CLI and persistent ACP sessions in 2.7.2 deliver the failure and continue once. Use report with kimi -p. If print mode exits before Stop claims the saved snapshot, Latch checks the changes on the next prompt in that session.
OpenHands CLI and local Agent CanvasThe Stop hook denies completion once and supplies the failure as feedback.

Verified in live Codex, Claude Code, and Copilot CLI sessions, and in real OpenCode v2, Pi, OpenHands CLI, local Agent Canvas, Grok Build, and Kimi Code CLI sessions with scripted models.

A model needs another request to act on a report produced after its final response. On supported edit hooks, after_edit can attach feedback to an existing tool result while the agent is still working.

Claude Code Stop hooks · Codex Stop hooks · Copilot stop hooks

On this page