# What Is the Timeout for Shell-Script Hooks Sending Data to ai-memory?

> Discover the one-second curl timeout for shell-script hooks sending data to ai-memory. Learn how this limit impacts client disconnections and server response times.

- Repository: [Fabio Akita/ai-memory](https://github.com/akitaonrails/ai-memory)
- Tags: how-to-guide
- Published: 2026-08-21

---

**Shell-script hooks transmitting observations to ai-memory enforce a rigid one-second (1 s) curl timeout, causing the client to disconnect if the server fails to respond within that window.**

The akitaonrails/ai-memory repository implements observation ingestion through lightweight shell hooks that POST data to the server. Understanding the timeout for shell-script hooks sending data to ai-memory is essential for designing admission logic that never exceeds the client’s hard deadline, preventing silent data loss.

## The One-Second Curl Timeout

Shell-script hooks in ai-memory use **curl** commands configured with a one-second client-side timeout. This represents the shortest shipped client deadline in the entire project. The server must complete admission processing and return a response before this 1-second window expires, otherwise the client will have already disconnected and cannot receive the approval signal.

The constraint is documented in the router implementation at [`crates/ai-memory-hooks/src/router.rs`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-hooks/src/router.rs), where a comment explicitly states: *"The shortest shipped client deadline is the shell hook's one-second curl timeout"*【/cache/repos/github.com/akitaonrails/ai-memory/main/crates/ai-memory-hooks/src/router.rs†L64-L68】.

```rust
// In crates/ai-memory-hooks/src/router.rs
/// Upper bound for reject-policy admission on the synchronous `/handoff`
/// path. The shortest shipped client deadline is the shell hook's one-second
/// curl timeout, so the server must decide earlier or leave the baton open;
/// otherwise an approved response can consume context after the client has
/// already disconnected and can no longer receive it.
const AUTOMATIC_HANDOFF_ADMISSION_TIMEOUT: std::time::Duration =
    std::time::Duration::from_millis(750);

```

## Server-Side Admission Constraints

To guarantee compliance with the client’s 1-second limit, the server enforces its own **750-millisecond admission timeout** via the `AUTOMATIC_HANDOFF_ADMISSION_TIMEOUT` constant. This 250-millisecond buffer prevents race conditions where the server might approve a request after the client has already terminated the connection.

When a shell hook sends its POST request to the `/hook` endpoint, the server must make its admission decision within 750 ms. If processing exceeds this limit, the baton remains open, but the client will never receive the response due to the underlying curl timeout.

## Comparison with Generic Webhook Timeouts

While [`crates/ai-memory-wiki/src/wiki.rs`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-wiki/src/wiki.rs) defines generic webhook timeout handling with a default of 1,000 ms, the shell-script hook overrides this behavior with its own explicit 1-second curl limit. The router’s `webhook_timeout` function clamps server-side timeouts accordingly, but the shell script’s network call remains governed by its independent curl configuration.

## Implications for Hook Reliability

Because the timeout for shell-script hooks sending data to ai-memory is non-negotiable at the client layer, any network latency or heavy computation in the admission pipeline risks observation drops. Hooks must assume that the server will either respond within one second or fail entirely; there is no retry mechanism built into the default curl invocation.

## Summary

- Shell-script hooks use a **1-second curl timeout** when posting to ai-memory.
- The constraint is documented in [`crates/ai-memory-hooks/src/router.rs`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-hooks/src/router.rs) as the shortest shipped client deadline.
- The server limits admission processing to **750 milliseconds** to stay within the client window.
- The timeout applies specifically to the synchronous `/handoff` path and the `/hook` endpoint used by shell integrations.

## Frequently Asked Questions

### What happens if the ai-memory server takes longer than 1 second to respond?

The curl command in the shell-script hook will terminate the connection after exactly one second. The server may continue processing, but the client will mark the request as failed and will not receive any admission approval or error response.

### Why does the server use a 750-millisecond timeout instead of the full 1 second?

The `AUTOMATIC_HANDOFF_ADMISSION_TIMEOUT` constant provides a 250-millisecond safety margin to account for network propagation delays and ensure the server never attempts to send a response to a client that has already disconnected.

### Where is the timeout configured in the shell-script hook itself?

While the raw analysis references the router documentation noting the one-second curl timeout, the actual curl invocation itself resides in the shell-hook scripts (external to the Rust source). The router code at [`crates/ai-memory-hooks/src/router.rs`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-hooks/src/router.rs) treats this 1-second limit as an external constraint that the server must respect.

### Can I modify the timeout for shell-script hooks in ai-memory?

You can adjust the curl timeout in your local shell-hook scripts, but the server’s admission logic in [`router.rs`](https://github.com/akitaonrails/ai-memory/blob/main/router.rs) assumes a 1-second maximum. Extending the client timeout without updating the server’s 750-millisecond admission limit would provide no benefit, as the server would still reject or timeout the request at 750 ms.