Skip to content

Conversation

@elliotmassen
Copy link
Member

@elliotmassen elliotmassen commented Dec 16, 2025

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's id
  • getMany: Get a collection of agent details.
  • generate: Use a single agent to generate an output via it's id.

The agent run endpoints provide the following functionalities:

  • get: Get a single agent run's details via it's id
  • getMany: 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

  • I have read the CONTRIBUTING.md file
  • All commits follow conventional commits
  • Documentation is updated (if necessary)
  • PR doesn't contain any sensitive information
  • There are no breaking changes

@elliotmassen elliotmassen requested a review from a team as a code owner December 16, 2025 13:56
@elliotmassen elliotmassen marked this pull request as draft December 16, 2025 13:56
@elliotmassen elliotmassen changed the title feat: add agents and agent runs [PIC-828 feat: add agents and agent runs [PIC-828] Dec 16, 2025
@elliotmassen elliotmassen self-assigned this Dec 16, 2025
@elliotmassen elliotmassen marked this pull request as ready for review December 17, 2025 14:32
Copy link
Contributor

@whitelisab whitelisab left a 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({
Copy link
Contributor

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?

Copy link
Member Author

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'
Copy link
Contributor

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?

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.

Copy link

@ivo-toby ivo-toby left a 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 = {

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

Copy link
Member Author

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?

Copy link
Contributor

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

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.

4 participants