Skip to content

[PLUGIN] Add health and status HTTP endpoint#228

Open
LNAMTY wants to merge 1 commit into
asi-alliance:mainfrom
LNAMTY:feat/health-status-endpoint
Open

[PLUGIN] Add health and status HTTP endpoint#228
LNAMTY wants to merge 1 commit into
asi-alliance:mainfrom
LNAMTY:feat/health-status-endpoint

Conversation

@LNAMTY

@LNAMTY LNAMTY commented Jul 5, 2026

Copy link
Copy Markdown

Description

Closes #216.

Adds a small HTTP endpoint served from the agent process (src/health.py, standard library only) so orchestrators can poll liveness/state instead of scraping docker logs:

  • GET /health200 while the loop is alive, 503 when the heartbeat is stale.
  • GET /status — JSON: status (thinking/sleeping/idle/offline), current_iteration, last_activity_at, uptime_seconds, version.

status comes from the loop's real state: src/loop.metta heartbeats once per iteration, and the endpoint reports offline when no heartbeat arrives within the staleness window. start() is idempotent and never raises into the loop.

Also: Dockerfile exposes 8081 (unprivileged; runs as nobody), entrypoint.sh allowlists HEALTH_PORT/OMEGACLAW_VERSION, and docs added under docs/reference-health-endpoint.md.

How Has This Been Tested?

  • python3 src/health.py — self-test covering start, /status schema, heartbeat
    updates, the fresh→stale offline/503 transition, and 404.
  • Built the image and confirmed the server starts on boot.
  • Manual (publish -p 8081:8081): curl localhost:8081/status shows an
    incrementing current_iteration; pausing the loop flips /health to 503.

Checklist

  • The code generated by LLM is reviewed by the PR creator
  • Self-review completed
  • Test scenarios above are passed with the version of the code

Adds a small HTTP server (src/health.py, standard library only) that exposes
the agent's liveness and state so orchestrators can poll it directly instead
of scraping docker logs:

  GET /health   200 while the loop is alive, 503 when the heartbeat is stale
  GET /status   JSON: status, current_iteration, last_activity_at,
                uptime_seconds, version

status is one of thinking/sleeping/idle/offline and is fed from the main loop,
which calls health.heartbeat once per iteration; offline is reported when no
heartbeat arrives within the staleness window.

- src/loop.metta: start the server in initLoop, heartbeat each iteration
- lib_omegaclaw.metta: import the module
- Dockerfile: EXPOSE 8081 (unprivileged; the agent runs as nobody)
- entrypoint.sh: allowlist HEALTH_PORT and OMEGACLAW_VERSION
- docs/reference-health-endpoint.md: endpoint and configuration reference
@vsbogd

vsbogd commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

I would prefer implementing it as plugin after merging #222 and introducing the API which allows implementing it as a plugin. But this PR shows which API exactly should be introduced. Thank you for raising it.

@vsbogd vsbogd changed the title Add health and status HTTP endpoint [PLUGIN] Add health and status HTTP endpoint Jul 15, 2026
@vsbogd vsbogd added the plugin label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OMEGA-222] Add a health and status endpoint to OmegaClaw

2 participants