# Quickstart

Gojent is a strongly typed, streaming-first Go agent runtime built around explicit contracts, one-way module dependencies, and zero third-party dependencies in the root module. Use this quickstart to install the runtime, execute a key-free agent with `mockllm`, and connect a real provider with typed tools and session persistence.

## Requirements

> **Beta (`v0.x`):** Gojent is pre-`v1.0.0`. Minor releases may introduce breaking changes while APIs settle—pin explicit module versions in `go.mod` and check [Versioning and submodule tags](/docs/guides/development#versioning-and-submodule-tags) and [`CHANGELOG.md`](https://github.com/ijaidev/gojent/blob/main/CHANGELOG.md) before upgrading.

Gojent requires **Go 1.25.5** or newer. Install the root module to get `core/agent`, `core/llm`, `core/tool`, `core/session`, `tools`, and the deterministic `providers/mockllm` model:

```bash
go get github.com/ijaidev/gojent@latest
```

Optional providers, durable session stores, and the MCP client live in separate Go modules so the root module stays dependency-free:

```bash
go get github.com/ijaidev/gojent/providers/google
go get github.com/ijaidev/gojent/providers/openai
go get github.com/ijaidev/gojent/providers/anthropic
go get github.com/ijaidev/gojent/stores/sqlite
go get github.com/ijaidev/gojent/stores/postgres
go get github.com/ijaidev/gojent/mcp
```

## Run a key-free agent

Start with `providers/mockllm` to verify the runtime loop locally without API credentials or external network calls:

```go
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/ijaidev/gojent/core/agent"
	"github.com/ijaidev/gojent/providers/mockllm"
)

func main() {
	model := mockllm.New("Gojent is a small, typed agent runtime for Go.")

	assistant, err := agent.New(agent.Config{
		Name:         "assistant",
		Instructions: "Answer in one sentence.",
		Model:        model,
	})
	if err != nil {
		log.Fatal(err)
	}

	response, err := assistant.Generate(context.Background(), "What is Gojent?")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(response.Text)
}
```

Running this program prints the deterministic response from `mockllm`:

```text
Gojent is a small, typed agent runtime for Go.
```

## Add a typed tool and a real provider

Tool inputs and outputs are ordinary Go structs. `tool.MustNew` generates a JSON Schema from struct tags (`json`, `description`, `enum`) and validates model arguments before your handler runs:

```go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/ijaidev/gojent/core/agent"
	"github.com/ijaidev/gojent/core/session"
	"github.com/ijaidev/gojent/core/tool"
	"github.com/ijaidev/gojent/providers/google"
)

type WeatherInput struct {
	City string `json:"city" description:"City name, e.g. Tokyo"`
}

type WeatherOutput struct {
	City         string  `json:"city"`
	TemperatureC float64 `json:"temperature_c"`
}

func main() {
	ctx := context.Background()

	model, err := google.New(ctx, google.Config{
		Model:  "gemini-2.5-flash",
		APIKey: os.Getenv("GEMINI_API_KEY"),
	})
	if err != nil {
		log.Fatal(err)
	}

	weather := tool.MustNew(tool.Config[WeatherInput, WeatherOutput]{
		ID:          "get_weather",
		Description: "Get the current weather for a city.",
		Annotations: tool.Annotations{ReadOnly: true},
		Execute: func(_ context.Context, in WeatherInput) (WeatherOutput, error) {
			return WeatherOutput{City: in.City, TemperatureC: 21.5}, nil
		},
	})

	assistant, err := agent.New(agent.Config{
		Name:         "assistant",
		Description:  "A concise weather assistant",
		Instructions: "Use the weather tool when asked about current conditions.",
		Model:        model,
		Tools:        []tool.Tool{weather},
		Store:        session.NewMemory(),
	})
	if err != nil {
		log.Fatal(err)
	}

	response, err := assistant.Generate(ctx, "What is the weather in Tokyo?",
		agent.WithSession("demo", "user-1"),
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(response.Text)
}
```

Swap `google.New` for `openai.New`, `openai.NewChatCompletion`, or `anthropic.New` without changing agent, tool, or session code—all adapters implement the same `llm.Model` contract.

## Next steps

- Understand the four extension seams and boundaries in [Architecture](/docs/architecture).
- Define schema-validated tools in [Typed Tools](/docs/core/tools) or enforce tool gating in [Policies & Approvals](/docs/core/policies).
- Explore [Model Providers](/docs/modules/providers) for OpenAI, Anthropic, and Google configuration.
- Browse the full exported Go API on [pkg.go.dev](https://pkg.go.dev/github.com/ijaidev/gojent/core/agent).
