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.
| Value | What 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
| Event | Trigger | Default comparison |
|---|---|---|
after_edit | A native edit tool finishes. | Immediately before and after that edit. |
turn_end | The 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.
| Harness | Native edit tools |
|---|---|
| Codex | apply_patch |
| Claude Code | Edit, Write, MultiEdit, NotebookEdit |
| GitHub Copilot CLI | create, edit, str_replace_editor, apply_patch |
| OpenCode v1 | edit, write, apply_patch |
| OpenCode v2 | edit, write, patch |
| Pi | edit, write |
| OpenHands CLI | file_editor write operations |
| Kimi Code CLI | Use turn_end for automatic checks. |
| Grok Build | write, 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.
| Harness | Edit failure reaches model | Turn-end failure reaches model |
|---|---|---|
| Codex | Same turn | Next prompt |
| Claude Code | Same turn | Next prompt |
| GitHub Copilot CLI | Same turn | Next prompt |
| OpenCode v1 and v2 | Same turn | Next prompt |
| Pi | Same turn | Next model request |
| OpenHands CLI and SDK | Next prompt | Next prompt |
| Kimi Code 2.7.2 | — | Next prompt |
| Grok Build 1.0.92 | Same turn | No model feedback |
Headless output
- Codex. The tested
codex exec --jsonoutput 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
| Harness | How the model sees the failure |
|---|---|
| Claude Code | Native 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 Pi | The extension adds its report to session context and resumes the current execution. |
| Codex and Copilot CLI | The host creates a continuation prompt from the stop-hook response. |
| Grok Build | With Latch v0.1.4 or later, the Stop hook supplies the failure and Grok continues once in the same turn. |
| Kimi Code CLI | The 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 Canvas | The 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