Skip to content

Improve agent types#287

Merged
threepointone merged 3 commits intocloudflare:mainfrom
ruifigueira:improve-agent-types
May 14, 2025
Merged

Improve agent types#287
threepointone merged 3 commits intocloudflare:mainfrom
ruifigueira:improve-agent-types

Conversation

@ruifigueira
Copy link
Copy Markdown
Contributor

@ruifigueira ruifigueira commented May 14, 2025

I think this is the final version! Even if the previous version was passing the tests, I was not happy with those types because I couldn't understand why they were not behaving the way I expected them to.

For instance, Methods<T> should return a object type with only Method values, something similar to Record<string, Method> but if I tried to use Parameters<Method<T>[K]> it would fail, which was odd.

It turns out I was missing a condition in the Method<T> value, even if its keys were already using the same condition.

After fixing that one and OptionalAgentMethods, which had the same problem, I was able to simplify the remaining types, like AgentStub<T> which no longer needs to be a type AgentStub<T extends AgentMethods<T>>.

ruifigueira and others added 3 commits May 14, 2025 14:09
For instance, Methods<T> not enforcing values to be a Method was causing problems on other types.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented May 14, 2025

🦋 Changeset detected

Latest commit: 409dcad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agents Patch
hono-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@threepointone threepointone merged commit 94d9a2e into cloudflare:main May 14, 2025
1 check passed
@threepointone threepointone mentioned this pull request May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants