Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How AI agents are changing the way we should bu...

How AI agents are changing the way we should build APIs

How AI agents are changing the way we should build APIs

Avatar for Fabien Potencier

Fabien Potencier

September 19, 2025
Tweet

More Decks by Fabien Potencier

Other Decks in Technology

Transcript

  1. What is an AI Agent? "AI agents are models using

    tools in a loop" Anthropic "AI agents are autonomous software tools that perform tasks, make decisions, and interact with their environment intelligently and rationally" Github "AI agents are software systems that use AI to pursue goals and complete tasks on behalf of users. They show reasoning, planning, and memory and have a level of autonomy to make decisions, learn, and adapt" Google "An AI agent is a software program that can interact with its environment, collect data, and use that data to perform self-directed tasks that meet predetermined goals. Humans set goals" AWS
  2. Who can consume your app? Website Only for humans CLI

    tool Only for developers API Only for machines (but driven by developers) Semi-private (decoupled frontend) or public
  3. Agents interact with them all! Website LLMs learn by scraping

    - training :( or live search CLI tool MCP servers can act by running CLI commands API LLM tools are mostly wrappers on top of APIs LLMs can write code that calls APIs
  4. From humans (websites) ...to machines (API) ...to AI agents (???)

    Do AI agents have different expectations for your API?
  5. APIs are optimized for machines... • Deterministic • Structured output

    • HTTP status for errors • Strict inputs ... but machines need a human in the loop to write the code and when something goes wrong AI agents are autonomous
  6. AI agents need guidance Thought: I need to get all

    Upsun projects via their API. I'm going to use GET /projects Action: Call GET /projects Observation: Something went wrong as the API returns 400 Bad request. Thought: I get a 400 Bad request but with no details. I'm not sure why it does not work. Let me check the API documentation. Action: Use the web browser tool to read the latest version of the documentation. Observation: I see that the endpoint is deprecated and that I should call /organizations/{id}/projects now. ...
  7. Problem Details for HTTP APIs Error Handling - RFC7807 https://api.platform.sh/projects

    { "detail" : "Bad Request.", "status" : 400, "title" : "Deprecated endpoint. See https://docs.upsun.com/api/", "type" : "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1" }
  8. Problem Details for HTTP APIs Error Handling - RFC7807 https://api.platform.sh/projects

    { "detail" : "Bad Request.", "status" : 400, "title" : "Deprecated endpoint. See https://docs.upsun.com/api/", "type" : "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1" } [ self::TYPE => $error[self::TYPE] ?? $context[self::TYPE] ?? 'https://tools.ietf.org/html/rfc2616#section-10', self::TITLE => $error[self::TITLE] ?? $context[self::TITLE] ?? 'An error occurred', self::STATUS => $context[self::STATUS] ?? $object->getStatusCode(), 'detail' => $error['detail'] ?? ($debug ? $object->getMessage() : $object->getStatusText()), ]
  9. Error Messages Wrong date format for 'date' Quantity too high

    vs Use the date format YYYY-MM-DD for 'date' Field 'quantity' must be between 1 and 100 Tell AI agents what to do rather than what's wrong
  10. Thought: I need to get all Upsun projects via their

    API. I'm going to use GET /projects Action: Call GET /projects Observation: Something went wrong as the API returns 400 Bad request; I see that the endpoint is deprecated and that there is a new /organizations/{id}/ projects endpoint. Thought: I get a 400 Bad request but with no details. I'm not sure why it does not work. Let me check the API documentation. Action: Use the web browser tool to read the latest version of the documentation. Observation: I see that the endpoint is deprecated and that I should call / organizations/{id}/projects now. Faster, cost effective, less context rot Less round-trips
  11. Naming things is hard Being consistent is easier https://github.com/symfony/symfony/pull/61743 /repos/{owner}/{repo}/pulls/{pull_number}

    https://github.com/symfony/symfony/issues/61741 /repos/{owner}/{repo}/issues/{issue_number} user_id vs UserId author_id vs user_id Same or different? Use consistent patterns: APIs should be predictable
  12. llms.txt / Markdown version of all doc pages (.md) Plain

    text means less tokens LLMs can parse and understand Markdown hierarchy Copy/paste directly into an LLM context Clear, complete, and up-to-date docs make AI agent succeed more often Document every API endpoint Concise description Flag required/optional inputs Document responses Document all errors, the conditions that trigger them and explain how to fix Inline examples Describe flows Documentation Write unambiguous, comprehensive, and centralized documentation Remove obsolete information, update blog posts, articles, forums, ... Quick-start guides for multi-step flows Avoid misleading agents Avoid frustrating agents Avoid guessing OpenAPI
  13. AI agents are slow Thought: I need to get all

    Upsun projects via their API. I'm going to use GET /projects Action: Call GET /projects Observation: Something went wrong as the API returns 400 Bad request. Thought: I get a 400 Bad request but with no details. I'm not sure why it does not work. Let me check the API documentation. Action: Use the web browser tool to read the latest version of the documentation. Observation: I see that the endpoint is deprecated and that I should call /organizations/{id}/projects now. ... SLOW FAST SLOW SLOW SLOW Can be avoided SLOW
  14. Testing Testing your API with unit tests Testing your UI

    with Playwright or similar How do you test regression for AI agents?
  15. Log everything Segregate agent actions from human/machine actions in your

    logs to be able to track what they do, when, and why.
  16. AI agents are expensive Thought: I need to get all

    Upsun projects via their API. I'm going to use GET /projects Action: Call GET /projects Observation: Something went wrong as the API returns 400 Bad request. Thought: I get a 400 Bad request but with no details. I'm not sure why it does not work. Let me check the API documentation. Action: Use the web browser tool to read the latest version of the documentation. Observation: I see that the endpoint is deprecated and that I should call /organizations/{id}/projects now. ... Can be avoided EXPENSIVE CHEAP EXPENSIVE EXPENSIVE EXPENSIVE EXPENSIVE