effort.go (package eai)
Source: sdks/go/effort.go. Back to the Go SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Type alias Effort
Effort is the normalized reasoning effort (common.schema.json#/$defs/effort), translated per model by the Capability Resolver.
Definition: string.
Values:
| Member | Value | Description |
|---|---|---|
EffortNone | "none" | No reasoning, wire value none. |
EffortLow | "low" | Low reasoning effort, wire value low. |
EffortMedium | "medium" | Medium reasoning effort, wire value medium. |
EffortHigh | "high" | High reasoning effort, wire value high. |
EffortMax | "max" | Maximum reasoning effort, wire value max. |
Effort.Valid
Valid() bool
Valid reports whether e is a known effort.
This element takes no parameter.
Returns: bool. true for none, low, medium, high and max.
Class ContextBudget
ContextBudget is the token budget of one model call: B_context = W_model - B_output - B_reasoning - B_safety (Context Contract v1, field budget).
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
Window (window) | int | yes | Context window of the model in tokens (window). |
OutputReserved (output_reserved) | int | yes | Tokens reserved for the model output (output_reserved). |
ReasoningReserved (reasoning_reserved) | int | yes | Tokens reserved for the model reasoning (reasoning_reserved). |
SafetyMargin (safety_margin) | int | yes | Safety margin in tokens (safety_margin); NewContextBudget sets 5 percent of the window, at least 256. |
ContextBudget.Context
Context() int
Context returns the tokens left for the assembled context (negative when reservations exceed the window).
This element takes no parameter.
Returns: int. Window minus the output, reasoning and safety reservations, in tokens.
ContextBudget.Fits
Fits(tokens int) bool
Fits reports whether tokens fit in the context budget.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
tokens | int | yes | Token count of the context to place. |
Returns: bool. true when tokens is at most Context().
ContextBudget.MarshalJSON
MarshalJSON() ([]byte, error)
MarshalJSON adds the computed context_budget field.
This element takes no parameter.
Returns: ([]byte, error). JSON of the four fields plus context_budget, the value of Context().
Raises: error.
ContextBudget.Overflow
Overflow(tokens int) int
Overflow returns how many tokens must be removed to fit (0 when it fits).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
tokens | int | yes | Token count of the context to place. |
Returns: int. Tokens above Context(), 0 when tokens fits.
Functions
ParseEffort
ParseEffort(s string) (Effort, error)
ParseEffort validates a wire value.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
s | string | yes | Wire value: none, low, medium, high or max. |
Returns: (Effort, error). A Effort: Effort is the normalized reasoning effort (common.schema.json#/$defs/effort), translated per model by the Capability Resolver. The error is a typed error of the SDK, nil on success.
Raises: error.
NewContextBudget
NewContextBudget(window int, output int, reasoning int) ContextBudget
NewContextBudget uses a default safety margin of 5 percent of the window, at least 256 tokens.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
window | int | yes | Context window of the model in tokens. | |
output | int | yes | Tokens reserved for the model output. | |
reasoning | int | yes | Tokens reserved for the model reasoning. |
Returns: ContextBudget. A ContextBudget: ContextBudget is the token budget of one model call: B_context = W_model - B_output - B_reasoning - B_safety (Context Contract v1, field budget).
EstimateTokens
EstimateTokens(text string) int
EstimateTokens is the chars/4 heuristic used by the Control Plane fallback estimator.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
text | string | yes | Text to measure. |
Returns: int. Number of runes divided by 4, rounded up; 0 for an empty text.