gem/tests/agent_mtp_autodiscovery.sh
2026-08-30 18:24:55 -06:00

66 lines
2 KiB
Bash
Executable file

#!/bin/sh
set -eu
gem=$1
state_dir=$(mktemp -d "${TMPDIR:-/tmp}/gem-agent-mtp.XXXXXX")
model=$state_dir/gemma-4-31B-it-Q4_0.gguf
assistant=$state_dir/mtp-gemma-4-31B-it-Q4_0.gguf
auto_error=$state_dir/auto.err
disabled_error=$state_dir/disabled.err
f16_error=$state_dir/f16.err
f16_full_error=$state_dir/f16-full.err
conflict_error=$state_dir/conflict.err
cleanup()
{
rm -f "$model" "$assistant" "$auto_error" "$disabled_error" "$f16_error" \
"$f16_full_error" "$conflict_error"
rmdir "$state_dir"
}
trap cleanup EXIT INT TERM
: >"$model"
: >"$assistant"
if "$gem" agent --model "$model" --port 19837 --hax /usr/bin/false 2>"$auto_error"; then
echo "gem agent unexpectedly accepted an empty model" >&2
exit 1
fi
grep -Fq "gem: using colocated MTP assistant $assistant" "$auto_error"
if "$gem" agent --model "$model" --no-mtp --port 19837 --hax /usr/bin/false \
2>"$disabled_error"; then
echo "gem agent unexpectedly accepted an empty model with --no-mtp" >&2
exit 1
fi
if grep -Fq "using colocated MTP assistant" "$disabled_error"; then
echo "gem agent ignored --no-mtp" >&2
exit 1
fi
if "$gem" agent --model "$model" --kv-type f16 --port 19837 --hax /usr/bin/false \
2>"$f16_error"; then
echo "gem agent unexpectedly accepted an empty F16 model" >&2
exit 1
fi
if grep -Fq "using colocated MTP assistant" "$f16_error"; then
echo "gem agent enabled MTP with F16 KV" >&2
exit 1
fi
if "$gem" agent --model "$model" --kv-type f16-full --port 19837 --hax /usr/bin/false \
2>"$f16_full_error"; then
echo "gem agent unexpectedly accepted an empty mixed-KV model" >&2
exit 1
fi
if grep -Fq "using colocated MTP assistant" "$f16_full_error"; then
echo "gem agent enabled MTP with mixed KV" >&2
exit 1
fi
if "$gem" agent --model "$model" --mtp "$assistant" --no-mtp --port 19837 \
--hax /usr/bin/false 2>"$conflict_error"; then
echo "gem agent accepted conflicting MTP controls" >&2
exit 1
fi
grep -Fq "usage:" "$conflict_error"