Skip to content

feat: add remote runtime state bridge - #153

Closed
hvpareja wants to merge 3 commits into
Human-Agent-Society:mainfrom
hvpareja:feat/remote-runtime-adapter
Closed

feat: add remote runtime state bridge#153
hvpareja wants to merge 3 commits into
Human-Agent-Society:mainfrom
hvpareja:feat/remote-runtime-adapter

Conversation

@hvpareja

@hvpareja hvpareja commented Jun 29, 2026

Copy link
Copy Markdown

Motivation

Refs #151.

CORAL currently has local subprocess runtimes and public run state, but no generic contract for surfacing agents that execute in managed remote runtimes. This PR starts with the additive state-bridge layer so remote adapters can publish normalized state without changing the existing local worktree agent flow.

Authored with assistance from Codex. I read every changed line before opening this draft PR and verified the commands below locally.

Changes

  • Adds RemoteRuntime, remote agent handle/spec/state dataclasses, dynamic adapter loading, and a RemoteStateBridge that writes .coral/public/remote_state/.
  • Adds agents.remote_runtime config with YAML class: support and runtime-specific config payloads.
  • Lets AgentManager periodically sync remote state when the block is configured, while leaving local subprocess agents unchanged.
  • Surfaces remote state in coral status and the web /api/status response.
  • Adds focused tests for config parsing, adapter loading, protocol validation, and bridge output.
  • Documents the opt-in bridge in README and docs pages for configuration and agent runtimes.

Test plan

  • uv run --extra dev python -m pytest tests/ -v — 552 passed, 1 skipped
  • uv run --extra dev ruff check . — passed
  • uv run --extra dev ruff format --check . — passed

Affected areas

  • coral/agent/ (runtime, manager, heartbeat, warmstart)
  • coral/grader/ (daemon, TaskGrader, subprocess grader, loader)
  • coral/hub/ (attempts, notes, skills, checkpoint)
  • coral/workspace/ (project setup, worktrees, grader env)
  • coral/cli/ (commands, helpers)
  • coral/hooks/ (post_commit / submit_eval)
  • coral/template/ (CORAL.md, bundled skills/agents)
  • coral/gateway/ (LiteLLM gateway)
  • coral/web/ (dashboard)
  • examples/ (new or modified task)
  • docs/ (docs site)
  • CI / tooling / packaging
  • Other: configuration schema

Checklist

  • Title follows Conventional Commits (feat:, fix:, docs:, refactor:, ...).
  • uv run pytest tests/ -v passes locally.
  • uv run ruff check . and uv run ruff format --check . pass.
  • Added or updated tests under tests/ for any behavior change.
  • Updated docs (docs/content/, README, or relevant skill under .claude/skills/) for any user-visible or contract change.
  • If this changes a config field, CLI flag, hook, or runtime contract — noted the migration path in the PR description.
  • New examples/<task>/: coral validate <task> succeeds and a smoke run produces at least one finalized score. No hidden answer keys committed under seed/.
  • AI-assisted PR: a human author has read every changed line and can defend the design. See AGENTS.md.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@hvpareja is attempting to deploy a commit to the yhy-4770's projects Team on Vercel.

A member of the Team first needs to authorize it.

@hvpareja

Copy link
Copy Markdown
Author

This PR has been generated by IA. I am reviewing now.

Comment thread coral/agent/manager.py
logger.info(f"Monitoring {len(self.handles)} agent(s) (check every {check_interval}s)...")

while self._running:
self._sync_remote_state()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review note: _sync_remote_state() calls the adapter's collect_metrics() synchronously inside the manager monitor loop. That keeps this first cut simple, but a slow or blocking remote adapter could delay heartbeat/restart handling. If this grows beyond lightweight polling, the next step should be a timeout, background worker, or async sync path.

Comment thread coral/agent/remote.py Outdated
self.state_dir.mkdir(parents=True, exist_ok=True)

for state in serialized:
self._write_json(self.state_dir / f"{state['agent_id']}.json", state)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Review note: agent_id comes from the adapter and is used directly as a filename. If a remote adapter returns values containing /, .., or other path separators, this could write outside the intended remote_state directory or create surprising nested paths. Before this becomes a stable contract, we should either validate/sanitize agent_id here or document a strict safe-ID requirement for adapters.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 54d5cc3 by percent-encoding agent_id for the per-agent state filename while preserving the original agent_id in index.json and the snapshot payload. Added test_remote_state_bridge_encodes_agent_id_for_filename to cover ../remote/agent.

@hvpareja

Copy link
Copy Markdown
Author

Superseded by #154, which models the remote proxy as a first-class AgentRuntime instead of a parallel state bridge. Keeping #154 as the active draft for the local-workspace-primary remote runtime approach.

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.

1 participant