---
title: "Agent-friendly SDK: the type signature the agent trusts"
description: "An agent-friendly SDK is the exported names, types, and deprecation notes. A guide with other names teaches a second contract."
canonical: "https://www.agentrail.co/blog/agent-friendly-sdk?h=CGA3BXZDPY7YM002"
author: "Harsh Raj"
published: "2026-12-02T04:30:00Z"
last_updated: "2026-12-02T04:19:37.208Z"
---

# Agent-friendly SDK: the type signature the agent trusts

An agent-friendly SDK is the exported names, types, and deprecation notes on the package. The agent imports those symbols. A guide that uses other names teaches a second contract.

An agent-friendly SDK is a package whose exported names, types, and deprecation notes are the contract a coding agent can import. The agent reads those symbols before it trusts a paragraph in a guide. When the guide and the type disagree, the next call follows the type the package actually exports.

Whether a cold agent finishes the install and the first call stays on [Can an agent finish your SDK quickstart?](https://www.agentrail.co/blog/sdk-quickstart-for-ai-agents?h=CGA3BXZDPY7YM010). This page owns the symbols on the package the agent imports.

> **Key Takeaways**
>
> • The agent trusts the exported names and types it can import.
>
> • The string in the type and the string in the docs have to match.
>
> • A deprecated export names the symbol that replaced it.
>
> • An example that fails the type checker still gets copied into the call.
>
> • A journey that never imports the package is a skip, and that record is a different page.

## The agent reads the exports before the prose

The agent reads the exports first. A coding agent that has installed the package can list the public symbols, their parameters, and their return types. That list is the document it can check without rendering your docs site. A README section that describes a method the package does not export will not be the method it calls.

Put the contract on the symbol. A parameter the task requires is required in the type. A parameter the task can omit is optional in the type. A return type names the fields the next line will read. An untyped object, or a map with no fields, forces a guess about the next key. The guess becomes the request.

Defaults are part of that contract. A default the type applies, and the guide never mentions, still goes out on the wire. The agent will not override a value it cannot see. Put the default in the type, and name it in the note on that parameter.

Enums belong in the type. The allowed strings are the members. A prose list that adds a value the type rejects fails when the agent copies the prose. If the set is open, say so on the type.

Docstrings and declaration comments sit on the symbol, so they travel with the import. A comment in a file the agent never opened does not. Keep the sentence that says when to call the method on the method. If the type cannot say when not to call it, put that sentence on the symbol too.

Export the call the task needs. A helper that is public in the guide and private in the type will be imported and then fail. A wrapper whose types only show a constructor hides the method the agent needed. Generated reference pages stay aligned when they are produced from these types. Hand-written pages drift. When they drift, change the type or change the page until the names match.

## Names in types match names in docs

Names match when the identifier in the type is the identifier in the guide, the error, and the body on the wire. One concept gets one string. `customer_id` in the type and `customerId` in the guide are two contracts. The agent will send one of them.

Pick the string the server already accepts, and use it in the type. Then use that same string in the guide, in the sample, and in the error that names the field. A rename that exists only in the guide teaches a call the server rejects. A rename that exists only in the type teaches a call the guide never shows. Either mismatch shows up as a confident request with a parameter you did not mean.

Aliases are a migration tool, not a second public name you leave unmarked. If you must accept both strings for a while, the type should show which one is current. The old string can remain as a deprecated field whose note contains the new name. Two current names for one field give the agent a choice with no rule.

Return fields follow the same rule. If the type lists `id` and `status`, the guide uses those fields. A field that exists only in a screenshot is not a field the agent can rely on. Add it to the type, or stop telling the agent to read it.

Errors that quote a field should quote the type's name for that field. The body of an API error is a separate contract, on [API errors an agent can retry](https://www.agentrail.co/blog/api-error-messages-for-ai-agents?h=CGA3BXZDPY7YM02Y). The field name in that body should be a name the type already taught. A new synonym in the error sends the agent back to the guide.

Before you publish, check parameter names, enum members, return fields, and the guide headings for that method. If a string appears in only one of those places, add it to the type or remove it from the guide.

| Place | The string that must match |
| --- | --- |
| Type parameter | The argument name the agent will pass |
| Serialized field | The key the server accepts on that argument |
| Guide heading | The name the page uses for the same argument |
| Error field | The name a later call is told to replace |

## A deprecated symbol says what replaced it

A deprecated symbol names its replacement on the export the agent imports. The note contains the new name. A changelog entry the agent did not open is not that note. A migration post on the blog is not that note. If the new name is absent from the symbol, the agent keeps calling the old one.

Keep the old symbol importable until you remove it, and put the replacement in the deprecation text. In a typed language, that is the annotation the editor and the language server show on the old name. A runtime warning that only prints to a console the model never reads does not rename the next call. If you emit a warning, repeat the new name in the text attached to the symbol, where the import can surface it.

Write the note as an instruction with an identifier in it. Naming the new function is enough. Saying the method is old is not enough, because the agent still has to choose a symbol. If you know the version that will delete the old export, put that version in the same note. Do not make the agent hunt a separate guide for the identifier it should import instead.

When you delete the symbol, the import fails. The failure should name the replacement in the message the agent reads. That may be a compiler diagnostic or an import error at runtime. The missing name and the new name both belong in that text. An error that only says the module has no such attribute leaves the next import unspecified.

If two exports perform the same write, mark the old one and name the replacement. If they differ by a required field, the parameter lists should show that difference.

## An example that does not typecheck will be copied anyway

An example that does not typecheck will still be copied into the call. Agents paste the block they were shown. If the block calls a symbol you renamed, passes a field the type removed, or points at a host you retired, the request can still contain that block. The surrounding paragraph can be correct and lose anyway.

The comparison between the fetched sample and the failed request stays on [the code sample inside the failing call](https://www.agentrail.co/blog/ai-agent-code-examples?h=CGA3BXZDPY7YM03W). This page owns the check you run before an agent is handed the block.

The example imports a symbol the package exports in the version you are documenting. It passes arguments the current type accepts. It reads fields the return type declares. It does not depend on a private type or a helper you did not export. A snippet that runs only inside your monorepo is not a public example. Agents outside that repo will paste it and then invent the missing import.

Run the example against the published types. A docs build that typechecks its samples catches a rename the prose still teaches. A screenshot will not. A markdown fence that no build typechecks will not either. On one snippet, it typechecks or it does not. Fix the sample or fix the type.

When the agent does hit a type error, the diagnostic should name the correction. Anthropic's 11 September 2025 essay says a validation error should state the correction and include one correct example ([Writing tools for agents](https://www.anthropic.com/engineering/writing-tools-for-agents)). That essay is about tool results. Use the same shape here. Name the symbol to call, and show one call that typechecks against the current package.

Keep one example per public method, on the symbol or compiled beside it. A second example is fine when it is the same call. Two examples that disagree teach two calls. Delete the one that does not typecheck. The short block is the one that gets pasted.

Say which package version the example was checked against. The types the agent reads are the types in the version it installed. A guide that shows a later signature next to an older package produces a call neither version accepts.

## The skip is a different page

A task that never imports the package is a skip, and that path is a different page. If the calls reach your API without the import, the types were not the document that agent used. How that path shows up in a journey stays on [when the journey shows the agent skipping your SDK](https://www.agentrail.co/blog/when-an-agent-skips-the-sdk?h=CGA3BXZDPY7YM04T).

This page still applies once the import has happened. Read the symbol the agent called, the arguments the type allowed, and the deprecation note on that symbol. A wrong argument the type permits is a hole in the type. A wrong argument the type forbids, sent because a sample still shows it, is the example problem above. A request that never imported the package is neither of those, and rewriting types will not explain it.

A typed package is not proof the task finished. Finished means the environment holds the result, and the method for that check stays on the quickstart page. Types can be exact while the install still stops. Types can be wrong while a raw request still completes. Write those down as separate facts.

[Agent experience](https://www.agentrail.co/blog/agent-experience?h=CGA3BXZDPY7YM05R) asks whether the task finished. The type signature is one surface that task can stall on. It is the surface you can correct in the package the agent imports, without maintaining a second set of names in prose.

## Frequently Asked Questions

### Does a long README make an SDK agent-friendly?

No. A long README is a document for a person. An agent-friendly SDK is the exported names, types, and deprecation notes. The README can point at the package. It does not replace the symbols the agent imports.

### What if the guide and the types disagree?

Make the strings match. The agent that imported the package follows the type it can check. A guide that uses a different name teaches a second contract. Change the guide or change the type before you treat the mismatch as a model failure.

### Will a console deprecation warning reach the agent?

Do not count on it. Put the replacement name on the symbol the agent imports, where the language server or the import text can show it. A warning that only reaches a log the model never reads does not change the next call.

### Should every method return a fully typed object?

Type the methods the task calls. Name the fields the next line needs to read. An untyped map forces a guess at the next key. A method no task calls can wait. The public write and the public read cannot.

Match the guide to the exports. Put the replacement name on the deprecated symbol. Typecheck the example before you publish the package. The next agent will import what the package exports, and it will paste the block you left in the guide.

A scan of the public site is a different check from the types inside the package. Use it when you want that read of the pages an agent can fetch: [the agent readiness checker](https://www.agentrail.co/agent-readiness/checker?h=CGA3BXZDPY7YM06P).
