Skip to content

About

On-machine A2A relay agent for repo issues, local worktrees, Copilot CLI, approval gates, and Draft PRs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Relay Agent

Relay Agent is an on-machine A2A agent for developer task delegation.

It accepts a repository issue over the standard A2A protocol, asks the local developer to approve it, creates an isolated Git worktree, delegates the coding work to GitHub Copilot CLI, and optionally publishes the result as a GitHub Draft PR.

The local worktree is always retained so the developer can inspect or modify the changes before accepting them.

A2A assignment
  -> Relay Agent URL (Dev Tunnel)
  -> approval dialog / task board
  -> clone or reuse repository cache
  -> create isolated worktree
  -> run Copilot CLI
  -> commit local changes
  -> optionally push and create a Draft PR
  -> notify the developer

Screenshots

Approval dialog

Review the issue context and explicitly approve local execution before Relay Agent creates a worktree or starts the coding agent.

Relay Agent approval dialog

Task board

Track pending approvals, work in progress, and completed tasks from the local board.

Relay Agent task board

Safety defaults

  • Every assignment requires explicit approval.
  • No repository is cloned and no worktree is created before approval.
  • The local worktree is preserved if Draft PR creation fails.
  • Draft PRs are never marked ready automatically.
  • Repository credentials and GitHub tokens are not stored by Relay Agent.
  • Each developer signs in with their own GitHub account.

Requirements

The bootstrap script can install the required tools on Windows:

  • Git
  • Python 3.10 or newer
  • GitHub CLI (gh)
  • GitHub Copilot CLI
  • Microsoft Dev Tunnel CLI

Windows App Installer (winget) is required for automatic system package installation.

Install from the private repository

The GitHub account cloning this private repository must have access to it.

gh auth login
gh repo clone xinyi-gong/relay-agent
cd relay-agent
.\bootstrap.ps1

bootstrap.ps1:

  1. Installs any missing system tools with winget.
  2. Installs GitHub Copilot CLI with npm.
  3. Installs Relay Agent into an isolated per-user Python environment.
  4. Adds the relay-agent command to the user PATH.
  5. Asks which GitHub repository this Relay Agent serves.

To verify an already provisioned machine without installing system packages:

.\bootstrap.ps1 -SkipSystemPackages

To install without opening the configuration wizard:

.\bootstrap.ps1 -SkipConfigure

Configure the developer identity

Each developer uses their own GitHub account:

gh auth login
gh auth status
relay-agent init
relay-agent whoami

The configuration file is stored at:

%APPDATA%\relay-agent\config.toml

relay-agent init binds this Relay Agent to one GitHub repository in owner/repository form. All assignments received at this agent's URL are handled in that repository.

Copilot execution, approval, and Draft PR publishing are always enabled by the initialization wizard:

WORKER_MODE = "copilot"
REQUIRE_APPROVAL = "true"
ASYNC_WORK = "true"
DRAFT_PR_ENABLED = "true"

The public URL is not entered during initialization. setup-tunnel.ps1 discovers the developer's Dev Tunnel URL and writes PUBLIC_BASE_URL automatically.

Configure the public Relay Agent URL

Relay Agent does not require a central registry. Each developer exposes their local agent through a named Dev Tunnel and gives that URL directly to the A2A caller.

Authenticate and configure a tunnel:

devtunnel user login -g
.\setup-tunnel.ps1

setup-tunnel.ps1:

  1. Resolves the signed-in GitHub username.
  2. Creates a tunnel named relay-<github-user>.
  3. Adds public HTTP port 8080.
  4. Resolves the public HTTPS URL.
  5. Writes PUBLIC_BASE_URL and TUNNEL_NAME to config.toml.
  6. Prints the URL to give to the A2A caller.

Start the tunnel and keep that terminal open:

devtunnel host relay-<github-user>

Start Relay Agent in another terminal:

relay-agent start

Verify the public AgentCard:

https://<tunnel>-8080.<region>.devtunnels.ms/.well-known/agent.json

The AgentCard url field must contain the same public Dev Tunnel URL, not localhost.

Foundry Dispatch Integration

Relay Agent is the on-machine endpoint in the GitHub Actions -> Microsoft Foundry -> A2A workflow. The workflow and hosted Dispatcher remain separate deployments; this repository contains only the local worker that receives the A2A assignment and performs approved work. See docs/foundry-dispatch.md for the boundary and runtime contract.

