Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/agent_env/agents/agents/letta-code/root.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ environment=HOME="/nonexistent",USER="agentenv-egress",LOGNAME="agentenv-egress"

; uvicorn itself, not entrypoint.sh: the marker holds for the process it's given to alone, and a shell that execs
; uvicorn would hand uvicorn an environment without it. HOME is the image's, /data, under which the CLI's state lives.
; Not restarted: agent-exit ends the container when it exits.
; Never restarted: see [eventlistener:agent-exit].
[program:agent]
command=/usr/local/bin/python3 -m uvicorn a2a_server:app --host 0.0.0.0 --port %(ENV_A2A_PORT)s --timeout-graceful-shutdown 5
user=agent
directory=/app
priority=10
autorestart=false
startretries=0
stopasgroup=true
killasgroup=true
stopwaitsecs=30
Expand All @@ -62,10 +63,12 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
environment=HOME="/data",USER="agent",LOGNAME="agent",AGENTENV_REAL_TIME="1",AGENTENV_EGRESS_PROXY="http://127.0.0.1:3128",NODE_EXTRA_CA_CERTS="/etc/agentenv/ca.pem",SSL_CERT_FILE="/etc/agentenv/ca-bundle.pem",REQUESTS_CA_BUNDLE="/etc/agentenv/ca-bundle.pem"

; The A2A server is the container, as it was before the clock: when it exits, or never gets going, this stops
; supervisord, which ends the container, rather than have a fresh server, without the dead one's MCP servers, peers and
; tasks, take its place while the dead one's CLI goes on. A stop of the container stops the server without an exit
; event, and the follower and the proxy restart in place. supervisord exits 0 either way.
; The server's exit, for any reason, stops supervisord and with it the container, as when the server was the
; container's main process: one restarted in place would have lost the env's MCP servers, its config, its peers and its
; running tasks, while the CLI the dead one started went on writing. The follower and the proxy restart in place.
; supervisord exits 0 however it stops, so the container's exit status doesn't tell a crash from a stop; its log does.
[eventlistener:agent-exit]
command=/usr/local/bin/python3 -I -c "while 1: import os, signal, sys; print('READY', flush=True); header = dict(f.split(':', 1) for f in sys.stdin.readline().split()); event = dict(f.split(':', 1) for f in sys.stdin.read(int(header['len'])).split()); event['processname'] == 'agent' and os.kill(os.getppid(), signal.SIGTERM); print('RESULT 2', end='\nOK', flush=True)"
command=/bin/sh -c 'while echo READY && read -r header; do body=$(head -c "${header##*len:}"); case " $body " in *" processname:agent "*) echo "the A2A server exited ($body): stopping the container" >&2; kill -TERM "$PPID";; esac; printf "RESULT 2\nOK"; done'
events=PROCESS_STATE_EXITED,PROCESS_STATE_FATAL
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
81 changes: 0 additions & 81 deletions tst/unit/agents/letta_code/test_server_exit.py

This file was deleted.

3 changes: 2 additions & 1 deletion tst/unit/agents/test_agent_clock_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def test_the_a2a_servers_exit_stops_supervisord_and_the_followers_or_the_proxys_
[section] = [name for name in _conf(agent).sections() if name.startswith("eventlistener:")]
listener = _conf(agent)[section]
assert set(listener["events"].split(",")) == {"PROCESS_STATE_EXITED", "PROCESS_STATE_FATAL"}
assert "%" not in listener["command"]
# As root, which may stop supervisord.
assert "user" not in listener and "%" not in listener["command"]
events = [("PROCESS_STATE_EXITED", "processname:clock groupname:clock from_state:RUNNING expected:0 pid:7"),
("PROCESS_STATE_FATAL", "processname:egress groupname:egress from_state:BACKOFF"),
("PROCESS_STATE_EXITED", "processname:agent-exit groupname:agent-exit from_state:RUNNING expected:1 pid:8"),
Expand Down
Loading