JuliusBrussee/caveman · error

invalid agent evidence identity

Error message

invalid agent evidence identity

What it means

AgentEvidenceForBuild requires a fully valid identity tuple: sessionID (evidence token, max 256 chars), buildSHA256 and planSHA256 (64-char digests). Any partial or malformed identity fails closed with this error rather than querying with wrong data.

Solutions

  1. Verify buildSHA256 and planSHA256 are exact 64-character lowercase hex strings from the recorded evidence.
  2. Check the session ID is non-empty, within 256 chars, and contains only accepted token characters.
  3. Log/inspect the three values before the call to see which one fails validation.
  4. If the caller doesn't have real digests, don't call this API — fetch the SHAs from the build/plan records first.

Example fix

// before
ev, err := store.AgentEvidenceForBuild(sessionID, buildSHA, "")
// after
if buildSHA == "" { buildSHA = record.BuildSHA256 }
if isValidDigest(buildSHA) && isValidDigest(planSHA) {
    ev, err = store.AgentEvidenceForBuild(sessionID, buildSHA, planSHA)
}
Defensive patterns

Strategy: validation

Validate before calling

func validBuildInputs(session, build, plan string) bool {
    return session != "" && len(session) <= 256 &&
        len(build) == 64 && len(plan) == 64 &&
        isHex(build) && isHex(plan)
}

Try / catch

ev, err := store.AgentEvidenceForBuild(sid, build, plan)
if err != nil && err.Error() == "invalid agent evidence identity" {
    return fmt.Errorf("bad identity tuple: session=%q build=%q plan=%q", sid, build, plan)
}

Prevention

When it happens

Trigger: Calling Store.AgentEvidenceForBuild with an empty/malformed sessionID, or a build/plan SHA that is empty, not 64 hex chars, or contains non-hex characters.

Common situations: Callers pass placeholder strings like "unknown" or "-" for build/plan SHAs, truncate a digest, or read a session ID from untrusted request input that fails the token validation.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/642eb3889c6a36a7. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/store/store.go:670

	ContextBill                  string `json:"context_bill"`
	TransformTrace               string `json:"transform_trace"`
	TransformLocation            string `json:"transform_location"`
	CacheEpoch                   string `json:"cache_epoch"`
	CachePrefixSHA256            string `json:"declared_cache_prefix_sha256"`
	ProviderCachePrefixSHA256    string `json:"provider_cache_prefix_sha256"`
	ProviderCacheComponentSHA256 string `json:"provider_cache_component_sha256"`
	CacheBoundaryKnown           bool   `json:"cache_boundary_known"`
	RecoveryHandle               string `json:"recovery_handle"`
	CompressionTokensBefore      int64  `json:"compression_tokens_before"`
	CompressionTokensAfter       int64  `json:"compression_tokens_after"`
	Basis                        string `json:"basis"`
}

// AgentEvidenceForBuild returns all requests for one exact session/build/plan
// tuple in provider-call order. Partial or malformed identity fails closed.
func (s *Store) AgentEvidenceForBuild(sessionID, buildSHA256, planSHA256 string) ([]AgentEvidence, error) {
	if !validEvidenceToken(sessionID, 256) || !validDigest(buildSHA256) || !validDigest(planSHA256) {
		return nil, fmt.Errorf("invalid agent evidence identity")
	}
	rows, err := s.db.Query(
		`SELECT ts, request_id, session_id, agent_build_sha256, efficiency_plan_sha256,
		        COALESCE(provider,''), COALESCE(model,''), COALESCE(status_code,0),
		        COALESCE(input_tokens,0), COALESCE(output_tokens,0), COALESCE(cached_input_tokens,0),
		        COALESCE(cache_creation_input_tokens,0), COALESCE(reasoning_tokens,0),
		        COALESCE(token_usage_basis,'unavailable'), COALESCE(raw_request_sha256,''),
		        COALESCE(transformed_request_sha256,''), COALESCE(request_hash_complete,0), COALESCE(optimization_ids,''),
		        COALESCE(context_bill,''), COALESCE(transform_trace,''), COALESCE(transform_location,''),
		        COALESCE(cache_epoch,''), COALESCE(cache_prefix_sha256,''),
		        COALESCE(provider_cache_prefix_sha256,''), COALESCE(provider_cache_component_sha256,''),
		        COALESCE(cache_boundary_known,0), COALESCE(recovery_handle,''),
		        COALESCE(compression_tokens_before,0), COALESCE(compression_tokens_after,0), basis
		   FROM requests
		  WHERE session_id = ? AND agent_build_sha256 = ? AND efficiency_plan_sha256 = ?
		  ORDER BY id ASC
		  LIMIT 500`,
		sessionID, buildSHA256, planSHA256,

View on GitHub (pinned to 3ee70a1026)