Assignment contract

Every assignment must be a JSON object containing an issue number:

{
  "issue_number": "123",
  "title": "Fix the upload retry behavior",
  "body": "Add bounded retries and cover the timeout case.",
  "assignee": "developer-github-login"
}

The dispatcher does not send a repository. Relay Agent reads its fixed REPO_SLUG from the configuration created by relay-agent init.

Repository cache and worktrees

Default locations:

%APPDATA%\relay-agent\
  repos\
    owner\
      repository\
  worktrees\
    owner\
      repository\
        issue-123\

Repositories are cloned once and reused from the cache. Every issue gets its own branch and worktree:

branch:   agent/issue-123
worktree: ...\worktrees\owner\repository\issue-123

Approval experience

New assignments appear in two places:

  • a Windows approval dialog
  • the Pending Approval column on the task board

The first decision wins. Approving from the board closes the dialog; responding to the dialog resolves the board item.

The desktop dialog lets the developer edit the incoming prompt before approving. Relay Agent passes that edited prompt to the local coding agent; board approval retains the original dispatched prompt.

The task board is available by default at:

http://127.0.0.1:8181/

The Windows system tray icon also opens the board.

Task actions include:

  • Approve
  • Decline
  • Open GitHub issue
  • Stop
  • Open in IDE
  • Open Draft PR
  • Delete

Draft PR publishing

When enabled, Relay Agent:

  1. Pushes the issue branch.
  2. Reuses an existing open PR for that branch, if present.
  3. Otherwise creates a new GitHub Draft PR.
  4. Stores the PR URL on the task board.

Configuration:

DRAFT_PR_ENABLED = "true"
DRAFT_PR_REMOTE = "origin"

The PR is created in the repository bound during relay-agent init.

The signed-in GitHub account must have permission to push a branch and create a PR in the target repository.

If publishing fails, the task remains completed locally and the error appears on the task card.

Common configuration

Environment variables override values in config.toml.

Setting Default Purpose
RELAY_GITHUB_USER auto-detected Developer identity
A2A_HOST 127.0.0.1 Local A2A bind address
A2A_PORT 8080 Local A2A port
PUBLIC_BASE_URL local URL Public Dev Tunnel URL advertised by AgentCard
REPO_SLUG required Fixed GitHub repository as owner/repository
REPO_CACHE_ROOT %APPDATA%\relay-agent\repos Cached repository checkouts
WORKTREE_ROOT %APPDATA%\relay-agent\worktrees Issue worktrees
WORKER_MODE mock mock or copilot
COPILOT_AUTOPILOT true Run Copilot CLI unattended after approval
REQUIRE_APPROVAL true Require approval before any repository work
ASYNC_WORK true Run approval and long work in the background
APPROVAL_TIMEOUT_SEC 300 Approval timeout; 0 waits indefinitely
BOARD_ENABLED true Enable the local task board
BOARD_PORT 8181 Task board port
TRAY_ENABLED true Enable the Windows tray icon
DESKTOP_TOAST true Enable Windows notifications
DRAFT_PR_ENABLED false Push and create/reuse a Draft PR
DRAFT_PR_REMOTE origin Git remote used for branch push

CLI commands

relay-agent init
relay-agent start
relay-agent whoami
relay-agent config-path
relay-agent install-autostart
relay-agent uninstall-autostart

Install Windows login autostart:

relay-agent install-autostart

Remove it:

relay-agent uninstall-autostart

Local smoke test

Start Relay Agent in mock mode:

$env:WORKER_MODE = "mock"
relay-agent start

Send a local A2A assignment:

python scripts\dispatch.py `
  --url http://127.0.0.1:8080 `
  --issue 123 `
  --title "Relay Agent smoke test" `
  --body "Create the mock task artifact." `
  --assignee developer-github-login

The request returns immediately with pending-approval. Approve it from the dialog or task board to continue.

Development

Create a local environment and install editable:

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .

Run tests:

.\.venv\Scripts\python.exe -m unittest discover -s tests -v

Run compile validation:

.\.venv\Scripts\python.exe -m compileall -q relay_agent tests scripts

About

On-machine A2A relay agent for repo issues, local worktrees, Copilot CLI, approval gates, and Draft PRs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages