mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-29 18:46:59 +00:00
refactor(agent): direct flag access in redecoration, matching call-block site
The call-block decoration reads agent._use_prompt_caching / _cache_ttl / _use_native_cache_layout directly; the redecoration helper wrapped each in getattr with divergent defaults (e.g. or-'5m' vs verbatim _cache_ttl). The flags are unconditionally initialized on AIAgent, so the defaults served only test fixtures and would mask a real init bug as silent cache-off. Align with the house style.
This commit is contained in:
parent
708390f47d
commit
551e1c6d64
1 changed files with 6 additions and 3 deletions
|
|
@ -887,13 +887,16 @@ def _redecorate_prompt_cache_for_provider(
|
|||
|
||||
strip_anthropic_cache_control(messages)
|
||||
|
||||
if getattr(agent, "_use_prompt_caching", False):
|
||||
# Direct attribute access matches the call-block decoration site — the
|
||||
# flags are unconditionally initialized on AIAgent, and a getattr
|
||||
# default here would mask a real init bug as silent cache-off.
|
||||
if agent._use_prompt_caching:
|
||||
_ensure_cached_system_prompt_static(agent, system_message=system_message)
|
||||
static = getattr(agent, "_cached_system_prompt_static", None)
|
||||
messages = apply_anthropic_cache_control(
|
||||
messages,
|
||||
cache_ttl=getattr(agent, "_cache_ttl", None) or "5m",
|
||||
native_anthropic=bool(getattr(agent, "_use_native_cache_layout", False)),
|
||||
cache_ttl=agent._cache_ttl,
|
||||
native_anthropic=agent._use_native_cache_layout,
|
||||
static_system_prefix=static if isinstance(static, str) else None,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue