A hook's systemMessage.metadata (user_markdown, as documented) panics, and the hook's whole output is dropped

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

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

injects nothing. The log reads:

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

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).

Hi @phreakocious,

Could you please upgrade to the latest Antigravity version v1.5.2 from official site, and let me know is the issue resolves or the issue still persists?

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.