chenhg5/cc-connect · error
hook input exceeds %d bytes
Error message
hook input exceeds %d bytes
What it means
Relay enforces a 4 MiB cap (maxHookInput) on the hook's stdin payload and returns 'hook input exceeds %d bytes' when the JSON invocation exceeds it. Oversized payloads are rejected before any network call so the bridge is never flooded.
Source
Thrown at agent/antigravityhook/protocol.go:42
}
type BridgeResponse struct {
Decision string `json:"decision"`
Reason string `json:"reason,omitempty"`
}
// Relay forwards one Agy hook invocation to the owning cc-connect session.
func Relay(in io.Reader, out io.Writer, address, token string) error {
if strings.TrimSpace(address) == "" || strings.TrimSpace(token) == "" {
return fmt.Errorf("permission bridge environment is missing")
}
input, err := io.ReadAll(io.LimitReader(in, maxHookInput+1))
if err != nil {
return fmt.Errorf("read hook input: %w", err)
}
if len(input) > maxHookInput {
return fmt.Errorf("hook input exceeds %d bytes", maxHookInput)
}
if !json.Valid(input) {
return fmt.Errorf("hook input is not valid JSON")
}
conn, err := net.DialTimeout("tcp", address, bridgeDialTimeout)
if err != nil {
return fmt.Errorf("connect permission bridge: %w", err)
}
defer func() { _ = conn.Close() }()
// The listener is started before agy runs this hook, so dial failures should
// fail closed quickly. After connect, wait much longer for a human response.
_ = conn.SetDeadline(time.Now().Add(bridgeResponseTimeout))
if err := json.NewEncoder(conn).Encode(BridgeRequest{Token: token, HookInput: input}); err != nil {
return fmt.Errorf("send permission request: %w", err)
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Reduce the size of the prompt/context attached to the agy turn that triggers the hook
- Upgrade or fix agy if it is inflating hook input beyond the spec
- If legitimately needed, raise maxHookInput in agent/antigravityhook/protocol.go and rebuild
- Check for runaway loops appending to the hook input upstream
Defensive patterns
Strategy: validation
Validate before calling
data, _ := io.ReadAll(in)
if len(data) > 4<<20 {
return fmt.Errorf("hook input is %d bytes; max is %d", len(data), 4<<20)
} Try / catch
if err := Relay(...); err != nil && strings.Contains(err.Error(), "exceeds") {
fmt.Fprintln(os.Stderr, "payload too large: shrink prompt/context")
os.Exit(2)
} Prevention
- Keep prompts and attached context reasonably sized
- Don't attach huge files to turns that will trigger permission hooks
- Raise maxHookInput consciously if your workflows need bigger payloads
When it happens
Trigger: Agy invokes the permission hook with a hook input document larger than 4194304 bytes — e.g. a prompt/context blob embedded in the hook input that grew huge.
Common situations: Extremely large prompts or attached context in the permission request; a modified/buggy agy version emitting extra fields; users piping artificially large files into the hook when testing.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- Content-Length too large: %d
- permission bridge environment is missing
- read hook input: %w
- hook input is not valid JSON
- download exceeds --max-bytes: %d > %d
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/5900eeda024b8f74.
Report an issue: GitHub.