-
Notifications
You must be signed in to change notification settings - Fork 100
feat: add agents and agent runs [PIC-828] #2852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
whitelisab
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great, just a few small comments for you to review
| */ | ||
| generateWithAgent(agentId: string, payload: AgentGeneratePayload) { | ||
| const raw = this.toPlainObject() as EnvironmentProps | ||
| return makeRequest({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, it looks like you are returning the raw response; is this intentional or did you want to wrap the response like the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thanks for the nudge here 👍 I've now clarified the return type here and updated it to be a wrapped agent run.
| import type { DefaultElements, Link, MakeRequest, MetaSysProps } from '../common-types' | ||
| import { wrapCollection } from '../common-utils' | ||
|
|
||
| export type AgentRunStatus = 'IN_PROGRESS' | 'FAILED' | 'COMPLETED' | 'PENDING_REVIEW' | 'DRAFT' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe consider making this an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it's best to avoid using enums in TypeScript, other options tend to be safer and easier to maintain.
ivo-toby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work, very nice! I've added some small comments
| } | ||
| } | ||
|
|
||
| export type AgentRunProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] I'm bit confused about the naming, this is a response-type, maybe call it AgentRunResponse instead of a Prop, as that is commonly associated with input types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fair point, I had a question mark on this too - but as far as I can see this is the convention used elsewhere (e.g. AI Actions, Vectorization Status, Semantic Duplicates, Scheduled Actions etc). @whitelisab would you be able to let us know if I've understood that correctly - is this the right convention for return types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! It is the convention that this should be called AgentRunProps as these types define the data structure of an entity, regardless of whether it's used for input or output. This pattern is used consistently across entity types in the SDK, so let's stick with the established convention on this one
… agent runs endpoints
Summary
This PR adds support for the new agent and agent run endpoints. Agents provide generative capabilities with optional access to tools and workflows, and agent runs store conversation history between a user and an agent.
Description
The agent endpoints provide the following functionalities:
get: Get a single agent's details via it'sidgetMany: Get a collection of agent details.generate: Use a single agent to generate an output via it'sid.The agent run endpoints provide the following functionalities:
get: Get a single agent run's details via it'sidgetMany: Get a collection of agent run details.Motivation and Context
We want to provide access to agents and agent runs to Contentful apps, and therefore we are adding support here as well as in the Apps SDK.
PR Checklist
CONTRIBUTING.mdfile