Commit Graph

277 Commits

Author SHA1 Message Date
alt-glitch
0cbf579e63 refactor(environments-terminal): resolve the process checkpoint path per call
Delete CHECKPOINT_PATH and _CHECKPOINT_PATH_AT_IMPORT from tools/process_registry.py.
_checkpoint_path() returned the constant only when a test had patched it; production
never patches it, so every real call already took get_hermes_home() / "processes.json".
The constant was also an import-time read of HERMES_HOME. No other production reader,
not in plugin_api.json or the frozen updater surface.

Tests and evals/completion_backlog_probe.py now patch _checkpoint_path itself.
2026-11-16 21:56:33 +05:30
alt-glitch
611f0ab757 refactor(cron): three cron helper files move from tools/ to cron/
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
tools/ holds model tools. These three files register none and do cron's
work, so they move to the package that owns it:

  tools/cronjob_job_args.py    -> cron/job_args.py
  tools/cronjob_prompt_scan.py -> cron/prompt_scan.py
  tools/blueprints.py          -> cron/skill_blueprints.py

Their tests move with them to tests/cron/. Every importer changes its
import line in place, so no module is imported earlier or later than
before. Nothing stays at the old paths: none of the three names is on the
plugin API list, the shipped-release list or the old-updater list.

skill_blueprints, not blueprints: cron/blueprint_catalog.py already holds
Automation Blueprints, a different thing. This file reads the blueprint
block of a skill's frontmatter.

Behaviour is the same except two strings. The report of a run the
injection scanner blocked names cron/prompt_scan.py. The one debug line
in skill_blueprints logs as cron.skill_blueprints, so it shows under
`hermes logs --component cron`. job_args and prompt_scan keep the logger
name tools.cronjob_tools.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; the two gateway contract files are regenerated from
the docstring that names job_args.py.
2026-11-16 17:43:16 +05:30
alt-glitch
7defffc296 fix(lint): clear the findings ruff preview reports
Turning on ruff preview (needed for PLW1514, unspecified-encoding) also
widens some stable rules. Clearing what it reports first lets the config
change that enables it land with no ignore list:

- evals workers: 20 text-mode open() calls get encoding="utf-8".
- a2a and weixin adapters: legacy "# type:" comments become annotations.
- agent/lsp/client.py, gateway/run_turn.py: two prose comments started a
  line with "type:", which type checkers read as a type comment.
- sorted(x)[0] becomes min(x) (plugins_session_env, one test).
- test_plugin_session_fork: the attempts default is built per call
  instead of a shared list inside a tuple.

The pinned ruff 0.15.22 passes with today's config and with preview on.
2026-11-15 14:02:40 +05:30
Teknium
67baa9ef20 evals(child_cache_marker): say the harness builds its own tail 2026-11-11 18:30:54 -08:00
Teknium
3a15d4b86a evals(child_cache_marker): build the per-session tail in the harness
The harness called the delegate prompt builder positionally; that builder is changing shape in #153385. The probe needs any per-session system-prompt tail, so it builds its own.
2026-11-11 18:30:54 -08:00
Teknium
3f05542b8b perf(prompt-cache): put the second system breakpoint before the ephemeral tail
A subagent's per-task text (and a personality) is appended to the session's
system prompt at API time, and the second system breakpoint sat after it. Every
child whose task text differed therefore re-wrote the skills index and footer
to the cache on its first call, although those bytes are identical for all of
them.

The breakpoint now sits at the end of the session prompt. The tail keeps a
breakpoint of its own on calls that have one to spare (a first call has a
single message to mark), so sessions with an identical tail still share it. A
session with no ephemeral tail is planned exactly as before, and the bytes on
the wire do not change for anyone.

Envelope layout and the native layout without a tool breakpoint; the
direct-Anthropic tool-cache layout is unchanged.
2026-11-11 18:30:54 -08:00
Teknium
69677b5829 fix(delegation): pin the child's brief through compaction; context first as a cacheable prefix
Review findings from unsupportedpastels and kshitijk4poor:

- A steered child lost its brief at its second compaction. The compactor stops
  protecting early turns after the first pass and restates the newest real user
  turn, which after a steer is the steer. A delegated child's first user turn
  is its whole brief (goal, context, output contract), so it is now always
  protected (ContextCompressor.pin_task_turn, set on every child). The head
  window methods move to context_compressor_window.py with it.
- Siblings given one context stopped reading it from cache: the goal came
  first, so the shared bytes started after the first difference. The first user
  turn is now "CONTEXT: ... TASK: <goal>", and the context is registered as the
  message's stable prefix, which gives it its own cache breakpoint on marker
  routes. Every brief is registered: a parent often sends one brief in separate
  calls, which a per-call "shared" test cannot see.
- Stale docs and comments that still placed the context in the system prompt.

Co-authored-by: unsupportedpastels <unsupportedpastels@users.noreply.github.com>
Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
2026-11-11 18:29:48 -08:00
Teknium
e78a8c1ee5 evals(sibling_prompt_cache): score the context instruction literally
The reply must end with the marker; trailing punctuation or markdown no longer passes. The 36 retained replies all pass the literal rule.
2026-11-11 18:29:48 -08:00
Teknium
180d5877a7 fix(delegation): keep the contract on schema retries; isolate siblings that fall back to xAI
Review findings on the sibling cache change:

- The schema-correction turn started a fresh conversation and relied on the
  output contract being in the child's system prompt. The contract now rides
  the first user turn, so the retry continues that conversation.
- The slot-keyed exception ran only when the child was built. It now runs when
  the scope is resolved, so a child that falls back onto xAI returns to its own
  scope instead of sharing one conversation slot with its siblings.
- The /review gateway test matched the reviewer's first user turn exactly; it
  now carries the command's context after the goal.
- The eval scored a context instruction ("end your reply with X") by
  containment; it now requires the reply to end with it and keeps the reply tail.
2026-11-11 18:29:48 -08:00
Teknium
e7ff451652 perf(delegation): sibling subagents share one prompt prefix and cache scope
Providers that cache automatically match only inside the scope the client
sends, and only up to the first byte that differs. A child's task context sat
in its system prompt, which OpenAI-family models render ahead of the tools, and
on the Codex backend each child sent its own session_id header, the scope that
backend caches under. So every subagent paid full price for the prefix all of
one parent's children share.

- The goal and its context are the child's first user turn; the child system
  prompt carries nothing per-task, so siblings send identical system prompts.
- One parent's children share a cache scope of their own (sub_<hash of the
  parent's scope>), which keys prompt_cache_key and, on the Codex backend, the
  session_id header. Skipped on slot-keyed routes (xAI), where two streams
  under one key evict each other.

Claude children gain too: the cache breakpoint at the end of the system prompt
now covers bytes every sibling sends.
2026-11-11 18:29:48 -08:00
Teknium
60f81635c2 fix: keep the connection card and the MCP hint when manage_connections is deferred
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Review findings on the default flip:

- Desktop: a card tool reached through the tool_call bridge is stored as
  `tool_call`, so after a reload or resume the connection card became a generic
  row (and a resumed open card was duplicated). Hydrate bridged card tools
  under their own name, as their live part is already named. Also covers the
  already-deferred manage_catalog and image_generate. Tested patch from
  BearHuddleston.
- When the catalog falls back to names only (or listing is off) the reworded
  catalog line never reaches the model. The bridge hint now names both jobs.
- Eval harness: every arm pins its first sentence (the tree default is now the
  reworded one, which made A/D and B/C identical), bridge refusals with other
  wording are counted instead of dropping the cell, the interpreter path is
  shell-quoted, the real Hermes home is hidden wherever HERMES_HOME points, and
  the dry cell fails on any visible credential file or reachable host.
- The readout states the decision and the mcp_setup_github limit.

Co-authored-by: BearHuddleston <BearHuddleston@users.noreply.github.com>
2026-11-10 23:20:02 -08:00
Teknium
6535200cfa docs(evals): record the manage_connections deferral follow-up readout
528 cells, three models, four arms. Deferred fails the pass bar on every
model with and without the reworded catalog line; the tool stays eager.
2026-11-10 23:20:02 -08:00
Teknium
e5e5090fb8 test(evals): sandboxed three-arm battery for deferring manage_connections
Extends evals/tts_connections_deferral to answer one question: can
manage_connections sit behind tool_search without hurting usage, accuracy,
calls or total tokens? No default changes; the reworded catalog sentence is
applied inside the eval worker only.

- worker.py: arms A-D on one tree (eager / deferred / deferred + reworded
  first sentence / eager + reworded), three more MCP-install phrasings, a
  second negative, a wrong-route tally, a raising backstop on the real
  connection backends, a no-model `__dry__` proof cell, and a cell root that
  no longer carries the arm name.
- battery.py: runs every cell in bubblewrap with its own network namespace,
  /home, /tmp, /run and /mnt masked, and prints the per-arm pass bar.
- relay.py: the one network exit; forwards /v1/ to the inference host and
  holds the agent key outside the cell.
2026-11-10 23:20:02 -08:00
Teknium
9e15361818 test: add the schema_dedupe live A/B harness and its reference run
Seventeen tasks on real AIAgents from two checkouts: a nearly full memory
store (batch remove+add, no repeat), which store a fact goes to, procedure
to skill, manage_connections target shapes (hosted vs MCP, second-account
alias, forced reconnect, no re-ask after a skip, no disconnect), and
no-regression passes on search_files and terminal. memory, skill_manage,
search_files and terminal are real; manage_connections is stubbed behind
its real validation.

Reference run (2026-11-09): anthropic/claude-fable-5.2 57/57 on main and
57/57 on the branch; qwen/qwen3.8-27b 151/153 and 151/153. The README
lists the traps the harness fell into while it was built.
2026-11-10 20:13:57 -08:00
Teknium
5d74914538 feat: defer text_to_speech behind tool_search by default
The text_to_speech schema costs 577 tokens on every request (1,245 with the
ElevenLabs variant) and most sessions never speak. A live A/B on Fable 5.2
and qwen3.8-27b reached it 12/12 on both arms with valid arguments on the
first call, so it joins the default tools.tool_search.defer list. Net saving
is 557 tokens per request after its 20-token catalog line.

manage_connections was tested in the same battery and stays eager: deferred,
the weak model installed an MCP server through the terminal instead of
finding the tool (3/3 -> 0/3).

A deferred producer is recorded under the bridge name, which two gateway
paths did not expect: the auto voice reply would speak a second time after a
bridge-called text_to_speech, and the audio (or image, or computer_use
screenshot) of a bridge-called producer was not attached to the reply.
tool_name_by_call_id now resolves a single-entry tool_call to the tool it ran.

Harness and readout: evals/tts_connections_deferral/.
2026-11-10 20:05:34 -08:00
Teknium
56a2d7b040 fix(delegation): the joined delegate_task variant asks for no delivery group
One-shot and inline-gateway sessions join every task inside the call, so a
`group` never changes delivery there. With independent_completions on, the
previous commit made that do-nothing field required on those surfaces too.
Drop `group` from the joined variant; the handler still accepts it.

