Hooks from chat

A hook is a command DataMind Oda runs automatically when something happens in a chat, for example after a step of the work or when you send a message. You do not have to write the hooks file by hand: ask Oda for the hook in a chat, check the card it shows you, and allow the change. This page covers the chat side; Hooks covers what hooks are, the events they answer to, and the Settings page where you manage them.

Add a hook from a chat

  1. Ask Oda for the hook in your own words: what should run, and when, for example a test after every file change Oda makes in this workspace.
  2. Oda prepares the change and shows a card titled Create this hook?. Nothing is written until you answer.
  3. Read the card. Before: and After: show the exact change to the hooks file, and File: names the file it will be written to. The card also tells you that the hook runs automatically in every future session that reads this file, including scheduled runs.
  4. Choose Allow once on the card. The answers work as on any approval card; Approvals covers them.
  5. Oda writes the hook and reports Created the hook and It runs from the next matching event.

What a hook needs

Describe the hook to Oda in your own words; the card then shows exactly what will be written. These are the values behind it, with their limits:

ValueWhat it sets
Scopeuser keeps the hook in your own hooks file and runs it in your chats; project writes it into this workspace's folder, so it stays with the project.
EventThe point the hook answers to, for example before or after a step, when you send a message, or the end of a turn. Hooks lists the events.
MatcherNarrows the hook to matching calls. Leave it out to answer every call of the event; there is no matcher on the message-submit or stop events.
CommandThe command to run: 1 to 4096 characters.
ArgumentsUp to 64 arguments, each at most 4096 characters.
TimeoutA whole number of seconds, 1 to 3600. Without one, the default for hooks applies.
Status messageA short line, at most 200 characters, that names the run in the chat and in Settings > Hooks.

Change or delete a hook

Ask Oda to change a hook or to delete it. The card is titled Change this hook? or Delete this hook?, with the same Before:, After: and File: detail, so you can check exactly what will change.

When the folder's hooks are not trusted

A project hook belongs to its folder, and Oda runs it only when that folder is trusted for exactly those hooks, or in a Full access session. Until you trust the folder, a new project hook stays inactive in ordinary sessions, and Oda reports The folder's hooks are not trusted, so it runs only in Full access sessions until the user trusts them. Hooks covers the trust review.

When a hook runs

When a hook runs, the chat shows a row labelled with the hook's status message. Expand it to see the event and matcher, how long the run took, its exit code, the message, any reminder it added, its reason, and its error output. A run that adds a reminder, shows a message, blocks, asks for approval or fails keeps its row; a run that did nothing leaves no row.

A hook can also block a step:

Who can add or change hooks

Questions, answered

Do I have to write the hooks file by hand?

No. Ask Oda for the hook in a chat, and it writes it into the right file after you allow the card. The files and the Settings page are described in Hooks.

What does the card show before a hook is written?

Before: and After: show the exact change to the hooks file, and File: names the file it will be written to, so you can check everything before you allow it.

What if I decline the card?

Nothing is written. Ask Oda to change the hook, and it shows a new card.

In Full access, does Oda ask before writing a hook?

No. In a Full access session there is no card, and the hook is written directly; Oda reports The session has Full access, so it was written without an approval prompt. The modes are described in Workspaces, files and permissions.

Why did Oda refuse to save my hook?

Each value has a limit: the command holds 1 to 4096 characters, up to 64 arguments of 4096 characters, the timeout is a whole number from 1 to 3600 seconds, and the status message holds at most 200 characters. A refused value reads The command must hold 1 to 4096 characters. or The timeout must be a whole number of seconds from 1 to 3600. Correct your request, and Oda tries again.

Why can't Oda find the hook I want to change?

Because it was edited or deleted after Oda last saw it, and an edited hook counts as a new entry; Oda refuses with That hook no longer exists. Ask Oda to look at the hooks again, then repeat the change.

Can a hook stop a run?

A hook cannot halt the run: when a hook asks the run to stop, Oda records it as a stop decision and the turn continues. At the end of a turn, a Stop hook can block the stop instead, which keeps Oda going (blocked by Stop hook). To stop a run yourself, use Stop generating in the message box.

Can a subagent add or change hooks?

No. Only the main chat can create, change or delete hooks; a subagent reports the hook it needs there, and the main chat asks you. The refusal reads Sub-agents cannot create, change, or delete hooks. Report the hook that is needed to the main agent, which can ask the user.

What is the row that appears in the chat when a hook runs?

Each hook run leaves a row labelled with the hook's status message. Expand it for the event and matcher, the duration, the exit code, the message, any reminder, the reason and the error output; a run that did nothing leaves no row. Recent runs are also listed under Settings > Hooks, described in Hooks.

I deleted a hook. Can I get it back?

Yes. Every write keeps the previous version of the file, and you can restore it in Settings > Hooks: The previous version of the file is kept; the user can restore it in Settings > Hooks. Hooks covers the versions and how to restore one.