Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ describe('attachment_presentation', () => {
expect(prompt).toBe('');
});

it('should return inline mode instructions', () => {
it('should return inline mode instructions with attachment_read guidance', () => {
const attachments = [createMockAttachment('1', 'text', 'Content')];
const presentation = prepareAttachmentPresentation(attachments);
const prompt = getAttachmentSystemPrompt(presentation);

expect(prompt).toContain('1 attachment');
expect(prompt).toContain('shown inline');
expect(prompt).toContain('attachment_read');
expect(prompt).toContain('content truncated');
expect(prompt).not.toContain('MUST use attachment tools');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,14 @@ export const getAttachmentSystemPrompt = (presentation: AttachmentPresentation):
if (presentation.mode === 'inline') {
return `## Conversation Attachments

The user has ${presentation.activeCount} attachment(s) in this conversation. The full content is shown above in XML format.
The user has ${presentation.activeCount} attachment(s) in this conversation. The content is shown above in XML format.

You can:
- Read attachments using attachment_read(id) to get full content if truncated
- Update attachments using attachment_update(id, data) to modify content
- Add new attachments using attachment_add(type, data) to store information

Since the content is shown inline, you don't need to read it - just reference it directly.`;
If you see "[content truncated, use attachment_read for full content]", you MUST call attachment_read(id) to get the complete content before analyzing or referencing that attachment.`;
}

return `## Conversation Attachments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import type { AttachmentTypeDefinition } from '@kbn/agent-builder-server/attachm
import { OBSERVABILITY_AI_INSIGHT_ATTACHMENT_TYPE_ID } from '../../common';

const aiInsightAttachmentDataSchema = z.object({
context: z.string(),
summary: z.string(),
context: z.string(),
Comment on lines -15 to +16

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.

i'm old enough to remember when key order in objects were not guaranteed. These days it's probably not a problem in modern browsers - but it still feels fragile.

That being said, it would be cleaner, and less noisy for the LLM if we did not have to stringify { summary context, } but avoid the outer object and send this string to the LLM:

Summary:
${summary}

Comtext:
${context}

I believe that would yield better results. If that's impossible, or very hard, so be it. But would be better imo.

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.

We can send the data as a string but we'll have to remove the custom attachment label and use the default one (Summary). Is that okay?
(Or I have to send the content and attachment label as a string and parse the string to extract it)

@sorenlouv sorenlouv Jan 21, 2026

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.

Let's merge this PR as-is and then discuss this separately

attachmentLabel: z.string().optional(),
});

Expand Down Expand Up @@ -59,7 +59,7 @@ export const createAiInsightAttachmentType = (): AttachmentTypeDefinition => {
},
getAgentDescription: () => {
return dedent(`
The AI Insight attachment carries a concise natural-language summary (aiSummary) and contextual data (contextData) relevant to observability investigations.
The AI Insight attachment carries a concise natural-language summary and contextual data relevant to observability investigations.
`);
},
};
Expand Down
Loading