Files
agent-zero/docker/run/fs/exe/initialize.sh
Alessandro 2afffe8edc Overlap embedding warm-up with chat restoration
Load sentence-transformers on the existing cache miss and construct the
preloaded model off the shared background event loop. Start warm-up before
chat restoration inside extensible init_a0, preserving start-hook control
and sharing the loaded model with ordinary runtime requests.

Remove unused speech preload imports and dead warm-up functions. Seed APT
indexes only when absent, skipping the refresh on normal container boots.
Keep the existing Python tunnel service and its provider lifecycle.

Validation: 49 focused framework tests passed, including extension-hook
short-circuit behavior, concurrent embedding-cache reuse, APT cache states,
tunnel behavior and CSRF origins. Three cold Fable chat trials per version:
median submit-to-first-token 9.588s -> 4.234s;
local preparation 6.904s -> 1.197s;
HTTP readiness 42.637s -> 41.139s;
boot-to-first-token 52.093s -> 46.657s.
Provider timing varies; these are local repeated measurements. The live
baseline already omitted APT refresh, so it receives no timing credit.
2026-10-10 16:36:08 +02:00

69 lines
1.8 KiB
Bash

#!/bin/bash
echo "Running initialization script..."
# branch from parameter
if [ -z "$1" ]; then
echo "Error: Branch parameter is empty. Please provide a valid branch name."
exit 1
fi
BRANCH="$1"
raise_open_file_limit() {
local requested="${A0_NOFILE_LIMIT:-65535}"
local soft
local hard
local target
if ! [[ "$requested" =~ ^[0-9]+$ ]] || [ "$requested" -lt 1 ]; then
echo "Warning: invalid A0_NOFILE_LIMIT='$requested'; keeping open file limit at $(ulimit -S -n)." >&2
return
fi
soft="$(ulimit -S -n)"
hard="$(ulimit -H -n)"
if [ "$soft" = "unlimited" ]; then
echo "Open file limit is already unlimited."
return
fi
target="$requested"
if [ "$hard" != "unlimited" ] && [ "$target" -gt "$hard" ]; then
target="$hard"
fi
if [ "$target" -gt "$soft" ]; then
if ulimit -S -n "$target"; then
echo "Raised open file soft limit from $soft to $(ulimit -S -n) (hard: $hard)."
else
echo "Warning: failed to raise open file soft limit from $soft to $target (hard: $hard)." >&2
fi
else
echo "Open file soft limit is $soft (target: $requested, hard: $hard)."
fi
}
initialize_package_lists() {
if ! compgen -G "/var/lib/apt/lists/*_Packages*" > /dev/null; then
apt-get update > /dev/null 2>&1 &
fi
}
raise_open_file_limit
# Copy all contents from persistent /per to root directory (/) without overwriting
cp -r --no-preserve=ownership,mode /per/* /
# Ensure upload storage exists before API and connector callers can reference it.
mkdir -p /a0/usr/uploads
# allow execution of /root/.bashrc and /root/.profile
chmod 444 /root/.bashrc
chmod 444 /root/.profile
initialize_package_lists
# let supervisord handle the services
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf