[Agent Builder] Add attachment origin to Converse API#259043
[Agent Builder] Add attachment origin to Converse API#259043machadoum merged 5 commits intoelastic:mainfrom
Conversation
5988cc9 to
8f93465
Compare
9170a03 to
acb0b94
Compare
* Unify AttachInput and VersionedAttachmentInput types
acb0b94 to
ad4aedd
Compare
1cd21ad to
8e351a9
Compare
⏳ Build in-progress, with failures
Failed CI Stepscc @machadoum |
pgayvallet
left a comment
There was a problem hiding this comment.
Looking good to me. a few nits and one question (last comment)
| export const getContentKey = (input: AttachmentInput, fallback: string): string => { | ||
| if (input.data !== undefined) { | ||
| return `${input.type}:${hashContent(input.data)}`; | ||
| } | ||
| if (input.origin !== undefined) { | ||
| return `${input.type}:origin:${input.origin}`; | ||
| } | ||
| return `${input.type}:${fallback}`; | ||
| }; |
There was a problem hiding this comment.
hashContent is potentially resource intensive for large attachment contents. Wherever we use getContentKey in the ui, we should make sure that everything is properly memo-ed to avoid calling those on each render cycles (I didn't check all usages so probably it's a non issue but still wanted to mention it)
There was a problem hiding this comment.
It is only used in one place in the UI inside a onMutate action. So it shouldn't execute when a components re-renders. It is also not a new logic, I introduce the origin content key and extracted to a function because we also need it in the server side. Here is where it was previously called https://github.com/elastic/kibana/pull/259043/changes#diff-e7fef969144ffae71dcca4f5afb88766fd631aedf8e0dd5944d85c1b68fd5211L105-L106
x-pack/platform/plugins/shared/agent_builder/common/http_api/chat.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/agent_builder/server/routes/chat.ts
Outdated
Show resolved
Hide resolved
| const resolveContext: AttachmentResolveContext | undefined = | ||
| context.savedObjectsClient !== undefined | ||
| ? { | ||
| request: context.request, | ||
| spaceId: context.spaceId, | ||
| savedObjectsClient: context.savedObjectsClient, | ||
| } | ||
| : undefined; |
There was a problem hiding this comment.
Out of scope of the current PR, but AgentHandlerContext.savedObjectsClient being optional seems like a code smell, and I don't like it forcing that kind of conditional logic / optional parameters.
I think I gonna have to open a tech debt PR about that - https://github.com/elastic/search-team/issues/13625
x-pack/platform/plugins/shared/agent_builder/server/services/execution/execution_service.ts
Outdated
Show resolved
Hide resolved
| @@ -17,31 +20,66 @@ export type ValidateAttachmentResult<Type extends string, Data> = | |||
| export const validateAttachment = async <Type extends string, Data>({ | |||
There was a problem hiding this comment.
nit: this does more than validate
Closes elastic/search-team#13477 ## Summary Agent Builder **Converse** (and related client surfaces) now accept attachments with optional **`data`**, optional **`origin`**, or **both**—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends only `origin`. **Types:** **`AttachInput` and `VersionedAttachmentInput` are merged** into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser. ## Architecture - **Contract:** one versioned attachment input type end-to-end; each attachment must include **at least one** of `data` or `origin`. - **Server:** converse (and step) validation resolves **`origin`** when `data` is omitted, using request-scoped context where types implement `resolve`; validated payloads become full **`Attachment`** objects before execution and conversation merge. - **Client:** optimistic UI and display paths tolerate **`origin`-only** pending rows using stable keys. **Breaking changes:** none—this extends accepted shapes. ### How to test Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither `data` nor `origin` is present. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Release notes Converse accepts optional **`origin`** on attachments for by-reference flows; rejects attachments with neither **`data`** nor **`origin`**. Attachment input types are unified so HTTP and UI use the same shape. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…hanges * commit 'd0e62a657916e84694a93983e513ce9e34e0b635': (27 commits) [Agent Builder] Agent overview page design updates (elastic#260468) [Inference UI] Add model detail flyout with endpoint management (elastic#260307) [Fleet] Update doc links in agent policy settings (elastic#260245) [Security Solution] show risk score in new flyout header (elastic#260187) Replace deprecated EUI icons in files owned by @elastic/kibana-security (elastic#255636) [Cases][Templates] Add DATE_PICKER field control type (elastic#260209) [SharedUX] Get spaces callout on each solution nav (elastic#259723) [SharedUX] Preserve feature visibility on solution change (elastic#259316) [CI] Increase investigations cypress disks to 110G (elastic#260423) [Agent Builder] Expose read-only conversations on plugin start contract (elastic#260435) [dasboards as code] drop panels with server errors (elastic#260073) [One Workflow] Add force-delete (hard delete) option for workflows (elastic#260391) [Agent Builder] Fix sidebar error handling error (elastic#260446) [Agent Builder] Add attachment origin to Converse API (elastic#259043) [Alerting v2] Fix rule results preview chart responsiveness (elastic#260444) [Streams] Processing error panel UI improvements (elastic#260028) fix flaky test: alert details error page timeout (elastic#260302) [Agent Builder] Add attachment origin to Converse API (elastic#259043) [One Workflow] Add more unit tests to workflows_extensions plugin (elastic#260384) [ResponseOps] Split alerting security_and_spaces group8 FTR config to fix CI timeout (elastic#260029) ...
Closes elastic/search-team#13477 ## Summary Agent Builder **Converse** (and related client surfaces) now accept attachments with optional **`data`**, optional **`origin`**, or **both**—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends only `origin`. **Types:** **`AttachInput` and `VersionedAttachmentInput` are merged** into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser. ## Architecture - **Contract:** one versioned attachment input type end-to-end; each attachment must include **at least one** of `data` or `origin`. - **Server:** converse (and step) validation resolves **`origin`** when `data` is omitted, using request-scoped context where types implement `resolve`; validated payloads become full **`Attachment`** objects before execution and conversation merge. - **Client:** optimistic UI and display paths tolerate **`origin`-only** pending rows using stable keys. **Breaking changes:** none—this extends accepted shapes. ### How to test Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither `data` nor `origin` is present. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Release notes Converse accepts optional **`origin`** on attachments for by-reference flows; rejects attachments with neither **`data`** nor **`origin`**. Attachment input types are unified so HTTP and UI use the same shape. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes elastic/search-team#13477 ## Summary Agent Builder **Converse** (and related client surfaces) now accept attachments with optional **`data`**, optional **`origin`**, or **both**—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends only `origin`. **Types:** **`AttachInput` and `VersionedAttachmentInput` are merged** into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser. ## Architecture - **Contract:** one versioned attachment input type end-to-end; each attachment must include **at least one** of `data` or `origin`. - **Server:** converse (and step) validation resolves **`origin`** when `data` is omitted, using request-scoped context where types implement `resolve`; validated payloads become full **`Attachment`** objects before execution and conversation merge. - **Client:** optimistic UI and display paths tolerate **`origin`-only** pending rows using stable keys. **Breaking changes:** none—this extends accepted shapes. ### How to test Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither `data` nor `origin` is present. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Release notes Converse accepts optional **`origin`** on attachments for by-reference flows; rejects attachments with neither **`data`** nor **`origin`**. Attachment input types are unified so HTTP and UI use the same shape. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes elastic/search-team#13477 ## Summary Agent Builder **Converse** (and related client surfaces) now accept attachments with optional **`data`**, optional **`origin`**, or **both**—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends only `origin`. **Types:** **`AttachInput` and `VersionedAttachmentInput` are merged** into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser. ## Architecture - **Contract:** one versioned attachment input type end-to-end; each attachment must include **at least one** of `data` or `origin`. - **Server:** converse (and step) validation resolves **`origin`** when `data` is omitted, using request-scoped context where types implement `resolve`; validated payloads become full **`Attachment`** objects before execution and conversation merge. - **Client:** optimistic UI and display paths tolerate **`origin`-only** pending rows using stable keys. **Breaking changes:** none—this extends accepted shapes. ### How to test Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither `data` nor `origin` is present. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Release notes Converse accepts optional **`origin`** on attachments for by-reference flows; rejects attachments with neither **`data`** nor **`origin`**. Attachment input types are unified so HTTP and UI use the same shape. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes elastic/search-team#13477 ## Summary Agent Builder **Converse** (and related client surfaces) now accept attachments with optional **`data`**, optional **`origin`**, or **both**—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends only `origin`. **Types:** **`AttachInput` and `VersionedAttachmentInput` are merged** into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser. ## Architecture - **Contract:** one versioned attachment input type end-to-end; each attachment must include **at least one** of `data` or `origin`. - **Server:** converse (and step) validation resolves **`origin`** when `data` is omitted, using request-scoped context where types implement `resolve`; validated payloads become full **`Attachment`** objects before execution and conversation merge. - **Client:** optimistic UI and display paths tolerate **`origin`-only** pending rows using stable keys. **Breaking changes:** none—this extends accepted shapes. ### How to test Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither `data` nor `origin` is present. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Release notes Converse accepts optional **`origin`** on attachments for by-reference flows; rejects attachments with neither **`data`** nor **`origin`**. Attachment input types are unified so HTTP and UI use the same shape. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes elastic/search-team#13477 ## Summary Agent Builder **Converse** (and related client surfaces) now accept attachments with optional **`data`**, optional **`origin`**, or **both**—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends only `origin`. **Types:** **`AttachInput` and `VersionedAttachmentInput` are merged** into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser. ## Architecture - **Contract:** one versioned attachment input type end-to-end; each attachment must include **at least one** of `data` or `origin`. - **Server:** converse (and step) validation resolves **`origin`** when `data` is omitted, using request-scoped context where types implement `resolve`; validated payloads become full **`Attachment`** objects before execution and conversation merge. - **Client:** optimistic UI and display paths tolerate **`origin`-only** pending rows using stable keys. **Breaking changes:** none—this extends accepted shapes. ### How to test Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither `data` nor `origin` is present. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Release notes Converse accepts optional **`origin`** on attachments for by-reference flows; rejects attachments with neither **`data`** nor **`origin`**. Attachment input types are unified so HTTP and UI use the same shape. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes https://github.com/elastic/search-team/issues/13477
Summary
Agent Builder Converse (and related client surfaces) now accept attachments with optional
data, optionalorigin, or both—so by-reference payloads match conversation APIs and are no longer rejected when the UI sends onlyorigin.Types:
AttachInputandVersionedAttachmentInputare merged into a single attachment-input shape used consistently across HTTP, plugin APIs, and the browser.Architecture
dataororigin.originwhendatais omitted, using request-scoped context where types implementresolve; validated payloads become fullAttachmentobjects before execution and conversation merge.origin-only pending rows using stable keys.Breaking changes: none—this extends accepted shapes.
How to test
Exercise Converse (sync/async) and in-product attachment flows with by-value, by-reference, and combined payloads; confirm errors when neither
datanororiginis present.Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*labels.Release notes
Converse accepts optional
originon attachments for by-reference flows; rejects attachments with neitherdatanororigin. Attachment input types are unified so HTTP and UI use the same shape.