Skip to content
Open
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
33 changes: 32 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,35 @@ jobs:

- name: Run tests
working-directory: typescript-sdk
run: pnpm run test
run: pnpm run test

go:
name: Go SDK Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.4'

- name: Setup Go module cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Download dependencies
working-directory: sdks/community/go
run: go mod download

- name: Run tests
working-directory: sdks/community/go
run: go test ./... -v
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.vscode/
.idea/

.DS_Store
**/.DS_Store
135 changes: 135 additions & 0 deletions docs/sdk/go/client/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: "Overview"
description: "Client package overview for Go SDK"
---

# Client Package

The AG-UI Go SDK client package provides Server-Sent Events (SSE) connectivity for real-time event streaming from AG-UI agents. This package enables Go applications to connect to agent endpoints and receive streaming responses.

## Package Import

```go
import "github.com/ag-ui-protocol/ag-ui/sdks/community/go/pkg/client/sse"
```

## SSE Client Introduction

The SSE (Server-Sent Events) client provides a robust connection mechanism for streaming events from AG-UI agents. SSE is a standard protocol for server-to-client streaming over HTTP, making it ideal for real-time agent interactions where the agent needs to send continuous updates about its processing state, thoughts, and outputs.

Key features:
- Real-time event streaming from agents
- Automatic connection management
- Context-based cancellation support
- Configurable timeouts and buffer sizes
- Built-in authentication support

## Configuration

The client is highly configurable to adapt to different deployment scenarios:

```go
client := sse.NewClient(sse.Config{
Endpoint: "https://api.example.com/agent",
APIKey: "your-api-key",
ConnectTimeout: 30 * time.Second,
ReadTimeout: 5 * time.Minute,
BufferSize: 100,
})

// Start streaming with context and payload
frames, errors, err := client.Stream(sse.StreamOptions{
Context: context.Background(),
Payload: map[string]interface{}{
"threadId": "thread_123",
"messages": []interface{}{
map[string]string{
"role": "user",
"content": "Hello, agent!",
},
},
},
})
```

## Quick Example

Here's a complete example showing how to connect to an agent and process events:

```go
package main

import (
"context"
"fmt"
"log"

"github.com/ag-ui-protocol/ag-ui/sdks/community/go/pkg/client/sse"
"github.com/ag-ui-protocol/ag-ui/sdks/community/go/pkg/core/events"
)

func main() {
// Create SSE client
client := sse.NewClient(sse.Config{
Endpoint: "https://api.example.com/agent",
APIKey: "your-api-key",
})

// Start streaming
ctx := context.Background()
frames, errors, err := client.Stream(sse.StreamOptions{
Context: ctx,
Payload: map[string]interface{}{
"threadId": "thread_123",
"messages": []interface{}{
map[string]string{
"role": "user",
"content": "What is the weather today?",
},
},
},
})

if err != nil {
log.Fatal("Failed to start stream:", err)
}

// Process events
decoder := events.NewEventDecoder()
for {
select {
case frame := <-frames:
event, err := decoder.Decode(frame.Data)
if err != nil {
log.Printf("Decode error: %v", err)
continue
}

// Handle different event types
switch e := event.(type) {
case *events.TextMessageContentEvent:
fmt.Print(e.Delta)
case *events.RunFinishedEvent:
fmt.Println("\nAgent finished processing")
return
}

case err := <-errors:
log.Printf("Stream error: %v", err)
return
}
}
}
```

## Navigation

<Card
title="SSE Client Reference"
icon="cube"
href="/sdk/go/client/sse-client"
color="#3B82F6"
iconType="solid"
>
Detailed documentation for the Server-Sent Events client including configuration, streaming, and error handling
</Card>
Loading