JuliusBrussee/caveman · error
rewriter: theta must not be negative, got %d
Error message
rewriter: theta must not be negative, got %d
What it means
New validated the rewriter theta gate configuration and found a negative Theta value. Theta zero defaults to DefaultTheta, but a negative threshold is nonsensical for the gate (it would invert the accept/reject decision) and is rejected at construction time.
Source
Thrown at rewriter/rewriter.go:144
// gate was designed for.
func New(cfg Config) (*Client, error) {
provider := strings.ToLower(strings.TrimSpace(cfg.Provider))
if provider != providerAnthropic && provider != providerOpenAI {
return nil, fmt.Errorf("rewriter: unsupported provider %q", cfg.Provider)
}
model := strings.TrimSpace(cfg.Model)
if model == "" {
return nil, errors.New("rewriter: model is required")
}
if strings.TrimSpace(cfg.APIKey) == "" {
return nil, errors.New("rewriter: api key is required")
}
theta := cfg.Theta
if theta == 0 {
theta = DefaultTheta
}
if theta < 0 {
return nil, fmt.Errorf("rewriter: theta must not be negative, got %d", theta)
}
doer := cfg.HTTPDoer
if doer == nil {
doer = http.DefaultClient.Do
}
return &Client{provider: provider, model: model, apiKey: cfg.APIKey, theta: theta, doer: doer}, nil
}
// Rewrite condenses req.StepBytes, or explains why it did not.
//
// Gate 1 (invocation) skips the API call entirely when the step is at or under
// θ tokens. Gate 2 (application) plus the fidelity checks in Accept decide
// whether the completion may replace the original. Only an accepted result
// carries bytes; every other path returns an empty Rewritten and a reason.
func (c *Client) Rewrite(ctx context.Context, req Request) (Result, error) {
originalTokens := countTokens(req.StepBytes)
if originalTokens <= c.theta {
return Result{RejectReason: reasonBelowTheta}, nilView on GitHub (pinned to 766dce6b13)
Solutions
- Set Theta to a non-negative value (or 0/omit it to use DefaultTheta)
- Remove the negative sign — likely a typo in configuration
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at rewriter/rewriter.go:144 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/17208ad6b60b01fa.
Report an issue: GitHub.