JuliusBrussee/caveman · error
native runtime: invalid decision id
Error message
native runtime: invalid decision id
What it means
ExplainDecision validates the decisionID against a strict decisionIDPattern before touching the store, returning this error for malformed ids. This keeps arbitrary strings from becoming store lookups and gives callers a deterministic, cheap validation failure.
Solutions
- Check the id against the same decisionIDPattern client-side before calling ExplainDecision and return a better message.
- Retrieve the decision id programmatically from the store (FindTaskDecision/list) instead of accepting user-typed input.
- If valid legacy ids fail, migrate them to the current id format.
- Log the offending id (safely) to spot the client sending malformed values.
Example fix
// before
exp, err := nativeruntime.ExplainDecision(store, req.DecisionID)
// after
if !isValidDecisionID(req.DecisionID) {
return errorf("decision id must match format ...")
}
exp, err := nativeruntime.ExplainDecision(store, req.DecisionID) Defensive patterns
Strategy: validation
Validate before calling
var decisionIDPattern = regexp.MustCompile(`^[0-9a-f-]{36}$`) // match the library's pattern
if !decisionIDPattern.MatchString(id) {
return fmt.Errorf("malformed decision id %q", id)
} Type guard
func validDecisionID(s string) bool { return decisionIDPattern.MatchString(s) } Try / catch
exp, err := nativeruntime.ExplainDecision(store, id)
if err != nil && strings.Contains(err.Error(), "invalid decision id") {
return fmt.Errorf("decision id %q is malformed; fetch ids from the store instead", id)
} Prevention
- Never accept hand-typed decision ids; list them from the store
- Keep client-side id format validation in sync with the runtime
- Log rejected ids to find misbehaving clients
When it happens
Trigger: runNativeWhy (native runtime why handler) or tests call ExplainDecision(store, decisionID) with an id that does not match decisionIDPattern — e.g. empty string, path separators, uuid with wrong format, or a truncated id from a client.
Common situations: A client tool passes a human-typed or copy-pasted decision reference; an older stored id format predating the pattern; passing a session id where a decision id was expected.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- caveman agent: invalid agent id
- caveman agent: invalid memory namespace
- invalid_scope
- : must be a safe non-empty identifier
- native runtime: invalid decision record
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/53a888deb5e0cc24.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/internal/nativeruntime/explain.go:35
// Ledger record. It contains decision basis, never raw prompt or tool output.
type DecisionExplanation struct {
Schema string `json:"schema"`
DecisionID string `json:"decision_id"`
SessionID string `json:"session_id"`
TimestampMS int64 `json:"timestamp_ms"`
Action string `json:"action"`
Reason string `json:"reason"`
InputBasis map[string]any `json:"input_basis"`
AlternativesRejected []string `json:"alternatives_rejected"`
TaskStateBefore string `json:"task_state_before"`
TaskStateAfter string `json:"task_state_after"`
Currentness string `json:"currentness"`
RecoveryRef string `json:"recovery_ref,omitempty"`
}
func ExplainDecision(store *ccr.Store, decisionID string) (DecisionExplanation, error) {
if !decisionIDPattern.MatchString(decisionID) {
return DecisionExplanation{}, errors.New("native runtime: invalid decision id")
}
object, err := store.FindTaskDecision(decisionID)
if err != nil {
return DecisionExplanation{}, err
}
var record struct {
Schema string `json:"schema"`
DecisionID string `json:"decision_id"`
TimestampMS int64 `json:"timestamp_ms"`
Action string `json:"action"`
Reason string `json:"reason"`
InputBasis map[string]any `json:"input_basis"`
AlternativesRejected []string `json:"alternatives_rejected"`
TaskStateBefore string `json:"task_state_before"`
TaskStateAfter string `json:"task_state_after"`
Currentness string `json:"currentness"`
RecoveryRef string `json:"recovery_ref"`
}View on GitHub (pinned to 3ee70a1026)