Skip to content
← All posts Architecture & Runtime 3 min read
The Polyglot AI: Achieving SDK Parity across Python, TypeScript, and Rust

The Polyglot AI: Achieving SDK Parity across Python, TypeScript, and Rust

In the rapidly evolving landscape of Agentic AI, developers often face a "Language Tax." You might prototype an AI tool in Python, but your production web backend runs on TypeScript, and your high-performance data processing requires Rust.

Typically, this means rewriting validation logic, security checks, and documentation three different times. Worse, your AI Agent might "perceive" the Python version slightly differently than the Rust version due to inconsistent metadata.

In this article, we explore how apcore solves this through Synchronized SDK Implementation. We’ve built the Python, TypeScript, and Rust SDKs to be mirrors of each other, ensuring that your AI-Perceivable modules remain consistent, no matter the tech stack.


One Mental Model, Three Ecosystems

The core philosophy of apcore is that the Protocol comes first, the Language comes second.

Whether you are a data scientist, a frontend engineer, or a systems programmer, the workflow is identical:

  1. Define a function.

  2. Annotate it with metadata (id, description, tags).

  3. Extract the schema automatically.

  4. Register it into a discovery-ready Registry.

Because the SDKs are synchronized, a module defined in Rust generates the exact same JSON representation as one defined in Python. This allows an AI Agent to transition between environments without ever losing its "understanding" of what a tool does.


Deep Dive: The Python SDK as the Blueprint

Python is the lingua franca of AI, and the apcore-python SDK serves as the primary reference for our cross-language patterns.

1. Automatic Schema Extraction

We leverage Python’s type hinting and libraries like Pydantic to ensure that your code is the documentation.

from apcore import module

@module(
    id="weather.get_forecast",
    description="Get a 5-day weather forecast for a specific city."
)
def get_weather(city: str, units: str = "metric") -> dict:
    """Business logic goes here..."""
    return {"city": city, "forecast": "sunny"}

In this snippet, apcore automatically inspects the function signature to generate a standards-compliant JSON Schema for the city and units parameters. There is no manual JSON writing.

2. The Registry Pattern

The Registry acts as the single source of truth for all available skills. It handles discovery, ACL (Access Control Lists), and execution.


Mirroring the Experience: TypeScript & Rust

To prove the power of synchronization, look at how the exact same logic is implemented in the other SDKs. We use language-native primitives (Decorators in TS, Macros in Rust) to maintain the same developer experience.

The "Mirror Effect"

Feature Python TypeScript Rust
Annotation @module(id="...") @Module({ id: '...' }) #[module(id = "...")]
Validation Pydantic / Type Hints Zod / TypeStack Serde / Strong Typing
Metadata __apcore__ attribute Reflect Metadata Static Compile-time info

TypeScript Example:

@Module({ id: 'weather.get_forecast' })
export class WeatherService {
  getWeather(city: string, units: string = 'metric') { ... }
}

Rust Example:

#[module(id = "weather.get_forecast")]
fn get_weather(city: String, units: Option<String>) -> WeatherResponse { ... }

Even though the syntax changes to feel "idiomatic" to each language, the Identity of the module remains constant across the entire enterprise.


Engineering Rigor: The Conformance Suite

How do we ensure these SDKs stay in sync? We don't rely on hope; we rely on Conformance Testing.

Every apcore SDK must pass a shared suite of integration tests. This ensures that:

  • Schema Generation is identical (e.g., how optional parameters are handled).

  • Execution Pipelines follow the same lifecycle (Submitted -> Working -> Completed).

  • Error Codes are standardized across languages.


Conclusion: Write Once, Perceive Everywhere

By synchronizing the implementation of Python, TypeScript, and Rust, apcore removes the friction of polyglot development. Your engineering teams can use the best tool for the job—be it the agility of Python, the ubiquity of TypeScript, or the safety of Rust—while your AI Agents enjoy a stable, unified view of the world.

Next up: apexe: Transforming 30 Years of CLI into AI Skills


GitHub: apcore-python | apcore-typescript | apcore-rust | Docs: apcore.apstack.org

Comments

Join the discussion via GitHub Discussions.