hermes-agent/agent
0xarkstar eaeba6474f feat(agent): add skip_background_review flag to AIAgent constructor
Phase 8 of the Hermes Agent token leak mitigation plan
(ralplan-hermes-token-leaks.md §3.9). Adds a boolean kwarg
`skip_background_review` (default False) to AIAgent.__init__ that
suppresses the end-of-turn _spawn_background_review fork.

Each background review fork instantiates a new AIAgent with its own
~15K input tokens + up to 8 LLM iterations, accumulating ~30K tokens
per event in the worst case. On cron sessions there is no
human-in-the-loop benefit from the review (no skill-creation pressure,
nobody curating MEMORY.md), so the cost is pure waste.

The end-of-turn guard now reads:

    if (final_response and not interrupted
            and not getattr(self, "skip_background_review", False)
            and (_should_review_memory or _should_review_skills)):

skip_memory=True already disables the memory-review trigger; this
flag is the explicit single-switch off for both review paths.

Defaults to False, so behavior is unchanged for gateway/CLI callers
that omit the kwarg.

Tests: 5 new unit tests in tests/agent/test_skip_background_review.py
covering the default value, flag persistence, the gate short-circuit,
the gate fall-through, and a source-text assertion that the cron
scheduler sets the flag to True (separate commit).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-08-08 00:07:14 +05:30
..
lsp fix(runtime): resolve Hermes-managed Node and uv before bare PATH 2026-08-01 21:17:51 -04:00
monitoring feat(monitoring): add hermes.gateway.background_delegations (unit/slot count) 2026-07-25 02:30:20 +00:00
pet
proxy_sources fix(windows): sweep remaining unguarded text-mode subprocess sites codebase-wide 2026-07-24 11:45:57 -07:00
secret_sources fix(gateway): hydrate cold profile secret sources 2026-08-02 00:11:50 -07:00
transports feat(providers): env-var metadata, config-driven local no-auth, reasoning-effort clamp for Actual 2026-08-05 14:08:32 -07:00
verify Integrate verify subsystem with the existing verification stack 2026-08-07 10:11:05 -07:00
__init__.py
account_usage.py fix(auth): detect upstream Codex quota resets and lift stale pool cooldowns (#69494) 2026-07-22 10:58:22 -07:00
agent_init.py feat(agent): add skip_background_review flag to AIAgent constructor 2026-08-08 00:07:14 +05:30
agent_runtime_helpers.py fix(agent): preserve destroyed tool-call argument bytes in the WARNING log 2026-08-07 16:57:11 +05:30
anthropic_adapter.py fix: prefer explicit anthropic api key 2026-08-04 00:12:45 +05:30
async_utils.py
aux_accounting.py
auxiliary_client.py fix(auxiliary): widen effective provider to relay, logging, and endpoint detection 2026-08-07 16:56:37 +05:30
azure_identity_adapter.py fix(secrets): scope-aware Azure credential presence reads in identity diagnostics 2026-08-02 10:02:33 -07:00
backend_identity.py refactor(fallback): single owner for backend identity and failure-scoped skips 2026-07-26 23:41:54 -07:00
background_review.py feat: /refine — run the memory/skill self-improvement review on demand 2026-08-05 22:40:51 -07:00
battery.py
bedrock_adapter.py feat(bedrock): add Converse API prompt caching (cachePoint) 2026-07-23 11:45:07 -07:00
billing_links.py feat(billing): shared cross-surface out-of-credits signal 2026-07-22 18:08:59 -05:00
billing_usage.py chore: remove unused imports and dead locals (ruff F401/F841 sweep) 2026-07-29 11:53:39 -07:00
billing_view.py chore: remove unused imports and dead locals (ruff F401/F841 sweep) 2026-07-29 11:53:39 -07:00
bounded_response.py
browser_provider.py fix(browser): replace expired cloud sessions 2026-08-02 11:18:41 +05:30
browser_registry.py
chat_completion_helpers.py fix(streaming): close the same mid-tool-call drop gap on the Anthropic path 2026-08-07 18:07:19 +05:30
codex_responses_adapter.py fix(codex): defang reserved Harmony tokens in requests 2026-07-31 22:53:20 -07:00
codex_runtime.py fix(codex): split reasoning summary parts on summary_index 2026-08-06 22:02:46 -05:00
coding_context.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
context_breakdown.py feat(cli,gateway): unify /context into a visual context-usage breakdown 2026-07-26 18:06:21 -07:00
context_compressor.py refactor(agent): fold simplify findings — DB picker parity, single scan, canonical strip delegation 2026-08-07 19:44:35 +05:30
context_engine.py fix(context-engine): snapshot select_context read-only inputs; scope on_turn_complete coverage doc 2026-07-23 19:44:35 -07:00
context_references.py fix(context): keep @ref tokens inline instead of stripping them from the prompt 2026-07-27 22:55:18 -05:00
conversation_compression.py fix: bind continuation-marker exclusions to the queried parent (fail-open fix) 2026-08-07 13:24:56 +05:30
conversation_loop.py refactor(agent): fold simplify findings — DB picker parity, single scan, canonical strip delegation 2026-08-07 19:44:35 +05:30
copilot_acp_client.py fix(core,cli,gateway,plugins): add encoding='utf-8' to read_text() calls 2026-07-24 17:10:39 -07:00
credential_persistence.py
credential_pool.py fix(credential-pool): bench a billing 403 fully, even as the sole key 2026-08-04 23:33:39 +05:30
credential_sources.py fix(windows): sweep remaining bare read_text/write_text sites + linter rule 2026-07-24 17:10:39 -07:00
credits_tracker.py fix(credits): reintroduce grant_spent, gated on an in-session crossing (#73634) 2026-07-28 21:36:23 +00:00
curator.py perf(curator): trim dead tool-schema from the LLM review fork 2026-08-03 18:21:17 +05:30
curator_backup.py fix(curator): restore the real skills tree when a rollback extract dies part-way 2026-07-31 22:34:57 -07:00
delegation_context.py fix(cron): don't let a cron job inherit a kanban worker's dispatcher identity 2026-08-06 03:16:26 +05:30
display.py refactor(discord): simplify tool preview links 2026-08-02 21:48:06 -07:00
error_classifier.py fix: show explicit member spend cap message instead of 'no credits' 2026-08-07 19:47:40 +05:30
errors.py
estop.py feat(cli): global emergency stop — `hermes pause` / `hermes resume` 2026-08-07 08:58:14 -07:00
file_safety.py fix(secrets): harden encrypted Bitwarden cache 2026-07-22 04:40:07 -07:00
gemini_native_adapter.py fix(gemini): interpose placeholder model turn between tool result and user text 2026-08-05 17:21:01 -07:00
gemini_schema.py fix(gemini): preserve typed enum constraints as strings 2026-07-26 20:59:16 -07:00
i18n.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
image_gen_provider.py
image_gen_registry.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
image_routing.py feat(image_routing): accept vision alias for custom provider models 2026-07-23 08:32:09 -07:00
insights.py refactor(insights): drop consumer-less get_skill_breakdown alias (simplify-pass) 2026-08-03 18:45:43 +05:30
interrupt_compat.py fix(compression): let explicit interrupts cancel safely 2026-08-02 22:15:20 +05:30
iteration_budget.py feat: raise default tool-calling iteration limit from 90 to 500 2026-07-26 12:54:45 -07:00
jiter_preload.py
kanban_stop.py
learn_prompt.py feat(/learn): expansive knowledge-base skills for books and large corpora 2026-08-06 22:14:52 -07:00
learning_graph.py
learning_graph_render.py chore: remove unused imports and dead locals (ruff F401/F841 sweep) 2026-07-29 11:53:39 -07:00
learning_mutations.py
lmstudio_reasoning.py
manual_compression_feedback.py fix(compress): classify unconfirmed lock-acquire failures and cover all manual-compress surfaces 2026-07-23 08:19:14 -07:00
markdown_tables.py
memory_manager.py fix(memory): honor disabled toolsets for provider tools 2026-07-24 13:00:53 +05:30
memory_provider.py fix(openviking): integrate reliability and configuration hardening 2026-08-03 20:35:47 +05:30
message_content.py
message_sanitization.py fix(agent): preserve destroyed tool-call argument bytes in the WARNING log 2026-08-07 16:57:11 +05:30
moa_loop.py perf(moa): cache resolved preset + per-slot runtime to cut cold-start latency (#66793) 2026-08-03 22:43:15 +05:30
moa_trace.py
model_metadata.py fix(model_metadata): read llama.cpp context from meta.n_ctx + accept sole model 2026-08-04 11:08:32 +05:30
models_dev.py Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
moonshot_schema.py
nous_rate_guard.py fix: decode config and state files as UTF-8 on non-UTF-8 locales 2026-07-24 17:10:39 -07:00
onboarding.py feat(surfaces): route busy-input corrections through active-turn redirect 2026-07-22 12:10:58 -05:00
oneshot.py
outbound_webhooks.py fix(hooks): flush outbound queue at interpreter exit 2026-08-02 15:01:11 -07:00
plugin_llm.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
portal_tags.py
process_bootstrap.py
prompt_builder.py fix(agent): prevent historical steer replay 2026-08-05 13:00:47 +05:30
prompt_caching.py fix(agent): make the send-path copy structural — close the write-through class 2026-08-07 16:57:11 +05:30
rate_limit_tracker.py
reactions.py
reasoning_summaries.py fix(reasoning): keep gpt-5.x summary parts as separate blocks on the chat wire 2026-08-06 22:02:37 -05:00
reasoning_timeouts.py fix(compression): coherent context_length setter — no-op guard, re-floor on new window, un-strandable init log 2026-07-28 20:04:58 +05:30
redact.py polish: document newline residual, reuse span local, cheap check first 2026-08-07 17:50:03 +05:30
relay_llm.py Merge upstream main into model metrics 2026-08-02 20:10:47 -07:00
relay_runtime.py fix(relay): preserve skipped turn context 2026-08-03 13:43:17 -06:00
relay_tools.py Reapply "feat(observability): integrate NeMo Relay runtime and shared metrics" 2026-07-27 21:10:51 -07:00
replay_cleanup.py
retry_utils.py refactor: single shared Retry-After parser 2026-07-29 10:13:50 -07:00
runtime_cwd.py
secret_scope.py fix(secrets): allowlist API_SERVER listener settings as global deployment env 2026-08-02 09:59:52 -07:00
session_activity.py refactor(agent): pin session activity heartbeat cadence + harden best-effort write 2026-08-02 16:16:36 -07:00
shell_hooks.py feat(hooks): outbound webhooks — push signed lifecycle events to external HTTP endpoints 2026-08-02 15:01:11 -07:00
skill_bundles.py feat(observability): add Relay skill metrics 2026-07-29 12:20:34 -07:00
skill_commands.py feat(observability): add Relay skill metrics 2026-07-29 12:20:34 -07:00
skill_preprocessing.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
skill_utils.py fix(cron): don't let a cron job inherit a kanban worker's dispatcher identity 2026-08-06 03:16:26 +05:30
ssl_guard.py fix(ssl): detect and repair a missing certifi cacert.pem via existing venv-repair infra 2026-07-24 15:53:38 -07:00
ssl_verify.py
stream_diag.py
stream_single_writer.py
subagent_lifecycle.py fix(compression): let explicit interrupts cancel safely 2026-08-02 22:15:20 +05:30
subdirectory_hints.py fix(context): dedupe subdirectory hints by content digest and skip backup/vendor dirs 2026-08-03 20:43:34 +05:30
subscription_view.py feat(cli): plan catalog on Free + plan= deep link + top-up/auto-refill copy split (#68689) 2026-07-22 08:11:09 +05:30
system_prompt.py docs(system_prompt): fix stale reconstruct_static_prefix docstring example 2026-08-03 23:23:39 +05:30
think_scrubber.py
thinking_timeout_guidance.py
thread_scoped_output.py fix: preserve session history when a turn crashes 2026-08-06 23:08:23 -05:00
title_generator.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
tool_dispatch_helpers.py feat(image): parallelize image_generate batches 2026-08-03 22:53:32 +05:30
tool_executor.py refactor: fold /simplify-code findings 2026-08-06 17:03:10 +05:30
tool_guardrails.py refactor(guardrails): make runaway-loop caps per-turn, not session-total 2026-07-26 21:27:45 -07:00
tool_result_classification.py
trace_upload.py fix(windows): sweep remaining unguarded text-mode subprocess sites codebase-wide 2026-07-24 11:45:57 -07:00
trajectory.py
transcription_provider.py
transcription_registry.py
tts_provider.py
tts_registry.py
turn_context.py fix(agent): stop reference-only compaction handoff from becoming the active turn 2026-08-07 19:44:35 +05:30
turn_finalizer.py feat(agent): add skip_background_review flag to AIAgent constructor 2026-08-08 00:07:14 +05:30
turn_retry_state.py fix(copilot): recover from stale/degraded token 400 AND expired IDE-token 401 2026-07-31 22:31:09 -07:00
turn_summary.py fix(cli): report unknown line deltas for content-free diffs instead of +0 -0 2026-07-26 17:47:51 -07:00
usage_pricing.py Revert "remove Vercel AI Gateway and Vercel Sandbox (#33067)" 2026-07-29 19:48:37 -07:00
verification_evidence.py Integrate verify subsystem with the existing verification stack 2026-08-07 10:11:05 -07:00
verification_stop.py Integrate verify subsystem with the existing verification stack 2026-08-07 10:11:05 -07:00
verify_hooks.py
vertex_adapter.py
video_gen_provider.py
video_gen_registry.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00
web_search_provider.py
web_search_registry.py perf: use load_config_readonly() at read-only call sites in agent/ 2026-07-29 15:28:15 -07:00