Skip to content

feat: align Rust SDK with Python SDK (ClientInfo, Vertex AI, TerminalError, 9-bucket policy)#4

Merged
codeitlikemiley merged 8 commits into
mainfrom
feat/python-sdk-alignment
May 29, 2026
Merged

feat: align Rust SDK with Python SDK (ClientInfo, Vertex AI, TerminalError, 9-bucket policy)#4
codeitlikemiley merged 8 commits into
mainfrom
feat/python-sdk-alignment

Conversation

@codeitlikemiley
Copy link
Copy Markdown
Owner

Summary

Aligns the Rust SDK with recent Python SDK changes to ensure feature parity across both SDKs.

Changes

1. ClientInfo Handshake Protocol

  • Added ClientInfo message to InputConfig proto (language, version fields)
  • Rust SDK now identifies itself during handshake (language="rust", version=<crate_version>)
  • Enables server-side SDK analytics and compatibility routing

2. Vertex AI Backend Support

  • Added use_vertex, project, and location fields to GeminiConfig and InputConfig proto
  • Allows agents to target Vertex AI endpoints instead of the default Gemini Developer API

3. TerminalError Status

  • Added TerminalError variant to StepStatus enum (proto state=5)
  • Created AntigravityExecutionError custom error type
  • Both local and WASM connection strategies propagate terminal errors to terminate agent execution
  • Agent server example handles TerminalError in SSE events

4. 9-Bucket Policy Enforcer

  • Upgraded from 6-bucket to 9-bucket priority system: specific/prefix/global × deny/ask/allow
  • Added longest-match MCP tool parsing via sorted server_names list for security
  • Added fail-closed security guard: MCP policies without registered servers are rejected
  • Added matches_target() for granular policy matching (exact, prefix wildcard, global)

5. MCP Server Config Enhancements

  • Added name, enabled_tools, disabled_tools fields to all McpServerConfig variants (Stdio/Sse/Http)
  • Added McpServerConfig::name() accessor method

6. Tests

  • Added test_agent_terminal_error_propagation integration test
  • Updated test_agent_chat_integration to verify client metadata handshake
  • Refactored mock_localharness to support terminal error and ClientInfo verification
  • Fixed model version: gemini-2.5-flashgemini-3.5-flash for consistency

7. Chore

  • Bumped harness version to 0.1.1

Test Results

  • 60 unit tests: ✅ all pass
  • 4 integration tests: ✅ 3/3 mock-harness tests pass (1 real-harness test skipped without binary)
  • Clippy: ✅ zero warnings
  • Formatting: ✅ cargo fmt clean

Files Changed (11 files, +608/-97)

File Changes
proto/localharness.proto ClientInfo msg, Vertex AI fields
src/types.rs GeminiConfig, McpServerConfig, TerminalError, AntigravityExecutionError
src/policy.rs 9-bucket PolicyEnforcer, MCP tool parsing, fail-closed guard
src/local.rs ClientInfo handshake, Vertex AI, TerminalError handling
src/wasm.rs Mirror of local.rs changes for WASM target
src/agent.rs PolicyEnforcer::new() API update
src/bin/start_harness.rs ProtoClientInfo import
src/bin/mock_localharness.rs Test harness with ClientInfo + TerminalError support
examples/agent_server/src/main.rs TerminalError SSE handling
tests/integration_tests.rs New tests + model version fix
scripts/install_harness.sh Harness version bump

…s, and MCP server fields

- Add ClientInfo message (language, version) to InputConfig proto for SDK identification
- Add use_vertex, project, location fields to InputConfig for Vertex AI backend support
- Add TerminalError variant to StepStatus enum (proto state=5)
- Add AntigravityExecutionError type for terminal failures
- Add name, enabled_tools, disabled_tools fields to all McpServerConfig variants
- Add McpServerConfig::name() accessor method
- Extend GeminiConfig with vertex/project/location fields and update default tests
…l parsing

- Expand from 6-bucket to 9-bucket system (specific/prefix/global × deny/ask/allow)
- Add longest-match MCP tool parsing via sorted server_names list
- Add fail-closed security guard: reject MCP policies without registered servers
- Update enforce() signature to accept mcp_servers parameter
- Add matches_target() for granular policy matching (exact, prefix wildcard, global)
- Update all existing tests for new enforce() API signature
…nnection strategies

- Send ClientInfo (language='rust', version=crate version) in InputConfig during handshake
- Pass use_vertex/project/location fields from GeminiConfig to proto InputConfig
- Map proto state=5 to StepStatus::TerminalError in both local and wasm readers
- Propagate TerminalError as AntigravityExecutionError to terminate agent execution
- Add rustc_version() helper for client metadata reporting
- Update start_harness.rs import for ProtoClientInfo
… handling

- Update Agent::start() to pass empty server_names to PolicyEnforcer::new()
- Handle StepStatus::TerminalError in agent_server SSE streaming
- Map TerminalError to 'TERMINAL_ERROR' status string in SSE events
…r propagation

- Add test_agent_terminal_error_propagation to verify fatal error handling
- Update test_agent_chat_integration to verify client metadata (language/version)
- Refactor mock_localharness: extract handle_ws_connection() to satisfy clippy
- Update mock harness to decode InputConfig and echo client info in responses
- Fix model version: gemini-2.5-flash -> gemini-3.5-flash in all tests
The install script (just install / scripts/install_harness.sh) places the
binary at ./bin/localharness. Prioritize this location before system PATH
since it's the standard install method for Rust SDK users.

Lookup order is now:
1. ANTIGRAVITY_HARNESS_PATH env var (explicit override)
2. ./bin/localharness (local install via just install)
3. System PATH (pip install google-antigravity)
4. Python site-packages
@codeitlikemiley codeitlikemiley force-pushed the feat/python-sdk-alignment branch from 8aaa3b6 to 715c689 Compare May 29, 2026 10:45
@codeitlikemiley codeitlikemiley merged commit ac9515b into main May 29, 2026
1 check passed
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