langchain-ai/deepagents · error · ValueError
RewarmEstimate incremental cost {self.incremental_cost_usd!r
Error message
RewarmEstimate incremental cost {self.incremental_cost_usd!r} cannot exceed the cold cost {self.cold_cost_usd!r} What it means
RewarmEstimate requires incremental_cost_usd <= cold_cost_usd: re-warming a cache can never cost more than a full cold rebuild. If it would, the estimate is inconsistent and the library rejects construction.
Source
Thrown at libs/code/deepagents_code/cold_cache.py:219
msg = (
f"RewarmEstimate costs must be finite, got "
f"cold={self.cold_cost_usd!r}, "
f"incremental={self.incremental_cost_usd!r}"
)
raise ValueError(msg)
if self.cold_cost_usd < 0 or self.incremental_cost_usd < 0:
msg = (
f"RewarmEstimate costs must be non-negative, got "
f"cold={self.cold_cost_usd!r}, "
f"incremental={self.incremental_cost_usd!r}"
)
raise ValueError(msg)
if self.incremental_cost_usd > self.cold_cost_usd:
msg = (
f"RewarmEstimate incremental cost {self.incremental_cost_usd!r} "
f"cannot exceed the cold cost {self.cold_cost_usd!r}"
)
raise ValueError(msg)
@dataclass(frozen=True, slots=True)
class ColdCacheWarning:
"""Validated data needed to render one advisory warning.
Constructed only after every gate has passed -- a policy resolved, the
prefix cleared the provider's cache minimum, and the priced delta reached
the configured threshold -- so the modal renders it without re-deciding
anything.
"""
policy: PromptCachePolicy
estimate: RewarmEstimate
context_tokens: int
age_seconds: float | None
"""Idle time since the last successful turn.View on GitHub (pinned to a1af029e6e)
Solutions
- Recompute both estimates from the same token counts and pricing source so incremental <= cold holds.
- Clamp the incremental estimate to the cold estimate (min()) if clamping is a defensible approximation for your use case.
- Audit which pricing snapshot each number came from and refresh them together.
Example fix
// before est = RewarmEstimate(cold_cost_usd=cold_old_pricing, incremental_cost_usd=inc_new_pricing) // after cold = estimate_cold(tokens, pricing_latest) inc = min(estimate_incremental(tokens, pricing_latest), cold) est = RewarmEstimate(cold_cost_usd=cold, incremental_cost_usd=inc)
Defensive patterns
Strategy: validation
Validate before calling
if inc > cold:
raise ValueError(f"incremental {inc!r} exceeds cold {cold!r}; recheck estimates")
est = RewarmEstimate(cold_cost_usd=cold, incremental_cost_usd=inc) Type guard
def is_valid_cost_pair(cold: float, inc: float) -> bool:
return math.isfinite(cold) and math.isfinite(inc) and 0 <= inc <= cold Try / catch
try:
est = RewarmEstimate(cold_cost_usd=cold, incremental_cost_usd=inc)
except ValueError:
est = RewarmEstimate(cold_cost_usd=cold, incremental_cost_usd=min(inc, cold)) Prevention
- Derive cold and incremental from the same token counts and pricing snapshot
- Refresh both estimates together when pricing changes
- Sanity-check with a pair validator before construction
When it happens
Trigger: Constructing RewarmEstimate(cold_cost_usd=1.0, incremental_cost_usd=1.5), typically because the two estimates came from different scopes, different models, or stale vs refreshed pricing.
Common situations: Cold cost computed for a smaller token count than the incremental path, mixing prices from two model versions, or double-counting fees into the incremental estimate.
Related errors
- RewarmEstimate costs must be finite, got cold={self.cold_cos
- RewarmEstimate costs must be non-negative, got cold={self.co
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
- -32602
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/d26fcd7c757d7406.
Report an issue: GitHub.