> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter-d02e98a0-mintlify-5b6e02fd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# StopServerToolsWhenCondition - Go SDK

> StopServerToolsWhenCondition type definition

<Warning>
  The Go SDK and docs are currently in beta.
  Report issues on [GitHub](https://github.com/OpenRouterTeam/go-sdk/issues).
</Warning>

A single condition that, when met, halts the server-tool agent loop.

## Supported Types

### StopServerToolsWhenFinishReasonIs

```go lines theme={null}
stopServerToolsWhenCondition := components.CreateStopServerToolsWhenConditionFinishReasonIs(components.StopServerToolsWhenFinishReasonIs{/* values here */})
```

### StopServerToolsWhenHasToolCall

```go lines theme={null}
stopServerToolsWhenCondition := components.CreateStopServerToolsWhenConditionHasToolCall(components.StopServerToolsWhenHasToolCall{/* values here */})
```

### StopServerToolsWhenMaxCost

```go lines theme={null}
stopServerToolsWhenCondition := components.CreateStopServerToolsWhenConditionMaxCost(components.StopServerToolsWhenMaxCost{/* values here */})
```

### StopServerToolsWhenMaxTokensUsed

```go lines theme={null}
stopServerToolsWhenCondition := components.CreateStopServerToolsWhenConditionMaxTokensUsed(components.StopServerToolsWhenMaxTokensUsed{/* values here */})
```

### StopServerToolsWhenStepCountIs

```go lines theme={null}
stopServerToolsWhenCondition := components.CreateStopServerToolsWhenConditionStepCountIs(components.StopServerToolsWhenStepCountIs{/* values here */})
```

## Union Discrimination

Use the `Type` field to determine which variant is active, then access the corresponding field:

```go lines theme={null}
switch stopServerToolsWhenCondition.Type {
	case components.StopServerToolsWhenConditionTypeFinishReasonIs:
		// stopServerToolsWhenCondition.StopServerToolsWhenFinishReasonIs is populated
	case components.StopServerToolsWhenConditionTypeHasToolCall:
		// stopServerToolsWhenCondition.StopServerToolsWhenHasToolCall is populated
	case components.StopServerToolsWhenConditionTypeMaxCost:
		// stopServerToolsWhenCondition.StopServerToolsWhenMaxCost is populated
	case components.StopServerToolsWhenConditionTypeMaxTokensUsed:
		// stopServerToolsWhenCondition.StopServerToolsWhenMaxTokensUsed is populated
	case components.StopServerToolsWhenConditionTypeStepCountIs:
		// stopServerToolsWhenCondition.StopServerToolsWhenStepCountIs is populated
}
```
