golato

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT

README

Golato logo
made by my sister

[!WARNING] Golato is still being churned. The recipe is in progress, and nothing is promised yet.

golato

golato is a small, embeddable Agent Core for Go.

Use its provider layer for direct chat streaming, or its Agent runtime for tool-using workflows. The host application keeps ownership of persistence, tenancy, retrieval, and product policy.

Why golato?

See the project description.

Install

go get github.com/yongtenglei/golato/agent@v0.1.0

Chat stream

apiKey := os.Getenv("OPENAI_API_KEY")
if apiKey == "" {
    return errors.New("OPENAI_API_KEY is required")
}
model := os.Getenv("OPENAI_MODEL")
if model == "" {
    return errors.New("OPENAI_MODEL is required")
}

client, err := openai.New(openai.Config{
    APIKey:   apiKey,
    BaseURL:  os.Getenv("OPENAI_BASE_URL"),
    Provider: "openai",
})
if err != nil {
    return err
}

stream, err := client.Stream(ctx, provider.Request{
    Model: model,
    Messages: []message.Message{
        message.NewUserMessage("What can you help me with?"),
    },
})
if err != nil {
    return err
}

var final message.AssistantMessage
for event := range stream.Events() {
    switch event := event.(type) {
    case provider.TextDeltaEvent:
        fmt.Fprint(os.Stderr, event.Delta)
    case provider.DoneEvent:
        final = event.Message
    case provider.ErrorEvent:
        return event.Err
    }
}
fmt.Fprintln(os.Stderr)
fmt.Println(final.Text())

Streamed deltas are provisional. provider.DoneEvent.Message is the authoritative complete response.

Agent

An Agent is immutable and can run concurrently. It adds an execution lifecycle and a tool loop on top of a Generator. Without tools, it runs as plain chat.

chatAgent, err := agent.New(agent.Config{
    Generator: client,
    Model:     model,
})
if err != nil {
    return err
}

run, err := chatAgent.Start(ctx, agent.Input{
    Prompts: []message.UserMessage{
        message.NewUserMessage("What can you help me with?"),
    },
})
if err != nil {
    return err
}

result, err := run.Wait()
if err != nil {
    return err
}
fmt.Println(result.Final.Text())

See examples/basic for the complete tool-driven dessert conversation, or run it directly:

export OPENAI_API_KEY=...
export OPENAI_BASE_URL=https://api.example.com/v1 # optional
export OPENAI_MODEL=gpt-4o-mini
go run github.com/yongtenglei/golato/examples/basic@v0.1.0

Compaction

Compaction is optional and stateless. It is useful for long-running conversations approaching a model's context window. Before a model call, it can summarize older complete turns while preserving recent ones. Golato returns the resulting context and compaction records to the host; it does not persist them.

Development

make test
make check

Install the worktree-friendly pre-push hook with make hooks.

License

Except for the Golato logo, this repository is licensed under the MIT License. The Golato logo is © 2026 liuzi. All rights reserved.

Directories

Path Synopsis
adapters
openai
Package openai implements OpenAI Chat Completions and compatible endpoints.
Package openai implements OpenAI Chat Completions and compatible endpoints.
Package agent provides an immutable Agent definition and one stateful Run per execution.
Package agent provides an immutable Agent definition and one stateful Run per execution.
Package compaction replaces older complete turns with a model-generated summary.
Package compaction replaces older complete turns with a model-generated summary.
examples
basic command
Package main demonstrates a minimal OpenAI-compatible agent.
Package main demonstrates a minimal OpenAI-compatible agent.
Package message defines the provider-neutral transcript used by golato.
Package message defines the provider-neutral transcript used by golato.
Package provider defines the provider-neutral generation boundary.
Package provider defines the provider-neutral generation boundary.
Package skills defines independent instruction resources and prompt composition helpers.
Package skills defines independent instruction resources and prompt composition helpers.
Package token defines the small token-estimation boundary used for context budgeting.
Package token defines the small token-estimation boundary used for context budgeting.
Package tool defines callable tools exposed to an agent.
Package tool defines callable tools exposed to an agent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL