Skip to content

Add gRPC Streaming for Harness interface and integration#34

Open
anj-s wants to merge 18 commits into
mainfrom
u/anj/harness-interface-3
Open

Add gRPC Streaming for Harness interface and integration#34
anj-s wants to merge 18 commits into
mainfrom
u/anj/harness-interface-3

Conversation

@anj-s
Copy link
Copy Markdown
Collaborator

@anj-s anj-s commented May 28, 2026

Add stateful gRPC streaming input/output and streaming AGY example.

1. AX V2 Controller Integration (Registry-Centric Design)

  • Introduces internal/controller2 containing the new single-writer orchestrator.
  • Integrates harness.Harness and harness.Execution interfaces to abstract agent sandboxing and execution pipelines.
  • Implements a robust Registry-centric harness lookup with runtime fallbacks.

2. Antigravity gRPC Streaming Harness (internal/harness/antigravity.go)

  • Moves the Antigravity SDK integration away from one-off subprocess execution to an always-on, stateful gRPC protocol.
  • Go client connects via standard gRPC dials, constructs the strongly-typed AgentRequest, and streams output callbacks directly to V2.

3. Python gRPC Harness Server (python/antigravity/harness_server.py)

  • Created a python gRPC server implementation conforming to pb.AgentService and using grpc.aio.server().
  • Natively unpacks messages list, hydrates conversation history, and yields AgentResponse frames (thoughts, text, tool calls).
  • Architectural Documentation Added: Included a detailed NOTE ON ARCHITECTURE documenting the generic loader design where harness_server.py dynamically imports agent files (defaulting to agent.py) using --agent_file flags to provide clean L1/L2 SDK boundary decoupling.

4. Python Agent Scaffolding (examples/antigravity_agent/agent.py)

  • Defines custom Python tools (get_weather), model identity, and persona configuration.
  • Provides a dual-purpose standalone CLI sandbox for L2 API local debugging.
  • Architectural Documentation Added: Included a detailed NOTE ON ARCHITECTURE explaining how this file acts as both a standalone L2 CLI debugging tool and a declarative config module imported by harness_server.py.

5. E2E Setup & Running Instructions (cmd/e2e/main.go)

  • Consolidated Go harness commands and established the main E2E verification runner (cmd/e2e/main.go).
  • Instructions Added: Appended explicit, step-by-step headers to cmd/e2e/main.go documenting how to start the Python server (with proper PYTHONPATH to bypass python path collisions) and drive the Go client demonstration.

6. Test Coverage & Verification

  • Go unit tests in internal/harness/antigravity_test.go (Mock gRPC server, Passed).
  • Go workspace-wide tests in internal/controller2 and other modules (All Passed).
  • Python server integration tests in python/antigravity/harness_server_test.py (Mock async gRPC stub client, Passed).
  • Go-Python E2E integration demonstrated successfully with streaming output captured from Python GenAI API.

anj-s added 3 commits May 22, 2026 13:37
…ntric design

This PR implements the integration of the Antigravity agent as the first built-in harness in AX Controller V2, satisfying the first item on the AX roadmap. It also refactors the architecture to make `Registry` the Single Source of Truth (SSOT) and introduces robust fallback mechanisms.

### Goals
1. **Built-in Harness Integration**: Enable AX Controller V2 to execute Python-based Antigravity agents.
2. **Registry-Centric Architecture (SSOT)**: Centralize the management of both agents and harnesses in the `Registry`.
3. **Inverted Control (Dependency Injection)**: Decouple the `Controller` from harness creation by passing `Registry` as an input config.
4. **Resilient Fallbacks**: Implement build-time (script check) and runtime (registration check) fallbacks to a Test Harness to prevent failures in unconfigured environments.
5. **End-to-End Verification**: Provide a comprehensive E2E demonstration script.

### Key Changes
- **Registry Updates (`internal/controller2/registry.go`)**: Added support for registering and retrieving Go `Harness` instances in `Registry`.
- **Controller V2 Refactoring (`internal/controller2/controller.go`)**:
  - Received `Registry` as an input config in `New`.
  - Updated `Exec` to retrieve the harness from the registry using `AgentId` at runtime, falling back to the test harness if not found.
- **Antigravity Go Harness (`internal/harness/antigravity.go`)**:
  - Implemented `AntigravityHarness` which executes the Python agent as a subprocess, passing the prompt as an argument.
  - Captured stdout and returned it as a streamed message.
  - Added a TODO to migrate to a gRPC server in the next step to avoid subprocess overhead.
- **Python Agent Modification (`examples/antigravity_agent/agent.py`)**: Modified the script to accept dynamic prompt inputs from command line arguments.
- **Verification (`internal/controller2/controller_test.go`, `fork_test.go`, `e2e.go`)**:
  - Updated unit tests to adapt to the new `Registry` injection.
  - Added unit tests for both build-time (implemented manually in test setup) and runtime fallbacks.
  - Created `e2e.go` in the root to demonstrate all 3 execution paths (Runtime Fallback, Build-time Fallback, and actual Antigravity Happy Path).
Move the Google Antigravity SDK integration from a one-off subprocess to an always-on, stateful WebSocket streaming harness protocol.

- Python WebSocket Server (harness_server.py): Exposes a /ws endpoint wrapping google-antigravity SDK, hydrates event log history, and streams thought/text delta frames over WebSockets.
- Go Harness Client (antigravity.go): Refactored client to connect over gorilla/websocket and stream output callbacks (OnMessage/OnComplete).
- Unit Tests: Implemented robust unit test suites in both Go and Python.
- Verification: Created hack/run-antigravity-streaming.sh for E2E verification.

TAG=agy
CONV=ae7297af-6274-4477-81b3-a5eb53abb0e1
@anj-s anj-s changed the base branch from u/anj/harness-interface-2 to main May 28, 2026 18:42
@anj-s anj-s changed the title Add WebSocket Streaming for Harness interface and integration Add gRPC Streaming for Harness interface and integration May 28, 2026
@anj-s anj-s marked this pull request as ready for review June 1, 2026 18:43
@anj-s anj-s requested a review from rakyll June 1, 2026 19:36
Comment thread cmd/e2e/main.go
fmt.Printf("WARNING: python3 not found, falling back to test harness: %v\n", err)
badHarness = harnesstest.New()
} else if _, err := os.Stat(scriptPath); err != nil {
if _, err := os.Stat(scriptPath); err != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can remove this, right?


# 6. Stream semantic chunks (Thoughts, Text, and ToolCalls) in real-time
async for chunk in response.chunks:
if isinstance(chunk, Text):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feel free to use a more structured format like JSONL.

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.

2 participants