[PLUGIN] Add health and status HTTP endpoint#228
Open
LNAMTY wants to merge 1 commit into
Open
Conversation
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 scrapingdocker logs:GET /health—200while the loop is alive,503when the heartbeat is stale.GET /status— JSON:status(thinking/sleeping/idle/offline),current_iteration,last_activity_at,uptime_seconds,version.statuscomes from the loop's real state:src/loop.mettaheartbeats once per iteration, and the endpoint reportsofflinewhen no heartbeat arrives within the staleness window.start()is idempotent and never raises into the loop.Also:
Dockerfileexposes8081(unprivileged; runs asnobody),entrypoint.shallowlistsHEALTH_PORT/OMEGACLAW_VERSION, and docs added underdocs/reference-health-endpoint.md.How Has This Been Tested?
python3 src/health.py— self-test covering start,/statusschema, heartbeatupdates, the fresh→stale
offline/503transition, and404.-p 8081:8081):curl localhost:8081/statusshows anincrementing
current_iteration; pausing the loop flips/healthto503.Checklist