Skip to content

feat(docker): a control-plane image for agent_sys, carrying no engine - #149

Draft
ChengYao-amd wants to merge 1 commit into
dev.yihou.aiopt.all.1from
dev.yaoc.aiopt.docker
Draft

feat(docker): a control-plane image for agent_sys, carrying no engine#149
ChengYao-amd wants to merge 1 commit into
dev.yihou.aiopt.all.1from
dev.yaoc.aiopt.docker

Conversation

@ChengYao-amd

Copy link
Copy Markdown

No description provided.

@ChengYao-amd
ChengYao-amd force-pushed the dev.yaoc.aiopt.docker branch 2 times, most recently from 4ec17ab to 94b88cf Compare September 3, 2026 06:32
Comment thread agent_sys/cli/main.py
_start(registry, stream)
_settle(registry, stream, timeout=getattr(args, "timeout", None) or _SETTLE_TIMEOUT)
try:
if args.resume:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli is entry, also provide cmd option to run agent_sys in docker container, but how to implement it should all live in env_mgr
and it should be a system/user layer to obey the whole env_mgr layers rules (as the very first layer): for example: dockerfile pre-install claude code sdk、senera、LSP, then, a agent env should use it according the env mgr rely system

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything about how deploy docker container, mount what, expose what port to ensure every feature right. should be handle with env_mgr

Comment thread deploy/docker/agent-sys/build.sh Outdated
echo "[build] using the running ssh agent ($(ssh-add -l | wc -l) identity/identities)"
else
if [ -z "$SSH_KEY" ]; then
for candidate in "$HOME/.ssh/id_ed25519" "$HOME/.ssh/id_rsa" "$HOME/.ssh/id_ecdsa"; do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is id_ed25519? some thing local? the ssh config should be detected by env_mgr and automatically copied into docker container while runtime. packaging key in dockerfile is dangerous

Comment thread deploy/docker/agent-sys/build.sh Outdated
[ -n "$TAG" ] || TAG="infera/agent-sys:latest"

# ---- BuildKit ---------------------------------------------------------------
if ! docker buildx version >/dev/null 2>&1; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file should be extremely thin(like the only reason it exists is there is too many options just using docker build xxx). but is not.

Comment thread deploy/docker/agent-sys/check-tools.sh Outdated
fi
fi

# ----------------------------------------------------------------------- Magpie

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no magpie please, it should run in the experiment env, not with agent_sys. even though sometimes the two use the same

Comment thread deploy/docker/agent-sys/check-tools.sh Outdated

python3 - <<'PY'
import importlib.metadata as md
import pathlib

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it a demo, call it in one line
actually add a e2e_tests folder under tests, and run it in one line

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, as default ai agent backend, it should be checked with agent_sys togather.
actually all simple test should use a e2e_test/xxx_task_package.

# builds no engine.
deploy/docker/third_party

# Editors / OS

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this file even exist? build process should happens in a pure folder in which all materials are copied by build.sh into it.

ca-certificates curl gnupg \
git openssh-client rsync \
bash coreutils findutils gzip tar xz-utils jq less procps tini \
&& update-ca-certificates

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let add some debug friendly tools like zsh、oh-my-zsh、autosuggestion、tmux、https://github.com/gpakosz/.tmux

&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates curl gnupg \
git openssh-client rsync \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an sshd server is needed, and export sshd port to host, defult 18887, can be configed by cli opt or global config

&& /opt/venv/agent/bin/pip install -e "/opt/Magpie"

# ============================================================ stage: runtime ==
FROM base AS runtime

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the build process should be very fast so that agent_sys can be "build and run" every time on flight.
so this docker file can be optimized? also agent_sys should automatically build docker image if it's not exist and run in docker is required

Comment thread deploy/docker/Dockerfile.agent-sys Outdated
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
apt-get update \
&& apt-get install -y --no-install-recommends g++

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by bring task specific stuff to here, delete it all

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's really a container for agent sys only

Comment thread deploy/docker/Dockerfile.agent-sys Outdated
&& chmod 0755 /usr/local/bin/git

# The agent environment is the interpreter `python3` resolves to, because the
# task package bodies call `python3` by that name and `megapie.sh` calls

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no task package relative things here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and only one system python here, which is defined by base

@@ -0,0 +1,376 @@
# syntax=docker/dockerfile:1.7

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally the agent_sys run root should default in a host viable mount, not overlay and not tmp. better nfs,implemented by env_mgr. configurable

@ChengYao-amd
ChengYao-amd force-pushed the dev.yaoc.aiopt.docker branch 2 times, most recently from 825f102 to 33e7ab8 Compare September 4, 2026 07:28
Add a lightweight Docker image that carries agent_sys, Claude Code CLI,
and standard tools (git, ssh, rsync, uv) but no inference engines or
task-specific dependencies.  Those are installed by env_mgr at runtime
per each task package's environment recipe.

Key changes:

Docker image (deploy/docker/)
  - Multi-stage Dockerfile: base → toolchain → venv-agent → runtime.
    Magpie, compilers, and model weights are excluded by design.
  - build.sh: thin wrapper around docker build with --tag support.
  - README.md: build, usage (manual and --docker), and exit codes.

Container lifecycle (agent_sys/env_mgr/container.py)
  - ContainerManager: build, start, exec, stop.
  - Auto-detects and bind-mounts host ~/.ssh (ro) and ~/.claude.
  - Generates /etc/passwd and /etc/group for arbitrary UID/GID.

CLI --docker mode (agent_sys/cli/main.py)
  - --docker, --docker-image, --detect-and-copy-host-{ssh,claude}-config.
  - Delegates the run into the container, stripping docker-specific flags.

Work root (agent_sys/cli/environment.py)
  - INFERA_AGENT_SYSTEM_WORKROOT env var: names the run root directly.
  - Falls back to $XDG_STATE_HOME/agent-sys-demo when unset.
  - Empty or relative values are treated as unset.

Executor shutdown (agent_sys/agent/)
  - claude_sdk.py: deterministic teardown -- disconnect, cancel pending
    tasks, close the private event loop.  Idempotent.
  - runner.py: Runner.shutdown() releases all surviving attempts.
  - cli/main.py: outer try/finally calls runner.shutdown() after the
    run report, preventing leaked SDK reader tasks at process exit.

Tests
  - test_claude_sdk.py: stop disconnects, cancels, and closes the loop.
  - test_runner.py: shutdown stops and forgets every surviving attempt.
  - test_shutdown.py: CLI-level shutdown is called on both success and
    error paths.
  - test_build.py: INFERA_AGENT_SYSTEM_WORKROOT precedence, relative
    and empty values fall back correctly.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants