mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 05:17:15 +00:00
Four call sites fork a second agent with skip_memory=True, which leaves the
child with _memory_manager = None: a fork is not the user, and its scratch
transcript is not the user's memory. With compression.checkpoint_required
armed that saving turns into a kill. The gate is armed globally per agent
instance from config, not from whether the agent has a provider, so the child
arms the same gate its parent did and then meets its first compaction with
nothing to checkpoint against. It raises CompressionCheckpointUnavailable --
"no active provider implements checkpoint API v2" -- and the delegate turn
dies with status=error and a null summary while the parent runs on. The gate
is not bypassed there; it is armed against a provider that was never loaded.
- The four sites (delegate_tool, curator, batch_runner, feishu_comment) pass
skip_memory=not checkpoint_required_from_config(). Gate off is the default
and stays byte-identical: skip_memory=True, no provider init, no hook. Same
shape and the same reason as the two gateway disposable-agent sites that
already read the key this way (run_turn_hygiene.py,
slash_commands_session.py). delegate_tool reads it inside the delegated
profile scope, where the child reads it.
- The detached review and /btw forks (build_cache_parity_fork) are not
touched: they persist nothing, and _pre_compress_memory_context already
exempts exactly that shape (decabd79f1), so the gate never fails them.
- checkpoint_required_from_config() in conversation_compression_checkpoint,
next to the gate's init refusals. One resolver rather than four parses, and
the call sites need it before an agent exists:
agent.compression_checkpoint_required is assigned inside the child's own
init, and the parent's says nothing about the child. It reads
load_config_readonly() -- the call init_agent makes to arm the gate on that
child, so parent and child answer from one source and a fork is given a
provider precisely when the child would refuse to compact without one. An
unreadable config reads as "not armed", matching init_agent's own except
around the same load.
- New memory_agent_context kwarg on AIAgent/init_agent, handed to the
provider's initialize() as agent_context; unset, the platform rule decides
as before (cron/subagent, else "primary"). The platform rule alone cannot
scope these forks: the curator runs as platform "curator", the batch runner
takes its platform from the caller's config, and the Feishu responder sets
none, so each would file its transcript as the user's own memory in every
provider that scopes writes by that key. All four pass "subagent" -- the
value memory_provider.py documents and supermemory gates on. A fresh
per-site string ("curator", "batch", ...) would drop out of every
provider's non-primary membership test and re-enable writes the provider
had deliberately disabled, which is a fail-open on the one path this commit
opens. platform still separates the shapes.
Costs, taken deliberately rather than hidden: one provider initialize() per
fork (a round trip for a network-backed store, on a path that made none), and
fork transcripts reaching the archive as checkpoints. Both are named at the
call site and in the contract doc, where a provider author reads them.
Ten tests (tests/agent/test_fork_memory_under_checkpoint_gate.py). The
four site probes drive the real spawn functions with the smallest parent stub
they accept and record the child constructor kwargs -- red at all four against
the previous commit with the literal skip_memory=True. The gate-off probes are
the control in the other direction: without them "inherit the provider" could
have shipped as "always inherit". The recorder aborts with a BaseException
because the sites wrap the spawn in except Exception and would have swallowed
an ordinary failure into a green test. The provider-initialize test drives a
real AIAgent init, the only way to observe the keyword at initialize().
Live probe (on the August base), isolated HERMES_HOME with a stub API-v2
provider and the gate armed: before, the child aborts with failure_class
"exception:CompressionCheckpointUnavailable" and delegate_task returns
status=error, summary=null. After, the child initializes the provider
(agent_context "subagent", platform "subagent"), its own session fires
on_pre_compress, no CompressionCheckpointUnavailable appears, and the parent
returns the subagent's answer.
(cherry picked from commit 31af59c54ebff4c6c1861961111700b8e42dba76)
(cherry picked from commit 9bf3feaf8c98dff6e90eadf0f533204adc150a8c)
34 lines
1.7 KiB
Python
34 lines
1.7 KiB
Python
"""Names of the ``AIAgent`` constructor params that ``init_agent`` copies onto the agent."""
|
|
|
|
# Constructor params stored verbatim under the same name.
|
|
_PASSTHROUGH_PARAMS = (
|
|
"model", "max_iterations", "save_trajectories", "verbose_logging", "quiet_mode",
|
|
"tool_progress_mode", "ephemeral_system_prompt", "platform", "skip_context_files",
|
|
"load_soul_identity", "pass_session_id", "log_prefix_chars",
|
|
# OpenRouter provider preferences
|
|
"providers_allowed", "providers_ignored", "providers_order", "provider_sort",
|
|
"provider_require_parameters", "provider_data_collection", "openrouter_min_coding_score",
|
|
# Toolset filtering
|
|
"enabled_toolsets", "disabled_toolsets",
|
|
# Model response configuration (None = provider/model default)
|
|
"max_tokens", "reasoning_config", "service_tier",
|
|
"side_agent", "memory_agent_context",
|
|
)
|
|
# Gateway identity params stored as ``agent._<name>``. gateway_session_key is the stable
|
|
# per-chat key (e.g. agent:main:telegram:dm:123).
|
|
_GATEWAY_IDENTITY_PARAMS = (
|
|
"user_id", "user_id_alt", "user_name", "chat_id", "chat_name", "chat_type", "thread_id",
|
|
"gateway_session_key",
|
|
)
|
|
_CALLBACK_PARAMS = (
|
|
"tool_progress_callback", "tool_start_callback", "tool_complete_callback",
|
|
"tool_result_metadata_callback",
|
|
"thinking_callback", "reasoning_callback", "clarify_callback",
|
|
"read_terminal_callback", "read_preview_callback", "drive_preview_callback",
|
|
"read_window_below_callback", "connection_callback", "tour_callback", "theme_callback",
|
|
"setup_beat_callback", "step_callback", "stream_delta_callback",
|
|
"interim_assistant_callback",
|
|
"status_callback", "notice_callback", "notice_clear_callback",
|
|
"event_callback", "reaction_callback", "tool_gen_callback",
|
|
)
|