Skip to content

feat: Python SDK feature parity — core types, hooks, tools, triggers, interactive loop#5

Merged
codeitlikemiley merged 6 commits into
mainfrom
feat/python-sdk-parity
May 29, 2026
Merged

feat: Python SDK feature parity — core types, hooks, tools, triggers, interactive loop#5
codeitlikemiley merged 6 commits into
mainfrom
feat/python-sdk-parity

Conversation

@codeitlikemiley
Copy link
Copy Markdown
Owner

Summary

Implements full feature parity between the Rust and Python Antigravity SDKs, closing all identified gaps from the SDK comparison analysis.

Changes

New Modules (5 files)

File Description
src/error.rs Typed error hierarchy: AntigravityError (Connection, Execution, Validation)
src/context.rs Hierarchical HookContext state store (Session→Turn→Operation)
src/tool_context.rs Session-scoped ToolContext with state store and agent communication
src/trigger_helpers.rs every() periodic trigger factory
src/interactive.rs run_interactive_loop() REPL utility (native only)

Extended Modules (4 files)

File Changes
src/hooks.rs Added on_session_end, post_turn, on_compaction hooks + dispatchers + tests
src/tools.rs Added needs_context() / call_with_context() for context-aware tools
src/types.rs Added multimodal pipeline (Media, Content, MimeType — 32 extensions), trigger types
src/lib.rs Wired all new modules into public API

Documentation

File Changes
README.md Added 7 new sections: Error Handling, Multimodal Content, Lifecycle Hooks, Hook Context, Context-Aware Tools, Trigger Helpers, Interactive Loop

Python SDK Feature Mapping

Python Feature Rust Implementation Status
AntigravityConnectionError / AntigravityValidationError AntigravityError::Connection / AntigravityError::Validation
Image, Document, Audio, Video, Content Media, Content, MimeType enums
SessionContextTurnContextOperationContext HookContext::new() / HookContext::child()
ToolContext with get_state/set_state ToolContext struct
on_session_end, post_turn, on_compaction Hook trait methods
every() trigger helper trigger_helpers::every()
run_interactive_loop() interactive::run_interactive_loop()

Testing

  • 90 unit tests — all pass
  • 4 integration tests — all pass
  • 4 doc-tests — all pass (including new modules)
  • cargo clippy --all-targets -- -D warnings0 warnings

Backwards Compatibility

All changes are fully backwards compatible:

  • New hook methods have default no-op implementations
  • Tool::needs_context() defaults to false
  • Existing PolicyEnforcer uses defaults automatically
  • No breaking changes to public API

- Add AntigravityError enum (Connection, Execution, Validation) in error.rs
- Add HookContext hierarchical state store (Session→Turn→Operation) in context.rs
- Add ToolContext with session-scoped state and agent communication in tool_context.rs
- Add multimodal content pipeline: Media, Content, MimeType (32 extensions)
- Add trigger types: TriggerDelivery, FileChange, FileChangeKind
- Add on_session_end, post_turn, on_compaction hooks to Hook/DynHook traits
- Add dispatch_session_end, dispatch_post_turn, dispatch_on_compaction to HookRunner
- Add needs_context() and call_with_context() to Tool/DynTool traits
- All additions are backwards compatible with default implementations
- Add trigger_helpers.rs with every() periodic trigger factory
- Add interactive.rs with run_interactive_loop() REPL (native only)
- Wire all new modules in lib.rs: context, error, tool_context, trigger_helpers, interactive
- Add Error Handling section with AntigravityError
- Add Multimodal Content section with Content/Media/MimeType
- Add Lifecycle Hooks section showing full hook API
- Add Hook Context section with hierarchical state
- Add Context-Aware Tools section with ToolContext
- Add Trigger Helpers section with every() factory
- Add Interactive Loop section with run_interactive_loop()
- Add mcp_servers field to AgentConfig
- Add .mcp_server() and .mcp_servers() builder methods
- Wire MCP configs through Agent::start() to LocalConnectionStrategy
- Add mcp_servers to LocalConnectionStrategy struct and constructor
- Fix all call sites (tests, README example)
- Add docs/agent.md — Agent builder, typestate, lifecycle
- Add docs/connections.md — Connection trait, Local/WASM strategies
- Add docs/conversation.md — Stateful sessions, streaming, chunks
- Add docs/hooks.md — Hook trait, context, policy enforcer
- Add docs/mcp.md — MCP server config, builder, policies
- Add docs/tools.md — Tool trait, context-aware tools, ToolRunner
- Add docs/triggers.md — Trigger trait, helpers, file watchers
- Add MCP Integration section to README
- Add Sugared Thoughts & Tool Call Streams section to README
- Add Component Documentation links to README
@codeitlikemiley codeitlikemiley merged commit 11853ec 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