diff --git a/README.md b/README.md index 60732f40..28c89d19 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ The Claude SDK for Go provides access to the [Claude API](https://docs.anthropic Full documentation is available at **[platform.claude.com/docs/en/api/sdks/go](https://platform.claude.com/docs/en/api/sdks/go)**. +> **Note:** Managed agent outcome events (e.g., `user.define_outcome`) are not yet supported in the Go SDK. +> The Go example in the managed agents documentation currently references types that do not exist in `anthropic-sdk-go`. +> Please use the Python or TypeScript SDKs for this feature until Go support is added. + ## Installation diff --git a/examples/session-basic/main.go b/examples/session-basic/main.go new file mode 100644 index 00000000..3ce1e16f --- /dev/null +++ b/examples/session-basic/main.go @@ -0,0 +1,50 @@ +package main + +import ( + "context" + "fmt" + + "github.com/anthropics/anthropic-sdk-go" +) + +func main() { + client := anthropic.NewClient() + ctx := context.TODO() + + // NOTE: Outcome events (user.define_outcome) are not yet supported in the Go SDK. + + // Create an environment + environment, err := client.Beta.Environments.New(ctx, anthropic.BetaEnvironmentNewParams{ + Name: "example-environment", + }) + if err != nil { + panic(err) + } + + // Create an agent + agent, err := client.Beta.Agents.New(ctx, anthropic.BetaAgentNewParams{ + Name: "example-agent", + Model: anthropic.BetaManagedAgentsModelConfigParams{ + ID: anthropic.BetaManagedAgentsModelClaudeSonnet4_6, + }, + }) + if err != nil { + panic(err) + } + + // Create a session + session, err := client.Beta.Sessions.New(ctx, anthropic.BetaSessionNewParams{ + EnvironmentID: environment.ID, + Agent: anthropic.BetaSessionNewParamsAgentUnion{ + OfBetaManagedAgentsAgents: &anthropic.BetaManagedAgentsAgentParams{ + ID: agent.ID, + Type: anthropic.BetaManagedAgentsAgentParamsTypeAgent, + }, + }, + }) + if err != nil { + panic(err) + } + + fmt.Println("Created session:", session.ID) +}