Also give the eval runner's wall-timeout record its `kind`, so a timed-out
cell stays in the class tables instead of dropping out of the denominator.

Both from review by BearHuddleston, whose tested patch this applies.

Co-authored-by: BearHuddleston <BearHuddleston@users.noreply.github.com>
2026-11-10 01:06:30 -08:00
Teknium
0a073ef715 test(evals): delegation grouping A/B results and one more task
Adds the implicit "table when it is done" task, drops model prose from the
per-cell records, and checks in the validating run: 84 cells, base
e0f07847b8 vs 84d1c1a3a7a3, parents Fable 5.2 and gpt-6-luna.
2026-11-10 01:06:30 -08:00
Teknium
0b276a7ac4 fix(delegation): make the result-delivery choice explicit, trim the schema
With delegation.independent_completions on, a multi-task call returned one
message per task unless the model named a `group` on every task. The only
guidance was a parenthetical in the description and an optional nested
field, so a parent that meant to answer once after all children finished
left the field out and was woken once per child, spending a filler turn on
each result.

The independent variant of the schema now marks `group` required on every
task and states the choice and its cost where delivery is described: the
same group on every task when the parent responds only once all are done,
a task's own group only when its result is acted on as it lands. Runtime
delivery is unchanged: a task that arrives without a group is still
accepted and still reports alone, and the default (option off, one message
per call) builds the same schema as before minus the duplicates below.

Also folds in the rule-preserving dedupe of the description and parameter
docs (opening sentence, `tasks`, `goal`, `action`, "Optional" markers that
repeat the JSON structure).

Adds evals/delegation_grouping, a live A/B harness with a real parent and
real background children scored on delivered completion units.
2026-11-10 01:06:30 -08:00
unsupportedpastels
6835dd55da refactor(gateway): read turn timestamps, overflow queues and stale approvals from SessionState
Drop the _running_agents_ts, _busy_ack_ts, _queued_events and
_pending_approvals legacy dict views from GatewayRunner. The stall
watchdog, shutdown flush/cleanup, /agents and the stale /approve-/deny
path now read SessionState directly (peek, never creating a row), and
tests set SessionState fields instead of the views.
2026-11-09 23:04:25 -05:00
kshitijk4poor
49165bcaff fix(aux): retry, fallback and refresh decisions come from classify_api_error
The auxiliary client decided every recovery step (same-provider retry,
credential refresh, pool rotation, unhealthy mark, provider fallback)
with private substring predicates and consulted classify_api_error only
to label telemetry. The logged reason and the action taken could
disagree, plugin transform_api_error_classification hooks and
ProviderProfile.classify_api_error overrides never steered an aux
decision, and the tables had drifted from the main loop's.

What changed:
- Each failed request is classified once, on the backend, model,
  endpoint and credential it was sent with (_classify_failure): the
  primary, a same-provider retry (its rebuilt client and model), a
  refreshed Nous client or healed
  model, a parameter-rung or backoff re-send, and a fallback candidate
  (its effective provider or destination; an async candidate classifies
  on the sync client it was converted from). The streamed-negotiation
  and affordable-402 checks classify on the same attempted provider,
  passed in by the caller. Every later rung reads the
  resulting Failure (error, verdict, whether a parameter rung's detector
  names the rejected field). A request boundary that already classified
  (a rebuilt same-provider retry, a judged stream negotiation) raises the
  typed _ClassifiedAttempt carrying its Failure, and recovery reads that
  instead of classifying again. The relay logical call records each
  failed attempt with the ladder's Failure for it and reports that
  verdict at close (one classification only when no verdict exists):
  classifier hooks fire once per failed request.
- The primary's retries, the candidates' parameter rungs and the ladder
  driver handle a failure after its except block ends, so a retry's own
  failure is classified as itself instead of through the previous
  error's context. The stream watchdogs raise their timeout from None.
- agent/auxiliary_error_policy.py (new): small pure functions over the
  verdict (same_provider_retry, auth_refresh, same_key_retry,
  benches_provider, fallback_label, ladder_accepts,
  stream_negotiation_reraises).
- The sync and async fallback-candidate helpers share one generator.
- context_compressor classifies a summary failure once; its
  session-preserving abort keys on the verdict's transport fact.
- The parameter rungs return a _ParameterRepair NamedTuple whose
  repaired flag tells provider fallback a rung changed the request.
- Deleted: the private _is_*_error predicates, _credential_rung_accepts,
  _FALLBACK_REASONS, the keyword tables, fallback_candidate_unavailable_
  reason and agent/auxiliary_error_shapes.py.

Behaviour changes:
- Transient failures (5xx, 408, overload, timeouts, connection failures
  incl. DNS/ECONNREFUSED and SDK transport classes) retry the same
  provider, then fall back.
- A missing model falls back on every route; a 404 free-tier body falls
  back; 400-coded billing and rate-limit bodies bench / rotate and fall
  back.
- RESOURCE_EXHAUSTED on a 429 is a rate limit unless it names a daily or
  weekly window, which is billing and benches the provider.
- An OpenRouter-wrapped upstream 429 and a 429 "overloaded" do not rotate
  a healthy key; a 429 naming a rate limit and a billing phrase stays a
  rate limit.
- A generic 403 falls back (auto routes; an explicit provider only with
  its task fallback_chain) without a credential refresh.
- Account gating of the model rotates (model-scoped) before falling back;
  a feature restriction falls back without touching the key.
- A rejection naming a request parameter with no applicable rung
  re-raises (primary and candidates); after a spent rung it falls back.
