Context
Integrating existing APIs that weren't designed for agents.
Problem
Legacy APIs have poor descriptions, complex auth, or unfriendly responses.
Solution
Build adapters that:
- Wrap: Hide legacy complexity
- Document: Add LLM-friendly descriptions
- Transform: Shape responses appropriately
- Handle auth: Manage credentials
- Wrap: Hide legacy complexity
- Document: Add LLM-friendly descriptions
- Transform: Shape responses appropriately
- Handle auth: Manage credentials
Examples
Python
# Legacy API: Poor documentation, nested response
class LegacyUserAPI:
def GetUserByID(self, uid, include_all=False):
# Returns deeply nested, poorly documented response
pass
# Adapter: Agent-friendly wrapper
@tool
def get_user(user_id: str) -> UserProfile:
"""Get user profile by ID.
Returns a clean UserProfile with name, email, role.
Call search_users() first if you only have a name.
"""
legacy = LegacyUserAPI()
raw = legacy.GetUserByID(user_id, include_all=True)
return UserProfile(
id=raw["data"]["user"]["uid"],
name=raw["data"]["user"]["profile"]["displayName"],
email=raw["data"]["user"]["contact"]["primaryEmail"],
role=raw["data"]["user"]["access"]["role"]
) Considerations
- Focus on the 80% use case, not all features
- Add comprehensive documentation
- Shape responses for token efficiency