Skip to content

Perform agent connectivity test on startup#228

Open
zeroklaw wants to merge 7 commits into
mainfrom
zeroklaw/issue-224-agent-health-check
Open

Perform agent connectivity test on startup#228
zeroklaw wants to merge 7 commits into
mainfrom
zeroklaw/issue-224-agent-health-check

Conversation

@zeroklaw

@zeroklaw zeroklaw commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements agent connectivity health check on startup as requested in #224.

On startup, Yoke now queries the /health endpoint of each configured agent before starting the server. If any agent is unreachable, returns a non-200 status code, or reports a status other than ok, Yoke reports an error and exits without starting the server.

Changes

src/harness.rs

  • Added HealthResponse struct (status, platform, version: String, derives Debug, Clone, Deserialize)
  • Added HealthCheckError enum with Http, BadStatus, and Parse variants (uses thiserror)
  • Added check_agent_health async function that queries {base_url}/health and verifies status == "ok"
  • Added 3 inline Display tests for HealthCheckError variants

src/main.rs

  • Added use yoke::harness::check_agent_health; import
  • Inserted health check loop after validate_triggers block, before watch::channel(false)
  • Logs successful checks at info! level with agent name, platform, and version
  • Fails fast with ContextError wrapping HealthCheckError on any agent failure

tests/harness_tests.rs

  • Appended 6 health check tests: all_healthy, bad_status, http_error, parse_error, unhealthy_status, trailing_slash

tests/health_startup_tests.rs (new file)

  • 6 integration tests: multi_agent_all_healthy, multi_agent_one_unhealthy, multi_agent_status_not_ok, multi_agent_invalid_json, multi_agent_connection_refused, health_check_url_construction

README.md

  • Added "### 6. Agent Health Check" section documenting the startup behavior

AGENTS.md

  • Updated Project Structure, Key Design Decisions, and Integration tests sections with health check documentation

Closes #224

zeroklaw added 7 commits July 3, 2026 11:07
Add `check_agent_health` async function to `src/harness.rs` that queries
the `/health` endpoint of each configured agent and verifies the response
contains `status: "ok"`. Integrate this into `src/main.rs` as a startup
check after trigger validation and before the server starts.

New types:
- `HealthResponse`: deserializes the `/health` JSON response
- `HealthCheckError`: typed errors for HTTP failures, bad status codes,
  and parse failures

The startup health check iterates over `config.agents` and fails fast if
any agent is unreachable or reports an unhealthy status, preventing the
server from starting with broken agent connectivity.

Tests added:
- `tests/harness_tests.rs`: 7 new health check tests (all_healthy,
  bad_status, http_error, parse_error, unhealthy_status, trailing_slash)
- `tests/health_startup_tests.rs`: 6 new integration tests covering
  multi-agent scenarios, connection refused, invalid JSON, and URL
  construction
- `src/harness.rs` inline tests: 3 Display tests for HealthCheckError
  variants

Docs updated:
- `README.md`: documented the startup agent health check behavior
- `AGENTS.md`: documented the new health check types and startup flow
Fix compilation error in src/harness.rs (missing semicolon after
format!() call) and fix mockito API usage in test files
(ServerGuard::new_async() -> Server::new_async()).

Closes #224
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.

Perform agent connectivity test on startup

1 participant