Files
letta-server/Dockerfile
Ani Tunturi 1d1adb261a
Some checks are pending
Test Package Installation / test-install (3.11) (push) Waiting to run
Test Package Installation / test-install (3.12) (push) Waiting to run
Test Package Installation / test-install (3.13) (push) Waiting to run
fix: orphaned approvals, token inflation, reasoning fields, memfs redis dep
[IN TESTING — self-hosted 0.16.6, Kimi-K2.5 via Synthetic Direct]

Four independent fixes that landed together on this stack:

helpers.py — skip PendingApprovalError when the associated run is already
cancelled or failed. Stale approvals from interrupted runs were blocking all
subsequent messages on that conversation. Now checks run status before raising;
falls back to raising on lookup failure (conservative).

letta_agent_v3.py — use prompt_tokens not total_tokens for context window
estimate. total_tokens inflated the estimate by including completion tokens,
triggering premature compaction. This was causing context window resets mid-
conversation and is the root of the token inflation bug (see #3242).

openai_client.py (both build_request_data paths) — strip reasoning_content,
reasoning_content_signature, redacted_reasoning_content, omitted_reasoning_content
from message history before sending to inference backends. Fireworks and Synthetic
Direct reject these fields with 422/400 errors. exclude_none handles None values
but not actual text content from previous assistant turns.

block_manager_git.py — skip DB write when block value is unchanged. Reduces
unnecessary write amplification on every memfs sync cycle.

memfs_client_base.py — remove redis_client= kwarg from GitOperations init.
Dependency was removed upstream but the call site wasn't updated.

Dockerfile / compose files — context window and config updates for 220k limit.
2026-03-26 23:24:32 -04:00

105 lines
3.3 KiB
Docker

# Start with pgvector base for builder
FROM pgvector/pgvector:0.8.1-pg15 AS builder
# comment to trigger ci
# Install Python and required packages
RUN apt-get update && apt-get install -y \
python3 \
python3-venv \
python3-full \
build-essential \
libpq-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
ARG LETTA_ENVIRONMENT=DEV
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} \
UV_NO_PROGRESS=1 \
UV_PYTHON_PREFERENCE=system \
UV_CACHE_DIR=/tmp/uv_cache
# Set for other builds
ARG LETTA_VERSION
ENV LETTA_VERSION=${LETTA_VERSION}
WORKDIR /app
# Create and activate virtual environment
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Now install uv and uvx in the virtual environment
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
# Copy dependency files first
COPY pyproject.toml uv.lock ./
# Then copy the rest of the application code
COPY . .
RUN uv sync --frozen --no-dev --all-extras --python 3.11
# Runtime stage
FROM pgvector/pgvector:0.8.1-pg15 AS runtime
# Overridable Node.js version with --build-arg NODE_VERSION
ARG NODE_VERSION=22
# Allow overriding the OpenTelemetry Collector version and let Docker inject TARGETARCH during build
ARG OTEL_VERSION=0.96.0
ARG TARGETARCH
RUN set -eux; \
# Map TARGETARCH to the naming used by otel release assets
case "${TARGETARCH:-amd64}" in \
arm64|aarch64) OTEL_ARCH=arm64 ;; \
amd64|x86_64|x64) OTEL_ARCH=amd64 ;; \
*) OTEL_ARCH=amd64 ;; \
esac; \
apt-get update && \
# Install curl, Python, and PostgreSQL client libraries
apt-get install -y curl python3 python3-venv libpq-dev redis-server git && \
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
apt-get install -y nodejs && \
# Download and install OpenTelemetry Collector for the target architecture
OTEL_FILENAME="otelcol-contrib_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz"; \
echo "Downloading https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_FILENAME}"; \
curl -L "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_FILENAME}" -o /tmp/otel-collector.tar.gz && \
tar xzf /tmp/otel-collector.tar.gz -C /usr/local/bin && \
rm /tmp/otel-collector.tar.gz && \
mkdir -p /etc/otel && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Configure git to ignore ownership checks for mounted repos (safe.directory fix)
RUN git config --global --add safe.directory '*'
# Add OpenTelemetry Collector configs
COPY otel/otel-collector-config-file.yaml /etc/otel/config-file.yaml
COPY otel/otel-collector-config-clickhouse.yaml /etc/otel/config-clickhouse.yaml
COPY otel/otel-collector-config-signoz.yaml /etc/otel/config-signoz.yaml
ARG LETTA_ENVIRONMENT=DEV
ENV LETTA_ENVIRONMENT=${LETTA_ENVIRONMENT} \
VIRTUAL_ENV="/app/.venv" \
PATH="/app/.venv/bin:$PATH" \
POSTGRES_USER=letta \
POSTGRES_PASSWORD=letta \
POSTGRES_DB=letta
ARG LETTA_VERSION
ENV LETTA_VERSION=${LETTA_VERSION}
WORKDIR /app
# Copy virtual environment and app from builder
COPY --from=builder /app .
# Copy initialization SQL if it exists
COPY init.sql /docker-entrypoint-initdb.d/
EXPOSE 8283 5432 6379 4317 4318
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["./letta/server/startup.sh"]