The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent/agent_init): compact compression summary + context-engine tool injection
Teknium3728e7609300
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex fd7e7de0f0d..34a1dd1dae8 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -1905,9 +1905,9 @@ def _inject_context_engine_tools(agent):_existing_tool_names = {t.get("function", {}).get("name") for t in agent.tools if isinstance(t, dict)}- from agent.memory_manager import normalize_tool_schema as _normalize_tool_schema+ from agent.memory_manager import normalize_tool_schemafor _raw_schema in agent.context_compressor.get_tool_schemas():- _schema = _normalize_tool_schema(_raw_schema)+ _schema = normalize_tool_schema(_raw_schema)if _schema is None:# A nameless tool makes strict providers 400 and disables the whole toolset._ra().logger.warning(@@ -1920,9 +1920,8 @@ def _inject_context_engine_tools(agent):if _tname in _existing_tool_names:continue # already registered via plugin/cache pathagent.tools.append({"type": "function", "function": _schema})- agent.valid_tool_names.add(_tname)- agent._context_engine_tool_names.add(_tname)- _existing_tool_names.add(_tname)+ for _names in (agent.valid_tool_names, agent._context_engine_tool_names, _existing_tool_names):+ _names.add(_tname)if agent.context_compressor:try:@@ -2003,18 +2002,15 @@ def _emit_compression_summary(agent, cs):)if not agent.quiet_mode:+ _cc = agent.context_compressorif cs.enabled:# The active engine's own threshold β a plugin's differs from cs.threshold.- _active_threshold_pct = getattr(- agent.context_compressor, "threshold_percent", cs.threshold- )- _cap_note = ""- _cap = getattr(agent.context_compressor, "threshold_tokens_cap", None)- if _cap and _cap > 0:- _cap_note = f" (capped at {_cap:,} tokens)"- print(f"π Context limit: {agent.context_compressor.context_length:,} tokens (compress at {int(_active_threshold_pct*100)}% = {agent.context_compressor.threshold_tokens:,}{_cap_note})")+ _pct = getattr(_cc, "threshold_percent", cs.threshold)+ _cap = getattr(_cc, "threshold_tokens_cap", None)+ _cap_note = f" (capped at {_cap:,} tokens)" if _cap and _cap > 0 else ""+ print(f"π Context limit: {_cc.context_length:,} tokens (compress at {int(_pct*100)}% = {_cc.threshold_tokens:,}{_cap_note})")else:- print(f"π Context limit: {agent.context_compressor.context_length:,} tokens (auto-compression disabled)")+ print(f"π Context limit: {_cc.context_length:,} tokens (auto-compression disabled)")# Gateway users get the same text via _compression_warning on turn 1.if _autoraise_notice:print(_autoraise_notice)