- A verdict with retryable=False skips the same-provider retry and the
  same-key rate-limit backoff; a plugin or profile verdict with
  should_fallback=False never reaches provider fallback. A verdict that
  is neither retryable nor should_fallback (data_policy_denied, the
  model's malformed tool-call arguments) re-raises even after a
  parameter rung changed the request: another provider would get the
  same content.
- An InterruptedError (a cancelled Codex stream) stops the call: no
  retry, no fallback.
- A missing or route-refused model on a fallback candidate quarantines
  that model only (model-scoped unhealthy key); siblings on the same
  provider stay eligible. The key holds the provider-normalized model,
  so a configured name and its resolved form (gpt-x / openai/gpt-x)
  match, and the discovery chain skips a hidden resolved model too.
- Aux pool selection (_select_pool_entry, _peek_pool_entry and the
  OpenRouter, Codex, Anthropic, xAI OAuth, plugin OAuth, named custom
  and API-key builders) passes the requested model, so a model-scoped cooldown on a key does not hide
  it from sibling models; CredentialPool.peek takes model= like
  select.
- 429 then a generic 403 on an explicit provider with no task chain
  re-raises the 403.
- Plugin and provider-profile classifiers steer every aux decision.

Tests: tests/agent/test_auxiliary_error_policy.py drives call_llm end to
end over one table of the behaviour decisions, plus regressions for a
failure after a 401 refresh, 429-then-403, retryable=False, OpenCode Go
classification (sync and async), a refreshed candidate's bad answer, a
Nous SSE error after refresh, a terminal verdict after a spent
parameter rung, one hook call per failed request (primary, retry and
candidate; streamed and plain, sync and async), TLS failure and a 502 connection reset in
compression, plugin overrides, an interrupt, a pinned custom provider's
model-scoped rotation, a candidate's model-scoped quarantine under its
resolved name, a sibling model keeping a pooled key, and a rebuilt
retry classified on its own model. Tests of
the removed predicates are deleted; ladder-internals tests are adapted
to the Failure tuple.

Part of the Code Health plan.
2026-11-08 13:18:54 +05:30
Maciej Lisiewski
c338036bf6 fix(pm): name a missing pnpm pin; keep npm's cache query out of the checkout
node-deps.mjs failed with a raw ENOENT/TypeError when pm/lock.json was
missing or pinned no pnpm; it now names the file and the field.
setup_toolchain.py keeps running `npm config get cache` outside the
checkout: a project package.json or .npmrc in cwd can change or fail it,
not only warn. The alignment test whose pnpm assertion went with
devEngines duplicated PM's lock validation and is gone with its type.
2026-11-07 00:45:52 +01:00
Maciej Lisiewski
d62c60787f fix: pnpm review follow-ups in nix, evals, the hang repro and an e2e test
- nix dev shell: pnpm-workspace.yaml (overrides, catalog, allowBuilds)
  joins the package.json stamp, so a settings-only change relocks.
- desktop-pane-fixture: resolve vitest/config from apps/desktop; pnpm
  links it only there.
- short-session hang repro: name the lockfile in the target metadata, so
  an npm-era target fails as a lockfile mismatch rather than a bare hash.
- test_mirrors: the pnpm mirror test prefetches from the registry and
  needs allow_network, like its siblings.
2026-11-06 04:08:46 +01:00
Maciej Lisiewski
29e78b124e docs: pnpm commands for the JS workspaces
READMEs, contributor guides, AGENTS.md files, skills and the website (with
the zh-Hans translations) give pnpm commands for the workspaces; the
website itself is still an npm project.
2026-11-06 04:08:45 +01:00
Maciej Lisiewski
7062229090 chore(js): switch the workspaces from npm to pnpm
pnpm 12.15.0 (native executable) installs every JS workspace from one
pnpm-lock.yaml, imported from package-lock.json with the same resolved
versions. website/, the WhatsApp bridge and the photon sidecar stay separate
npm projects.

Configuration moves from .npmrc and the root manifest into
pnpm-workspace.yaml: the 14-day minimumReleaseAge and its excludes,
overrides, allowBuilds (the old allowScripts set, with strictDepBuilds
failing any unlisted build script), engineStrict, sideEffectsCache: false
(in-place rebuilds must not write into the store) and
verifyDepsBeforeRun: false (a `pnpm run` never installs).

The pnpm version is pinned in pm/lock.json and in root devEngines.
pmOnFail: ignore keeps that pin out of pnpm-lock.yaml: a leading pin
document makes osv-scanner read zero packages. scripts/build/node-deps.mjs
enforces the exact version instead, and every lock reader refuses a
multi-document lock. A root preinstall refuses `npm install`; devEngines
onFail is warn so npx (MCP servers, the tsc linter) keeps working inside
the checkout.

User-machine installs run --frozen-lockfile --trust-lockfile (release age is
checked when locking, in CI, not per user). node-deps removes npm-era
node_modules trees before the first pnpm install. Nix builds the store with
fetchPnpmDeps and a hash file that CI checks.
2026-11-06 04:08:24 +01:00
unsupportedpastels
936f3465f8 refactor(cli): remove the unused one-shot agent that ran outside the gateway
`hermes -z` has run through the gateway (`_run_oneshot_from_args` ->
`launch_gateway_chat`) at every dispatch site for a while, but the old
in-process runner stayed behind: `hermes_cli.oneshot.run_oneshot` /
`_run_agent` built a bare AIAgent outside the session authority, and
`hermes_cli.main._run_and_exit_oneshot` (with its
`_cleanup_oneshot_runtime` cleanup table) was its only caller. Nothing
outside tests reached any of it.

Delete that path. `hermes_cli.main._exit_after_oneshot` stays exactly as
it is: `--cpu-profile` names it as the one-shot hard-exit path and it
writes the profile before `os._exit`; only its docstring loses the
pointer to the removed cleanup helper. `hermes_cli/oneshot.py` keeps
only what the gateway path and gateway CLI turns still import: the
exit-code mapping, the `--usage-file` ledger with its auxiliary-usage
delta, and `--toolsets` normalization. The process-receipt eval probe
now calls `process_registry.wait_for_pending_completions` directly.

Tests that only exercised the deleted runner are removed; the exit-code
and usage-file tests now call the kept helpers directly; the cost-guard
test patches the gateway launcher instead of the removed function. A new
test pins that `hermes -z` dispatches to `launch_gateway_chat`.

Refs #145171 (EP-11a)
2026-11-05 17:59:21 -05:00
Maciej Lisiewski
9f9b9f54a1 fix: review follow-ups for the workspace dependency moves
- The MCP OAuth renderer probe bundled its entry with esbuild resolving from
  the checkout root, so its react, react-dom and react-query imports still
  relied on hoisting. Resolve them from apps/desktop, which declares them
  (verified: from the root they fail to resolve in an isolated pnpm tree).
- The Windows MSIX commit fixture linked node_modules before `git add apps`,
  so the commit could pick up the dependency link. Link the install trees
  after the commit, which needs only the fixture's own files.
2026-11-05 14:08:26 -08:00
Maciej Lisiewski
c2a0ecc734 fix: resolve electron, vite and playwright from the workspaces that declare them
Scripts outside the declaring workspace found these through the hoisted root node_modules:
mock-server and connector-rehearsal (whose desktop-local Electron path did not exist under npm),
ui-tui's visual harness, the eval harnesses, and the tests/install/e2e-assets drivers, which import
tests-js's @playwright/test and zod. They now resolve from apps/desktop or tests-js; the typed
e2e-assets files go through a tests-js re-export module so their types resolve the same way.
2026-11-05 14:08:26 -08:00
Teknium
b4d7128975 test(cron): the fork-race probe waits for killed descendants to exit
test_cron_timeout_closes_the_descendant_snapshot_fork_window read each
descendant's status the instant _run_job_script returned. SIGKILL is
asynchronous: the killed process stays in state R until the kernel
finishes tearing it down, and freeing its memory waits for a CPU on a
loaded runner. CI caught the pre-existing setsid child there
({gone, running, zombie}).

The kill was delivered. A scratch dump at the check showed the "running"
child in state R with SIGKILL pending (ShdPnd 0x100) and PF_EXITING set,
and it exited 86-233 ms later. kill_process_tree is correct.

The probe now waits up to 10 s for every recorded descendant to be gone,
a zombie or dead (the transient X state while its parent reaps it). The
children now sleep 60 s instead of 15, so a descendant the kill missed
is still alive when the wait ends and the probe still fails.

Repro: give the first child 1.5 GiB of touched memory, so its exit takes
~100-200 ms. Base fails 12/12 with CI's shape; the fixed probe fails
0/12. The fixed probe still fails when the fork-window stop+rescan is
reverted, and when snapshotted descendants are never signalled.
2026-10-25 04:45:42 -07:00
Teknium
e82c354b28 fix(evals): desktop eval probes find pm's Chromium through PLAYWRIGHT_BROWSERS_PATH, not the retired AGENT_BROWSER_EXECUTABLE_PATH 2026-10-23 01:43:16 -07:00
Teknium
68500d9ff9 refactor(browser)!: delete the built-in browser_* tools, agent-browser and bundled Camofox
browser_exec is the only core browser tool (plus browser_cdp, browser_dialog,
browser_vault, all CDP). Deleted: browser_navigate/snapshot/click/type/
scroll/back/press/get_images/vision/console and every module that served
them (browser_tool_session/_lifecycle/_cloud/_cdp/_real_profile/
_lightpanda_fallback/_eval_policy/_origin/_snapshot/_vision) plus
browser_camofox*.py (Camofox ships as the catalog plugin 'camofox').
tools/browser_tool.py and tools/browser_tool_install.py shrink to the
frozen old-updater stub warm_agent_browser_npx_cache.

toolsets: _HERMES_CORE_TOOLS / browser toolset list only the CDP tools.
model_tools: browser_tools legacy alias and the browser_navigate /
browser_type schema rewriters removed. Cloud providers no longer request an
install post_setup hook (nothing to install).
2026-10-23 01:41:24 -07:00
Teknium
d7db4d109d refactor: OpenClaw migration leaves core too; first-time setup offers the agent-importers plugin
`hermes claw` (hermes_cli/claw.py) and the openclaw-migration optional skill
moved into the agent-importers plugin (hermes-official-plugins #140/#141), which
keeps `hermes claw migrate|cleanup` as the older spelling of
`hermes import-agent openclaw`. Core drops them with their tests (ported to the
plugin) and the eval leg that loaded the skill's script.

Setup: hermes_cli/setup_agent_import.py replaces setup_migration's OpenClaw
offer. On a first-time `hermes setup` it checks ~/.openclaw (or ~/.clawdbot /
~/.moltbot), ~/.claude, ~/.codex and ~/.cursor; when any is found it asks
"Import your setup from <found>?" (default yes), shows a checklist when more
than one was found, installs agent-importers through the normal catalog install
(or enables it when present), then runs `hermes import-agent <agent>` for each
pick in a child process, which previews and asks first. OpenClaw gets
--migrate-secrets, as core's step did. Nothing found, a no, or
HERMES_NONINTERACTIVE: no prompt, nothing installed. The skip-configured-section
offer now follows any import that changed config.yaml or .env.

LEFT_CORE: `claw` joins the agent-importers row as old_cli, so `hermes claw`
without the plugin names the install. No automatic install for it: an OpenClaw
migration is one-shot and leaves no state that needs the plugin later.

Docs: import guide, OpenClaw guide, cli-commands, quickstart, bundled
cli-reference; locale tips and README pointers.
2026-10-22 11:22:12 -07:00
kshitijk4poor
9ca23c6840 fix(cli): run every /cron form on the gateway that owns the cron store
Symptom: in a classic `hermes chat` session on the shared gateway, /cron
add|edit|pause|resume|run|remove still ran main's handler in the CLI
process, which called the cronjob tool there and wrote the profile's
cron/jobs.json from the client. Under strace, every write to jobs.json
came from the `chat --cli` process and none from the gateway.

Root cause: the one-gateway runtime (#106742) made the gateway the
owner of the profile's runtime state and of the ticker that fires cron
jobs. It left CLICommandsMixin._cron_* in the client, and the
gateway's slash.exec refused /cron for every local session except TUI
reads (2efe028116). That left the cron store with two writers.

Change:
- Move main's /cron handler (overview, list and every write) into
  hermes_cli/cli_cron_lines.py as line builders (cron_command_lines),
  with no other behaviour change. The CLI prints them when it has no
  gateway session. The unused CLICommandsMixin._cron_list goes; its
  test and eval read cron_list_lines directly.
- On the gateway, /cron is an owner command
  (gateway/session_cron_commands.py). Bare /cron and `list` are reads
  for every local session; that includes Desktop- and ACP-created
  sessions, which main refused with unsupported_command. Every other
  form is an admission-fenced control. An unclosed quote is refused as
  invalid_params before pre_command fires. `/cron list -a` keeps the
  list-all alias that the TUI read path accepted.
- A /cron write runs only when it arrives on a connection that is not
  attached to the session: the classic CLI's own command socket
  (GatewayConnection.call_until), which waits with no deadline. A
  connection attached to the session keeps main's unsupported_command.
  That is how Ink, Desktop and ACP send /cron: on their main
  connection, which the gateway answers one request at a time and
  which waits with a deadline, while a /cron run lasts as long as its
  job. The gate is on the requesting connection, not on the surface
  that created the session, so a classic CLI that resumed a TUI-made
  session still writes (as on main), and Ink on a CLI-made session is
  still refused.
- The classic CLI sends /cron to slash.exec
  (gateway_setting_commands.GATEWAY_SETTINGS) with no deadline, on a
  socket of its own (gateway_plugin_commands.call_unbounded, now shared
  with plugin commands; its Ctrl+C handle is renamed
  _gateway_command_wait). Ctrl+C prints the stopped line and
  propagates.
- Regenerate the parity table. test_pre_command_in_gateway pinned the
  old refusal of every classic CLI /cron; it now pins that the accepted
  /cron forms fire pre_command once and a refused one (an unclosed
  quote) fires nothing.

Why: the design contract allows one writer per owned store, and
clients only read and submit. The gateway already serves this
profile's cron store to its ticker and to Desktop (cron.manage). Now
the classic CLI's writes go through the same process.

Refs #134889 (T1)
Refs #139158
2026-10-20 13:08:24 +05:30
Maciej Lisiewski
91fae5f8cb ci: run everything on blacksmith.sh runners 2026-10-15 05:23:46 -07:00
Teknium
0715474bfd Merge origin/main into feat/unified-gateway-runtime
375 commits from main (0e427d788d). 24 files conflicted; the resolutions that carry a decision:

- /initiate-setup: main removed the command (25bf722063). Its gateway rewrite, CLI handler and the
  Desktop kickoff go with main; this branch's command-layer admission of it is dropped too
  (gateway/session_commands.py _PROMPT_COMMANDS, its slash.exec test row, the parity doc row), and
  the Desktop slash dispatcher loses the `hidden` option that only the kickoff used.
- Code this branch moved out of its old file, carrying main's edits to the moved copy:
  first-contact notes (gateway/run_turn.py -> run_turn_prepare.py: no message/setup_command),
  the TUI agent factory (tui_gateway/server.py -> agent_factory.py: onboarding toolsets at build,
  setup_beat/set_theme lifecycle cards, no cli platform extras on a coding selection), the serve
  lifespan (web_server.py -> web_server_app.py standalone_lifespan: first-install probe before the
  state.db reconcile, onboarding due answer after the setup bootstrap), and the compression child
  publish (the shared _publish_compression_child_on_conn reads the parent's model_config).
- agent/auxiliary_client.py: both import changes (_route_key from main; this branch's move of
  _without_structured_output_format).
- Desktop: main's onboarding run (decideOnboarding, OnboardingEnd, card-waiting Send) replaces the
  kickoff; this branch's prepared-submission slash path, request_id on session.create and
  PreparedImageRecovery stay. Pool-limits imports are dropped (this branch removed the pool).
  createBackendSessionForSend takes main's (preview, overrides) signature.
- ci.yaml detect job: main's `ref: inputs.commit` plus this branch's sparse checkout.
- package.json / lock: main's vitest 4.1.11 plus this branch's ws 8.21.1.
- Generated: gateway-contract.openrpc.json regenerated; parity doc regenerated.
2026-10-14 05:52:49 -07:00
alt-glitch
72e7085e9e feat: set_theme replaces apply_layout and reports what the desktop applied
set_theme (desktop_ui, deferred like apply_layout was) sets the accent,
light/dark mode and layout preset, or with `picker` shows an accent or
layout card and waits up to 300 s. apply_layout emitted a layout.apply
event and returned success whether or not the renderer applied anything;
set_theme asks the renderer through the theme.apply server request and
returns its answer, so an unknown preset or a chat that is not on screen
comes back as an error with the available ids.

theme.pick waits for a person; the backend tells a dismissed card
({cancelled}) from an expired one ({timed_out}). The tool description
lists the Simple and Advanced preset ids from one constant, which fixes
the old description that named neither sidebar preset. The layout.apply
event and its renderer handler are deleted with the tool.
2026-10-13 23:55:10 +05:30
Teknium
a89f374d7c Merge origin/main (#45: 255 commits to 3b63f7b0a4) into feat/unified-gateway-runtime
Conflicts (2 files, 1 hunk each); every main-side change is kept, ported to
where the branch moved the code:

hermes_cli/kanban_db.py (build_worker_context helpers _ctx_cap .. _ctx_comments)
  main:   f5a6651231c/d56e357556f coerce foreign/text timestamps on read; in
          _ctx_role_history the "Recent work" stamp became
          _ctx_stamp(_to_epoch(row['ended_at']) or 0, now) instead of int().
  branch: moved the whole _ctx_* helper block into hermes_cli/kanban_db_context.py
          (kanban_db.py imports it back), deleting it from kanban_db.py.
  merged: kept the branch's deletion in kanban_db.py and applied main's change in
          kanban_db_context.py::_ctx_role_history as
          _ctx_stamp(_kb._to_epoch(row['ended_at']) or 0, now). Main's other
          timestamp coercions in kanban_db.py (Task/Run/Comment/Attachment/Event
          from_row, _TASK_EPOCH_COLUMNS, release_stale_claims,
          _extend_live_stale_claim, task_age) auto-merged unchanged.

hermes_cli/web_server.py (_lifespan)
  main:   d7830c6f42 reworded one comment in the free-tier bootstrap block
          ("the ONE place its identity is created" -> "the one boot-time creator
          of its identity"; guests are now also created on first connector use).
  branch: moved _lifespan's body into hermes_cli/web_server_app.py::app_lifespan.
  merged: kept the branch's relocation and applied main's comment rewording in
          web_server_app.py.

Merge-induced health fix (no conflict marker; the combination tripped the ratchet):
apps/desktop/src/app/session/hooks/use-cwd-actions.ts::changeSessionCwd
  main:   63ed3caa4ba/dbc538547fc grew the function (statusbar cwd change for the
          focused chat / tile runtime ids) to CC 20.
  branch: added the session_busy refusal mapping (sidebar.projects.moveBusy) in
          its catch, +1 branch -> CC 21 > target 20 (scripts/check health blocking).
  merged: both behaviours kept; the busy-error mapping moved verbatim into a
          module-level cwdChangeError(err) helper. Health back to 0 blocking.

Check: every line main added between 1fd1827726 and 3b63f7b0a4 (317 files) is
present in the merged tree.
2026-10-12 16:55:20 -07:00
Teknium
2ddbd66ac6 eval(prefix_rediet): tolerate string-encoded tool_call entries in the call tally 2026-10-12 03:18:48 -07:00
Teknium
3bf97898ac perf(prompt): fixed prefix back under the post-diet size (-2.1k tokens per request)
The stock prompt surface regrew ~3.4k tokens after the August diet, almost
all from features added straight into the never-deferred core. This takes
back the biggest pieces:

- browser_vault: the five eager browser_vault_* tools (list, fill, unlock,
  save_login, enter_code) become one browser_vault tool with an action enum,
  deferred behind tool_search by default. It still rides with the browser
  (an empty vault keeps save_login reachable), so discovery holds; only a
  catalog line is paid per request. Results and errors name the new actions;
  the input-tool password note points at it through tool_call.
- terminal: schema re-dieted (1,136 -> 651 Qwen tokens). Description and
  param docs no longer repeat each other; heartbeat / persist_on_release keep
  their rules in one line each; process(...) references name process_manage.
- tool_search / tool_call: the keyword-query rule lives once, in the queries
  param; description and connector hint trimmed.
- system prompt: the "Async handoff" block is removed. Its rule ships in the
  delegate_task description and in the background dispatch result the model
  reads at the moment it matters, and the polling loop it targeted is guarded
  structurally (#124724).

Stock CLI surface (prompt-surface render, chars/4): 18,612 -> 16,524.
Fresh install, Qwen3 tokenizer: 14,962 -> 13,120 (Sep 7 post-diet: 11,595).

Live A/B harness: evals/prefix_rediet/.
2026-10-12 03:18:48 -07:00
Teknium
aefb5b097e docs(evals): the normal-boot probe is expected to pass; drop stale wave notes
evals/shared_gateway/README.md said the "unintegrated bootstrap is expected to fail"
normal_boot.py; this PR integrates it and tests/gateway/test_normal_runtime_boot.py
asserts state == 'ready' from the real control socket. The README now says a pass is
expected and a failure is a regression.

The four worker wave notes (worker-persistence-inventory.md and the -substrate,
-lifecycle-wave22, -constructor-context-wave20 notes; ~2,000 lines) were pinned to
an old snapshot, cited private worktrees and .hermes/plans paths, called worker
switching "still blocked", and nothing links to them: removed from the shipped tree.

Docs only; no test.

Review: ahrazzle B2-28
2026-10-11 19:31:40 -07:00
Teknium
129234cee6 docs(cli): classic chat resumes latest and queues at the gateway
Docs follow code (round-13 ruling for stale docs):
- cli.md said classic `hermes chat` refuses bare --continue and --resume latest
  (exit 2). gateway_chat.wants_latest/_resume_latest resolve both through the owner
  and _UNSUPPORTED holds neither; the developer guide already documents them. The
  refused list also omitted --compact, which _UNSUPPORTED refuses. Examples and the
  info box now match _UNSUPPORTED.
- The busy_input_mode `queue` row said the classic CLI queues in-process.
  GatewayChatView.submit sends every line to prompt.submit, never reads
  busy_input_mode and has no steer/redirect path: classic chat always queues at the
  gateway; interrupt/steer are TUI/Desktop behaviours.

Docs only; no test.

Review: ahrazzle B2-23
Review: ahrazzle B2-24
2026-10-11 19:31:40 -07:00
Teknium
994759f4c4 Merge origin/main (#39: 29 commits to d4d2ab7b5d) into feat/unified-gateway-runtime
No conflicts. Brings in main's reasoning-replay series, holographic memory leaving core
(run_profile_reconcile now imports it through import_provider_module), and the update
main-channel fix.
2026-10-10 23:38:42 -07:00
Teknium
655546246c chore: strip the trailing blank lines at EOF that git diff --check flags
Eight files the branch adds ended in one or more blank lines, so
`git diff --check $(git merge-base HEAD origin/main) HEAD` reported 8 "new blank line at EOF"
errors. Whitespace-only: each file now ends with exactly one newline; no other line changes.

Check (8 errors on r11-base, 0 here): git diff --check c57331677d HEAD

Review: andrexibiza 24
Review: andrexibiza 5479692359-P2.10
Review: JoaoMarcos44 diffcheck
(cherry picked from commit 6b34c53b7041b037431405282a6fb2d76f657893)
2026-10-10 22:49:21 -07:00
Teknium
87da183a8a refactor(evals): split reasoning-replay summarize into per-cell helpers
Keeps the matrix byte-identical while meeting the code-health CC/nesting
targets, and narrows the network catch to the errors urlopen can raise.
2026-10-10 20:49:30 -07:00
Teknium
7a70cbd0db fix(evals): reasoning-replay treats Anthropic refusals like xAI 403s
Anthropic answers a probe that asks about "earlier reasoning" with a 200
content_filter refusal and no usage block, which left cross-turn cells
without a baseline. Both refusal shapes now rerun the cell with neutral
wording, and opaque cells pick the newest turn-1 capture per position so a
partial rerun does not mix captures.
2026-10-10 20:49:30 -07:00
Teknium
2d1077b001 fix(evals): reasoning-replay harness measures opaque carriers reliably
Newer OpenAI/Gemini models emit no reasoning on a trivial turn 1, so step 2
had nothing to replay; turn 1 now poses a small arithmetic task and escalates
effort until a reasoning carrier and tool call come back. Opaque cells are
compared only within one turn-1 capture (run_id), xAI's safety-layer 403 on
"earlier reasoning" falls back to neutral probe wording per cell, xAI
cost_in_usd_ticks is read as billed cost, and keyless local servers cost $0.
2026-10-10 20:49:30 -07:00
Teknium
cb4342c238 feat(evals): reasoning-replay consumption harness
A 200 only proves a provider accepted a replayed reasoning field; the gateway or
chat template may still drop it. This stdlib-only harness measures whether each
carrier (reasoning_content / reasoning / reasoning_details / Responses reasoning
items / Gemini thought parts and signatures) reaches the model's prompt: the
prompt-token delta against a byte-identical baseline, plus canary recall, for
in-loop and cross-turn positions, and real turn-1 opaque carriers replayed
verbatim vs stripped. Portal calls are keyed by lane (gen- = OpenRouter) and
can be resampled until a direct-lane result exists. Results stay out of tree.
2026-10-10 20:49:30 -07:00
Teknium
e1a10b0bc2 ci: bring the branch's own code under main's strict ruff config
Main made the strict ruff config the default (`ruff check .`, blocking), and
the branch's code carried 278 findings under it (main itself is clean). Fixed:

- PLW1510 (86): `check=False` on each subprocess.run, preserving behaviour,
  as main's own sweep (0006a5e229) did.
- ASYNC220 (9, test fixtures only): `noqa` with the reason, main's convention
  for a Popen that returns at once and whose handle the test drives.
- ruff's safe autofixes plus the narrow unsafe ones (UP006/UP037/RUF100/RUF013/
  PLR0402/RUF059 underscore renames/UP031/UP041/UP017/FURB167/PIE807/RUF007/
  RUF015/RUF022/FURB162), and by hand: four %-formats to f-strings, three
  unused unpacked names, one fixture loop over `.items()`.

No behaviour change. `ruff check .` passes; scripts/check passes; the 412 test
files mirroring every edited file pass (3 tests/pm files that fail only under
that batch's uv lookup pass solo, before and after this commit).
2026-10-10 17:59:08 -07:00
Teknium
b1ccce898b Merge origin/main (#38: 70 commits to c57331677d) into feat/unified-gateway-runtime
Conflicts: tests/hermes_cli/test_finite_chat_delegation.py and
tests/tools/test_completed_process_results.py, where main's lint sweep (0006a5e229) added
check=False to subprocess.run calls this branch had rewritten. Kept the branch's test bodies
and carried check=False onto their subprocess.run calls.
2026-10-10 17:47:35 -07:00
Maciej Lisiewski
c57fbf4584 ci: fix remaining ASYNCXXX linter errors 2026-10-10 15:20:14 +02:00
Maciej Lisiewski
bda3aea496 ci: remove unused variables (linter) 2026-10-10 15:20:14 +02:00