Skip to content

Conversation

@sixlive
Copy link
Contributor

@sixlive sixlive commented Jan 3, 2026

Description

Adds support for tools to produce binary artifacts (images, audio, files) alongside text results. Artifacts flow through the streaming event system and are available to applications without going to the LLM's context window.

Key changes:

  • New Artifact and ToolOutput value objects for returning binary data from tools
  • New ArtifactEvent stream event emitted after tool execution
  • All 9 provider stream handlers updated to yield artifact events
  • DataProtocolAdapter sends artifacts as type: 'artifact' messages
  • BroadcastAdapter emits .artifact WebSocket events
  • Backward compatible: tools returning strings continue to work unchanged

Usage

$tool = Tool::as('generate_image')
    ->for('Generates an image')
    ->withStringParameter('prompt', 'Image description')
    ->using(function (string $prompt): ToolOutput {
        $imageData = $this->imageService->generate($prompt);

        return new ToolOutput(
            result: json_encode(['status' => 'success']),
            artifacts: [
                Artifact::fromRawContent(
                    content: $imageData,
                    mimeType: 'image/png',
                    metadata: ['width' => 1024, 'height' => 1024],
                ),
            ],
        );
    });

@kinsta
Copy link

kinsta bot commented Jan 3, 2026

Preview deployments for prism ⚡️

Status Branch preview Commit preview
✅ Ready Visit preview Visit preview

Commit: e4fd3b775acde9f822304d5e0559a01eb776a665

Deployment ID: 4c314ec6-5f33-4ab7-a6e0-661e1b56f2ae

Static site name: prism-97nz9

@sixlive sixlive merged commit fa7d043 into main Jan 5, 2026
14 checks passed
@sixlive sixlive deleted the artifacts branch January 5, 2026 14:04
@sixlive sixlive changed the title Add artifacts and artifact handling feat: tool artifacts Jan 5, 2026
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.

2 participants