name: add-sdk-method description: Use when adding a new method, function, or API endpoint to the SDK. Ensures consistent implementation across all SDKs (Python, TypeScript, Java, Rust CLI) with proper types, tests, and naming conventions.
Add SDK Method
Adds a new method to all SDKs (Python, TypeScript, Java, Rust CLI) with consistent implementation.
Usage
/add-sdk-method <method-name> <description>
Checklist
Understand the Method
- Clarify the method signature (parameters, return type)
- Clarify the HTTP endpoint it calls (GET/POST/etc, path, body)
- Clarify error handling requirements
Python SDK (
python/src/ai_sdk/)- Add method to appropriate class (likely
AgentHandlein_client.py) - Add type hints using Pydantic models
- Add async version if sync version exists (or vice versa)
- Add unit test in
python/tests/
- Add method to appropriate class (likely
TypeScript SDK (
typescript/src/)- Add method to
AgentHandleclass inagent.ts - Add TypeScript interfaces to
models.tsif needed - Add unit test in
typescript/tests/
- Add method to
Java SDK (
java/src/main/java/io/metadata/ai/)- Add method to
AgentHandle.java - Add model classes in
models/if needed - Add unit test in
java/src/test/
- Add method to
Rust CLI (
cli/src/)- Add subcommand or option to handle the new functionality
- Update
main.rsor relevant module - Add unit test
Verify
- Run
make lint- all linters pass - Run
make test-all- all unit tests pass - Update CHANGELOG if exists
- Run
Patterns to Follow
Python
async def new_method(self, param: str) -> ResponseModel:
"""Short description.
Args:
param: Description of param
Returns:
ResponseModel with the result
"""
response = await self._client._request("POST", f"/path/{param}")
return ResponseModel.model_validate(response)
TypeScript
async newMethod(param: string): Promise<ResponseModel> {
const response = await this.client.request('POST', `/path/${param}`);
return response as ResponseModel;
}
Java
public ResponseModel newMethod(String param) throws AISdkException {
return httpClient.post("/path/" + param, ResponseModel.class);
}
DO NOT
- Add method to only some SDKs (all must be updated)
- Skip tests
- Use different naming conventions across SDKs (camelCase in TS/Java, snake_case in Python/Rust)
- Add dependencies without justification