JuliusBrussee/caveman · error

native pack: invalid Core budget or instructions

Error message

native pack: invalid Core budget or instructions

What it means

The second identity check in nativepack.validate: the pack's Core section must be flagged Mandatory, must contain non-empty Instructions, and its EstimatedTokens must not exceed its PromptTokenBudget. This guarantees the always-injected core actually fits its budget before any skill is loaded.

Source

Thrown at proxy/internal/nativepack/pack.go:96

	found := false
	for _, skill := range pack.Skills {
		for _, candidate := range skill.TaskTypes {
			if candidate == taskType {
				if !found || skill.Precedence > selected.Precedence {
					selected, found = skill, true
				}
			}
		}
	}
	return selected, found
}

func validate(pack Pack) error {
	if pack.Schema != "caveman.native-pack.v1" || pack.ID == "" || pack.Version == "" || pack.Protocol < 1 {
		return errors.New("native pack: invalid identity")
	}
	if !pack.Core.Mandatory || pack.Core.Instructions == "" || pack.Core.EstimatedTokens > pack.Core.PromptTokenBudget {
		return errors.New("native pack: invalid Core budget or instructions")
	}
	owners := map[string][]Skill{}
	ids := map[string]bool{}
	for _, skill := range pack.Skills {
		if skill.ID == "" || ids[skill.ID] || skill.Activation != "classified" || skill.Instructions == "" || len(skill.Instructions) > skill.PromptByteBudget {
			return fmt.Errorf("native pack: invalid skill %q", skill.ID)
		}
		ids[skill.ID] = true
		for _, taskType := range skill.TaskTypes {
			owners[taskType] = append(owners[taskType], skill)
		}
	}
	for _, skill := range pack.Skills {
		for _, conflict := range skill.Conflicts {
			if !ids[conflict] {
				return fmt.Errorf("native pack: %s conflicts with unknown skill %s", skill.ID, conflict)
			}
		}

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Set core.mandatory = true and provide core.instructions text
  2. Re-measure the instructions' token count and set estimated_tokens to that value, keeping it <= prompt_token_budget
  3. If instructions are legitimately large, raise prompt_token_budget rather than under-reporting the estimate

Example fix

// before
pack.Core = nativepack.Core{Mandatory: false, Instructions: "", EstimatedTokens: 5000, PromptTokenBudget: 4000}

// after
pack.Core = nativepack.Core{Mandatory: true, Instructions: coreText, EstimatedTokens: countTokens(coreText), PromptTokenBudget: 4000}
Defensive patterns

Strategy: validation

Validate before calling

if !pack.Core.Mandatory || pack.Core.Instructions == "" || pack.Core.EstimatedTokens > pack.Core.PromptTokenBudget {
    return errors.New("fix core section")
}
err := nativepack.Load(pack)

Type guard

func validCore(c nativepack.Core) bool {
    return c.Mandatory && c.Instructions != "" && c.EstimatedTokens <= c.PromptTokenBudget
}

Prevention

When it happens

Trigger: Loading a pack where core.mandatory is false or missing, core.instructions is empty, or core.estimated_tokens > core.prompt_token_budget (e.g. instructions grew past the declared budget after editing).

Common situations: Editing core instructions without re-measuring tokens; copying a pack template and forgetting the mandatory flag; budgets declared in a different unit (K vs raw tokens) than the estimator emits.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/8e13ca037e88ca77. Report an issue: GitHub.