Skip to content

[Agent Builder] attachments by ref#248937

Merged
ppisljar merged 24 commits intoelastic:mainfrom
ppisljar:agentbuilder/attachments_by_ref
Feb 3, 2026
Merged

[Agent Builder] attachments by ref#248937
ppisljar merged 24 commits intoelastic:mainfrom
ppisljar:agentbuilder/attachments_by_ref

Conversation

@ppisljar
Copy link
Copy Markdown
Contributor

@ppisljar ppisljar added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v9.4.0 labels Jan 14, 2026
@leemthompo leemthompo added the feature:agent-builder Identify agent builder functionalities to be grouped together for release notes label Jan 14, 2026
@ppisljar ppisljar force-pushed the agentbuilder/attachments_by_ref branch 5 times, most recently from 5995444 to 6018eb4 Compare January 21, 2026 08:03
@ppisljar ppisljar force-pushed the agentbuilder/attachments_by_ref branch from 6018eb4 to 7b9d891 Compare January 21, 2026 08:08
@ppisljar ppisljar marked this pull request as ready for review January 22, 2026 14:50
@ppisljar ppisljar requested a review from a team as a code owner January 22, 2026 14:50
Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-approved, but added two questions

Comment on lines +38 to +41
export type VisualizationRefAttachment = Attachment<
AttachmentType.visualizationRef,
VisualizationRefAttachmentData
>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: You shouldn't need that second generic parameter, given you added an entry in AttachmentDataMap (see AttachmentDataOf)

Comment on lines +90 to +96
/**
* Saved objects client scoped to the current user.
*
* Optional for now to avoid forcing all runner implementations to provide it,
* but recommended for tools that need to access saved objects (e.g. by-reference attachments).
*/
savedObjectsClient?: SavedObjectsClientContract;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to make that optional exactly? From the diff it's unclear to me, and I would really prefer being consistent if possible, this is fairly "dangerous" / error prone for devs.

Comment on lines +67 to +82
let resolved: unknown;
const definition = getTypeDefinition?.(attachment.type);
if (definition?.resolve && context) {
resolved = await definition.resolve(
{
id: attachmentId,
type: attachment.type,
data: versionData.data,
},
{
request: context.request,
spaceId: context.spaceId,
savedObjectsClient: context.savedObjectsClient,
}
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to move that logic one layer down, in the attachmentManager ( maybe a resolve function in addition to the existing get). I assume it means moving a bunch of stuff in it (we need the request and the SO client/contract and maybe other stuff), but it would feel better in terms of isolation of concerns.

If that's not possible, I would try to at least isolate/extract that "resolving" logic in an helper function.

Asking because in the scope of #250043, I'm going to have to "replicate" the behavior from attachment tools in the FS store, and because an entry in the store should have a single "representation", so I will need to retrieve and store that "representation" for each attachment so that it's the file content in the store.

Copy link
Copy Markdown
Contributor Author

@ppisljar ppisljar Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried to put this inside attachmentManager. i also renamed some methods and changed the interface a bit, hopefully making it less likely for consumers to mess this up (forget resolving or sth).

Comment on lines +84 to +102
const formatVisualizationRefAttachment = (data: VisualizationRefAttachmentData): string => {
const parts: string[] = [];

parts.push(`[Visualization Reference]`);
parts.push(`Type: lens`);
parts.push(`ID: ${data.saved_object_id}`);

if (data.title) {
parts.push(`Title: ${data.title}`);
}

if (data.description) {
parts.push(`Description: ${data.description}`);
}

parts.push(`\nNote: resolve this reference using attachment_read.`);

return parts.join('\n');
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: following our discussion today, do we want that, or shall we just return the JSON of the ref attachment instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replacing this with format() getRepresentation()

@ppisljar ppisljar requested a review from a team as a code owner January 28, 2026 05:36
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
agentBuilder 554.5KB 554.6KB +151.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
agentBuilderPlatform 57.0KB 57.1KB +112.0B
Unknown metric groups

API count

id before after diff
@kbn/agent-builder-server 214 216 +2

History

@ppisljar ppisljar merged commit 1b4429e into elastic:main Feb 3, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting feature:agent-builder Identify agent builder functionalities to be grouped together for release notes release_note:skip Skip the PR/issue when compiling release notes v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants