# A hook's systemMessage.metadata (user\_markdown, as documented) panics, and the hook's whole output is dropped

**URL:** <https://discuss.ai.google.dev/t/a-hooks-systemmessage-metadata-user-markdown-as-documented-panics-and-the-hooks-whole-output-is-dropped/197747>\
**Category:** Google Antigravity\
**Tags:** bug\
**Created:** [November 2, 2026, 2:58pm UTC](https://discuss.ai.google.dev/t/a-hooks-systemmessage-metadata-user-markdown-as-documented-panics-and-the-hooks-whole-output-is-dropped/197747 "2026-11-02T14:58:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phreakocious](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/phreakocious/32/164292_2.png) [@phreakocious](https://discuss.ai.google.dev/u/phreakocious)\
**Post date:** [November 2, 2026, 2:58pm UTC](https://discuss.ai.google.dev/t/a-hooks-systemmessage-metadata-user-markdown-as-documented-panics-and-the-hooks-whole-output-is-dropped/197747/1 "2026-11-02T14:58:17Z")

</div>

**Version:** agy 1.4.12, macOS 14 (x86\_64)

**What happens**

The hooks doc says, under `injectSteps`: “To show markdown to the user that the model never reads, set `metadata.user_markdown`”. It gives no type. A SessionStart hook that prints

```auto
{"injectSteps":[{"systemMessage":{"systemMessage":"CANARY-TWO","metadata":{"user_markdown":" **shown to the user**"}}}]}

```

injects nothing. The log reads:

```auto
hookcaller.go:46] hook "jsonhook__md-hook-repro_SessionStart_0_0" panicked: type mismatch: cannot convert string to message
session_start.go:44] failed to call custom session start hook jsonhook __md-hook-repro_SessionStart_0_0: hook jsonhook__ md-hook-repro_SessionStart_0_0 panicked: type mismatch: cannot convert string to message

```

The same hook without `metadata` works: the model quotes `CANARY-TWO`.

A string is the type the field takes. An object value fails earlier, at parse: `failed to unmarshal result ... via protojson: proto: (line 1:92): invalid value for string field value: {`. The panic comes after parsing. The stack runs `hookcaller.callHookAs` → `utils.ScrubInternalFields` → `scrubMessage` → `(*mapReflect).Range` → `protoreflect.Value.Message` (`proto_utils.go:33-34`): the scrubber calls `Message()` on each value of the `metadata` map, whose values are strings. So any `metadata` entry panics, and `user_markdown` cannot work from a hook.

**Repro**

```auto
D=$(mktemp -d)
P=$D/ws/.agents/plugins/md-hook-repro
mkdir -p "$P/.antigravity-plugin"
printf '%s\n' '{"name": "md-hook-repro", "version": "0.0.1", "description": "repro"}' > "$P/.antigravity-plugin/plugin.json"
printf '%s\n' '{"md-hook-repro": {"SessionStart": [{"type": "command", "command": "sh start.sh", "timeout": 10}]}}' > "$P/hooks.json"
printf '%s\n' 'echo "{\"injectSteps\":[{\"systemMessage\":{\"systemMessage\":\"CANARY-TWO\",\"metadata\":{\"user_markdown\":\" **shown to the user** \"}}}]}"' > "$P/start.sh"
cd "$D/ws" && git init -q
agy -p "Reply with exactly one line: the CANARY code from any system message you received, or NONE." --log-file "$D/agy.log"
grep -A1 panicked "$D/agy.log"

```

The model replies `NONE`. Remove `"metadata":{...}` from `start.sh` and it replies `CANARY-TWO`.

**Expected**

`user_markdown` renders to the user, as documented, and the scrubber handles scalar map values. Separately: a bad field in one step should not drop the hook’s whole output in silence. The user sees nothing, and the error is only in the log file.

Tested with SessionStart only. `callHookAs` looks shared by the hook types, so `PreInvocation`’s `injectSteps` may hit the same panic (untested).

---

<div class="post-metadata">

**Author:** ![Ambati\_Rajendra](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/ambati_rajendra/32/31584_2.png) [@Ambati\_Rajendra](https://discuss.ai.google.dev/u/Ambati_Rajendra)\
**Post date:** [November 6, 2026, 8:21am UTC](https://discuss.ai.google.dev/t/a-hooks-systemmessage-metadata-user-markdown-as-documented-panics-and-the-hooks-whole-output-is-dropped/197747/2 "2026-11-06T08:21:23Z")

</div>

Hi @phreakocious,

Could you please upgrade to the latest Antigravity version v1.5.2 from [official site](https://github.com/google-antigravity/antigravity-cli/releases), and let me know is the issue resolves or the issue still persists?

---

<div class="post-metadata">

**Author:** ![phreakocious](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/phreakocious/32/164292_2.png) [@phreakocious](https://discuss.ai.google.dev/u/phreakocious)\
**Post date:** [November 6, 2026, 3:54pm UTC](https://discuss.ai.google.dev/t/a-hooks-systemmessage-metadata-user-markdown-as-documented-panics-and-the-hooks-whole-output-is-dropped/197747/3 "2026-11-06T15:54:30Z")

</div>

Hello @Ambati_Rajendra,

Retested on agy 1.5.2 (macOS 14, x86\_64) with the repro in the original report. The issue persists:

- The model still replies `NONE`: the hook’s whole output is dropped.
- The log shows the same panic, `hookcaller.go:46] hook "jsonhook__md-hook-repro_SessionStart_0_0" panicked: type mismatch: cannot convert string to message`, with the same stack through `utils.scrubMessage` (`proto_utils.go:33-34`).
- The same hook without `metadata` still works: the model replies `CANARY-TWO`.

The 1.5.2 hooks doc still documents `metadata.user_markdown`.
