Commit Graph

415 Commits

Author SHA1 Message Date
Teknium
1c4cbb2222 Merge remote-tracking branch 'origin/main' into copilot-seams/integration 2026-10-26 00:40:32 -07:00
Teknium
49f5de617e fix(left-core): only a turn someone sees claims kept migration notices
Every AIAgent's _load_tools ran recover_at_startup(say=agent._emit_startup_warning), which claimed the
home's kept notices. Cron runs, subagents, the curator, kanban workers and background-review forks have
no notice_callback, so the notices were parked on an agent nobody watches and dropped; a cron tick
after a gateway start usually beat the user's next message.

Agent init now only runs the migration and keeps its outcomes in the home. The turn start
(deliver_kept_startup_notices) claims them when the turn has a real sink: the CLI's print sink, or a
driver's notice_callback (gateway chat, Desktop/TUI), and not for an unattended turn
(side_question_lease.is_unattended_turn: fork, cron, delegated child) or suppress_status_output.
The restart-the-gateway hint was gated on having a sink; it is now gated on not being the gateway's
own start (recover_at_startup(gateway_start=True)), so an agent-start install still carries it.
2026-10-26 00:32:14 -07:00
Teknium
70d31a5a5d fix(agent): only the first attempt of a user turn carries user attribution (billing parity)
53a51a49cc made every attempt of a user turn's first API call (429/5xx retries, fallback
activations) re-send the provider's user_initiated request headers. Hermes has always sent them
on the first attempt only (retries went out with the route's default), and that difference is
billing-visible (premium-request initiator headers), so it is reverted: the first payload built
in a user turn consumes the flag and is the only user-initiated one.

Kept from 53a51a49cc: the flag is consumed exactly once whatever the route answers, so a route
without attribution or a failing request_headers hook never leaves it set for a tool-loop
follow-up.
2026-10-26 00:32:11 -07:00
kshitijk4poor
fb4cc3bd68 refactor(agent): move the compression banner and Codex autoraise notice into a sibling
_emit_compression_summary and the once-per-profile Codex gpt-5.x autoraise
notice helpers move unchanged from agent/agent_init.py to
agent/agent_init_compression_notice.py, so the prepared-compaction flag can
land in agent_init without growing the file past its ratchet cap.
2026-10-25 22:55:11 -07:00
Hugo Alves Pereira
32a636bc8d feat(agent): opt-in prepared compaction (compression.prepare_ahead)
With compression.prepare_ahead (default false), once the provider-reported
prompt size is within 12% of the context window below the compaction
trigger, the turn loop starts a background pass before a tool batch runs
and at turn end. The pass plans the same window compress() plans and runs
the same summariser on a copy of the compressor and of the window rows.
The pass itself never rewrites the live transcript, system prompt or
prompt cache; the transcript keeps growing normally meanwhile.

At the next automatic threshold compaction, compress() splices the
finished candidate when the head boundary is unchanged, its boundary is no
later than the fresh tail cut, and the transcript up to that boundary is
unchanged (ignoring what the no-LLM prune rewrites). Messages after the
candidate boundary stay outside the summarized region and go through the
existing tail handling. Everything else, including a pass that has not
finished, manual/focus compaction, overflow recovery and memory-provider
summary context, compacts inline as before. A running pass is never
waited on and loses the right to publish once compaction or a session
boundary overtakes it. A failed pass backs off further passes without
touching the live failure cooldown.

State is per compressor and in memory only. Plugin context engines, Codex
app-server, native Responses compaction, micro-compaction and
background-review forks are not prepared. With the flag off no state is
created and compress() takes its existing path.
2026-10-25 22:55:11 -07:00
Teknium
3562023300 fix(agent): bounded per-request profile hooks and one deterministic failure policy
R4 P2-5 (wire W2).
- replay_message_carriers was asked once per carrier-bearing assistant message
  on every request (O(history) calls, each an IPC round trip under
  plugins.isolation: host). Its answer is now kept per (route, carrier key set)
  as a key mapping and applied to every message with that key set; a hook whose
  answer rewrites values is still asked per message. Contract documented on the
  hook in providers/base.py.
- reasoning_payload and replays_function_thought_signature join request_headers
  / max_tokens_param as memoized pure hooks (argument values frozen, answers
  deep-copied).
- ONE failure policy for every per-request profile hook
  (provider_route_hooks.ask_profile, also behind route_answer): a raising hook is
  logged once per (profile, hook) and answers the generic value; the agent (scope)
  remembers it, so the rest of the session keeps the generic answer and request
  bytes never flip between turns. Before: _supports_reasoning_extra_body
  swallowed per request, _endpoint_reasoning_payload / replay_message_carriers /
  replays_function_thought_signature raised out of the kwargs build, route_answer
  swallowed per call. A failure mid-request reshapes the whole request so it
  matches every later one. One-shot auxiliary calls (no agent) ask again.
- x-initiator turn flag: already consumed before asking the route (53a51a49cc).
2026-10-25 22:22:47 -07:00
Teknium
53a51a49cc fix(agent): per-request provider headers reach the wire
A provider's request_headers(user_initiated=True) answer (turn attribution,
e.g. a premium-billing initiator header) was consumed when the first
attempt's payload was built. A 429/5xx retry or a fallback activation
rebuilds the payload for the SAME API call, so the retried attempt went out
with the route's default (agent) attribution instead of the user's.

The route now claims the call's api_call_count; every attempt of that call
re-applies the headers, tool-loop follow-ups (higher count) do not, and a new
turn / session reset clears the claim.

Repro (fake profile + local HTTP stand-in, scratch probe_xinit.py): first
attempt carries the header, the retry did not (codex_responses 500 retry,
chat_completions 429 retry); both attempts carry it after this change.

The turn flag is consumed exactly once per user turn, before the route is
asked: a route with no attribution, or a request_headers hook that fails
(route_answer swallows plugin errors), no longer leaves it set, which billed
the next tool-loop call as user-initiated (r4-review P2-5).
2026-10-25 21:28:27 -07:00
Teknium
b9712a0c9f refactor(providers): generic wire seams for per-model api_mode, endpoint headers, max-tokens param
Core branched on the Copilot slug/host for four wire decisions. Replace them with
generic ProviderProfile hooks (providers/base.py L1 block) and move the Copilot
logic into plugins/model-providers/copilot/wire.py:

- api_mode_for_model(model, *, api_key=None): run_agent Responses routing, aux
  CodexAuxiliaryClient wrap, model_switch.model_derived_api_mode (copilot rows
  of _PROVIDER_API_MODE_OVERRIDES removed).
- client_headers(*, base_url, api_key, has_images): agent_init/_client_lifecycle
  host tables, the client-kwargs chokepoint guard (_ensure_route_client_headers),
  the image request-client header swap, both aux header branches.
- request_headers(*, base_url, model, user_initiated): first-call-of-a-user-turn
  attribution in turn_api_request and MoA reference slots.
- max_tokens_param(*, base_url, model): run_agent._max_tokens_param and
  auxiliary_max_tokens_param.

agent/provider_route_hooks.py asks the named provider's profile first, then any
registered profile overriding the hook, so custom routes at a provider's host
keep its quirks. Plugin absent = generic behaviour.
2026-10-25 18:23:40 -07:00
Teknium
e75f6675ac fix(agent): a memory provider that is installed but fails to load says so
Agent init resolves the configured provider in one sibling: a parked
provider gets its notice and is never re-installed, an installed provider
that fails to import (a broken install, missing packages) now tells the user
external memory is off instead of only logging, and the unavailable warning
keeps its once-per-home dedup.

Co-authored-by: AIalliAI <285906080+AIalliAI@users.noreply.github.com>
Co-authored-by: Mani Saint-Victor, MD <drmani215@gmail.com>
2026-10-25 03:01:26 -07:00
Teknium
0147e44161 refactor(agent): move memory-provider startup warnings into a sibling
Offsets the agent_init.py growth from the parked-provider notice and the
config-load warnings; mark the three config-fallback handlers as reviewed.
2026-10-25 03:01:26 -07:00
Youngseok Oh
438f19ee9b fix(agent): report independent configuration-reader failures
Cover cache, reasoning echo and section reads with real initialization tests.
Preserve fallback semantics and omit exception values from diagnostics.

Zero × Youngseok Oh
2026-10-25 03:01:26 -07:00
Youngseok Oh
cfe79177a3 fix(agent): warn when agent configuration cannot be loaded 2026-10-25 03:01:26 -07:00
Teknium
ffe2f6411c fix(pm): an update that disables a plugin keeps memory.provider and retries it
When an update had to disable a plugin it also cleared memory.provider, so
the memory provider stayed lost even after the plugin was re-enabled, and
nothing ever retried the plugin: one transient failure (a TLS proxy, a mirror
outage, a since-fixed resolver bug) left it off for good.

- The dependency union now honours plugins.disabled for memory.provider the
  same way the provider loader already does, so eviction no longer has to
  blank the selection. Re-enabling the plugin brings the provider back.
- The eviction is recorded in the home's config under
  plugins.disabled_by_update (was it enabled, and why). Every later update
  retries recorded plugins after the enabled ones and undoes exactly the
  edit once a plugin fits again.
- A user's own enable/disable/remove takes the decision back: PM's selection
  publication forgets the record for the plugin the user settled, and
  `hermes plugins disable` on an update-disabled plugin now writes that.
- Spellings come from the plugin's own manifest instead of a plugin scan of
  the PM process's home, so a profile's plugins are matched in that profile.
- A parked provider is reported, not re-installed: agent init tells the
  user once why external memory is off (naming the update's reason), and
  `hermes memory status` and `hermes doctor` show it instead of "plugin not
  found" or "All checks passed". Doctor lists every update-disabled plugin.
2026-10-25 03:01:26 -07:00
Teknium
8bbf95c85b fix(tools): a one-shot resume still honours a configured clarify disable
Greptile "Disabled `clarify` returns on resume": disabled_toolsets mixes the
caller's configured disables with the automatic session gates, so stripping
every one-shot gate name to carry a pinned clarify also undid a user's explicit
`clarify` disable. The agent now keeps the configured list
(_configured_disabled_toolsets, set at load and on an explicit reload), and only
the one-shot gate's own addition is ignored when judging a carried tool.
2026-10-24 17:31:52 -07:00
Teknium
c422d69189 fix(prompt): one-shot runs drop steering, clarify and delegate live-control; skill-safety rule moves to compaction
Maintainer-approved prompt-footprint trims (measured on the Nous endpoint, anthropic/claude-opus-5.5):

All sessions
- The [SKILL_PRUNED] "Skill Safety Rule" (126 tok) left the system prompt: markers only exist after a
  compaction, so the compaction handoff now carries the rule whenever a marker survives in the
  compacted transcript (context_compressor_tail.with_skill_safety_rule, applied in
  _assemble_compressed for LLM and fallback summaries alike). The "## Pruned Skills" block drops
  its own parenthetical, which the rule now covers. `hermes sessions repair-prompts` keyed its
  "full build" detector on the rule's heading; it now keys on SKILLS_GUIDANCE (present in prompts
  built before and after this change).
- The CLI/TUI cron "LOCAL-ONLY" caveat (154 tok) moved from the platform hints into
  cronjob_manage's deliver description (a deferred tool: paid only when loaded).
- The Hermes help pointer no longer restates identity ("You run on Hermes Agent (by Nous
  Research)") after SOUL.md's "You are Hermes Agent, built by Nous Research."; it now opens "For
  help with Hermes Agent itself — ...", which still tells a custom persona what it runs on (22 tok).

One-shot sessions only (-q/--oneshot/-z, and gateway-owned `oneshot` policy sessions)
- No "## Mid-turn user steering" note (253 tok): nobody can steer a one-shot.
- No clarify tool (590 tok): ONESHOT_DISABLED_TOOLSETS is folded into session_disabled_toolsets
  (oneshot=...), so the agent tool build, MCP refresh, the tool_search bridge, delegate children and
  the gateway's session inventory / tool listings all drop it together. skill_manage stays.
- delegate_task without live control (425 tok): action/subagent_id/message and the
  background-delivery paragraph are removed (children are joined inside the call), applied via
  toolsets.agent_tool_surface at load and MCP refresh. The one-shot fact is frozen on the agent at
  its first tool build so refreshes stay byte-stable.

Interactive tool schemas are byte-identical to main.
2026-10-24 17:31:52 -07:00
Teknium
d7094033f6 fix(oneshot): one-shot runs keep skill_manage
Maintainer ruling: a finite `hermes chat -q` / `--oneshot` / `-z` run may author
skills. Drop the one-shot strip of skill_manage (ONESHOT_HIDDEN_TOOLS /
prune_oneshot_tools) from both places that applied it: the agent's tool build
(agent/agent_init.py) and the gateway's session tool inventory
(gateway/session_local_inventory.py). The one-shot skills prompt (domain skills
only) and the delegation cap are unchanged.

Before this, the two paths disagreed in the field: a gateway-owned one-shot on an
installed build still pinned skill_manage while getting the one-shot prompt. With
no strip there is nothing left to disagree about.

Tests: the two assertions that pinned "no skill_manage in one-shot" now pin the
opposite, per the ruling; docs updated.
2026-10-24 07:12:47 -07:00
Teknium
4b6c7f68d9 feat(delegation): a session routes on the backend its delegate_task was built from
A plain /delegation save (or a config.yaml edit) now changes nothing in a running
chat: routing and schema switch together at /new or on a --now rebuild.

- agent._delegation_backend is captured with the tools (agent_init, ACP rebuild,
  refresh_agent_mcp_tools rebuilds incl. --now and compaction) and pinned with
  them to the session row; a fresh agent restoring the pin restores the backend.
- resolve_task_routes routes on it (config.yaml only for agent-less callers).
- set_global_backend(name, *, session_key, apply_now) is unchanged.
2026-10-23 00:37:14 -07:00
kshitijk4poor
310bcf444a refactor(memory): move tool-schema plumbing into agent/memory_manager_tools.py
The stall/registry work pushed agent/memory_manager.py past 1,000 lines.
The memory-provider tool-schema helpers (normalize_tool_schema,
memory_provider_tools_enabled, memory_provider_tools_exposed,
inject_memory_provider_tools) are a self-contained topic with no
dependency on MemoryManager, so they move verbatim to a
memory_manager_tools sibling and every in-tree caller imports from the
new module. agent.memory_manager is a public plugin module
(hermes_cli/plugin_validate_private_imports.py), so it re-exports the
four names, as it already does for the helpers that moved to
agent.memory_context.
2026-10-19 19:15:44 +05:30
unsupportedpastels
e948784466 fix(providers): restore a custom primary from the entry its snapshot recorded
Restoring the primary after a fallback rebuilt credential ownership from
live config.yaml, not from the config the session resolved on. Two edits
made mid-session moved it onto another account:
- alpha and beta share one URL and the session runs on custom:beta. Once
  beta's live endpoint moves, the named lookup misses, load_runtime_pool
  falls back to URL-only matching, and the session resumes on alpha's
  `hermes auth add` key.
- the session runs on custom:deepseek with a declared key_env. Once the
  declaration is removed from live config, the entry looks credential-less,
  so the built-in's env row is no longer foreign and restore swaps to
  DEEPSEEK_API_KEY and api.deepseek.com.

Both `_primary_runtime` builders (agent construction and a model switch)
now record the owning entry's provenance (`custom_entry`), matched the way
resolution matched it, in the frozen scope when one is active. The record
holds the entry's name, provider_key, base_url, key_env names and whether
it declares a credential; it never holds a secret. Restore takes the pool
key and the ownership filter from that record, so live edits can't
reassign the endpoint or drop the declaration. A named identity whose
snapshot recorded no owner, including a snapshot from an older builder,
keeps its snapshot credential instead of borrowing by URL. A genuinely bare
`custom` snapshot without a recorded owner still matches by URL, as
before.

The two builders move unchanged into agent/primary_runtime_snapshot.py, so
agent_init.py and agent_runtime_helpers.py, both over the file-size
target, shrink instead of growing. test_primary_runtime_restore's
named-pool test now builds its agent under the config it restores with,
as a real session does; built without that config, its snapshot
correctly records no owner.

Refs #140297
2026-10-17 13:29:00 -04:00
unsupportedpastels
4007e7b76f fix(memory): tell the user when a shared provider instance is dropped for their profile
When initialize_all refuses a provider instance another profile already
bound, it drops the provider, but the agent build still logged "Memory
provider '<name>' activated" and kept a manager with no external provider,
and nothing reached the user. With a singleton-style plugin, which profile
keeps its memory depends on whose message arrives first after boot.

Agent builds now call MemoryManager.initialize_for_agent, which runs
initialize_all, reports each dropped provider through the agent's startup
warning sink (as the unavailable-provider path does) and returns whether an
external provider is still served. The build logs "activated" only then;
otherwise it drops the empty manager like the not-available path. The
warning names the provider, never a home path; the check's code and the
homes stay in the log.

Refs #134889 (PLG-11)
Refs #140208
2026-10-17 13:28:18 -04:00
unsupportedpastels
dfc2cbeaa1 refactor(memory): move memory-context fencing into agent/memory_context.py
agent/memory_manager.py mixes provider fan-out, background work and the
text formatting that fences recalled memory for the model. The formatting
half (sanitize_context, StreamingContextScrubber, build_memory_context_block
and their regexes) is pure text work with no provider calls or profile
state, so it moves unchanged to its own module. Callers import it from
there; nothing in plugins/ imported it, so no re-export is kept.

The only visible difference is the logger name on the "pre-wrapped
context" warning (agent.memory_context). This leaves the manager room for
the profile-ownership checks the next commit adds without crossing its
line cap.

Refs #134889 (PLG-11)
Refs #140208
2026-10-17 13:28:18 -04:00
Teknium
e7a81e7520 fix(cli): label a callable API key by its credential source, not by "is it callable"
/config (cli.py show_config) and the agent's key banner (_print_key_banner)
printed "Microsoft Entra ID" for every callable api_key, so a custom
provider's key_cmd bearer or MiniMax OAuth read as Azure. /config also
picked Vertex out with a __module__ string compare, and the banner had no
Vertex case at all.

Each builder now tags the callable it returns with a source
(agent/credential_source.py): build_token_provider -> entra-id,
vertex_access_token -> vertex-oauth, CommandTokenSource -> key-cmd,
build_minimax_oauth_token_provider -> minimax-oauth. Both surfaces resolve
the label through one source-to-label table. An untagged callable gets the
neutral "Token provider" label. The tag is read with getattr, so no display
path calls the callable (no token minted just to mask it).

New catalog keys key_cmd_token, minimax_oauth and token_provider in every
locale (English text, matching the brand-name convention of the existing
microsoft_entra_id / google_vertex_oauth keys).

Tests: tests/agent/test_credential_source_labels.py, one red/green case per
label on each surface (7 red before: key_cmd/minimax/unknown on /config,
vertex/key_cmd/minimax/unknown on the banner). Each case's callable raises
if invoked. The old "any other callable is Entra" pin now uses a real
Entra-tagged provider.

Review finding by @unsupportedpastels on #140469
Review finding by @alt-glitch on #140469
Refs #134889 (T6)
Refs #140337
2026-10-17 07:23:06 -07:00
Teknium
848fc0ad8b fix(gateway): keep an accepted /steer across the exhaustion deferral; drop checkpoint re-exports
Follow-up to #139923 (salvage of #105100), from its review:

- When a compression-exhausted turn left a queued event, _run_agent_drain_pending returned before
  _merge_leftover_steer, so a /steer the agent had already taken out of its buffer
  (result["pending_steer"]) vanished. _defer_past_exhaustion_reset now queues it ahead of the
  deferred event, the same steer-first order as the normal path.
- conversation_compression re-exported every helper moved to conversation_compression_checkpoint.
  Internal moves get no re-export shims: callers and tests import from the new module, and the
  facade keeps only the two names it uses.
- test_total_ceiling_exhaustion_does_not_start_fallback used a 0.3 s budget; raised to the 2 s
  floor from tests/AGENTS.md.

Reported-by: greptile-apps
2026-10-16 08:38:51 -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
3a867a9e65 refactor: delete the initiate-setup turn core, keep the scripted prelude
Salvage of 058b5c8158 from the static-onboarding stack, adapted: the
initiate-setup prompt, its facts builder and the first-task prompt go with
the setup_choose server request and callback, the initiate-setup branch of
the prelude wiring in prompt_turn and the intro auto-continue skip. Unlike
058b5c8158 the scripted prelude seam (agent/turn_scripted_prelude.py and
the prelude parameter on run_conversation) and gui_tour's preset stay: the
default-profile onboarding opening plays through them, and prompt_turn now
asks only _onboarding_prelude for one.

(cherry picked from commit 058b5c8158, adapted)
2026-10-14 00:29:11 +05:30
alt-glitch
37f9a0f480 refactor: move constructor param tables and clarify copy into siblings
The code health ratchet failed on this branch: agent_init.py grew past its
main size, handleInputRequestEvent went over its complexity, and the locale
files grew by the theme picker import. The constructor param name tables
move to agent/agent_init_params.py, the clarify card copy moves to
<locale>_clarify.ts files, and theme-pick cancellation becomes a helper.
2026-10-13 23:55:11 +05:30
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
alt-glitch
d8cefac352 feat(onboarding): setup_beat, the one onboarding-only tool
tools/setup_beat_tool.py shows a beat's card and blocks until the user
answers (the card callback is a server request, like clarify), then
returns their answer with a reminder of the next beat. beat=next shows
the first open beat; value and skip record an answer given in words
without a card; beat=done ends the run once the build card was reached,
and beat=done with skip=true ends it early when the user asks to stop.
Words typed while the name card waits are the name. The account's full
name goes to the name card only.

The tool lives in a new desktop-only "onboarding" toolset, which nothing
enables by default; the gateway folds it in for the onboarding chat only
(next commit). It runs inline in the agent loop (inline_tool_executors)
with the session's store and the agent's setup_beat_callback, and never
in parallel with another tool.

Two loop seams:
- tool_executor passes every successful tool result to
  onboarding.observe_tool_result, so set_theme, manage_connections
  display and gui_tour (also when reached through tool_call, which the
  executor unwraps first) settle their beat.
- turn_tool_round treats a setup_beat round like a housekeeping round
  for the empty follow-up: the line written with the card becomes the
  reply instead of an empty-response nudge (not muted).
2026-10-13 22:08:20 +05:30
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
336b11584c fix: replay prior reasoning to every chat-completions route that can read it
Every model reasons and intends that reasoning to be replayed, but the
chat-completions wire echoed reasoning_content only to DeepSeek/Kimi/MiMo/
Ollama (plus a hardcoded Portal stealth model) and reasoning_details only to
OpenRouter; turn_context popped `reasoning` everywhere, so Ollama's /v1
(reads only `reasoning`) never saw any.

- message_sanitization owns one route->carrier table
  (_REASONING_CARRIER_ROUTES): strict schemas (Mistral, Groq, Cerebras,
  SambaNova) get nothing, Fireworks reasoning_content only, OpenRouter-format
  gateways (OpenRouter, Kilo, Vercel AI Gateway, Nous Portal) all three,
  Novita/MiniMax /v1/TokenHub + reasoning_details, local/Ollama/Upstage +
  reasoning, everyone else reasoning_content.
- The " " pad stays limited to the must-echo tier (DeepSeek, Kimi, MiMo);
  Ollama leaves it (no echo requirement) and the stealth hardcode is gone.
- Reactive recovery: a 4xx unknown-field rejection that NAMES a reasoning
  key this request carried is recorded per (provider, host, model) and the
  retry re-shapes api_messages without it. Generic upstream errors never
  count; a recorded key falls through, so no loop. History is untouched.
- Nous Portal reads reasoning_details again: the #118182 "replay budget"
  does not exist in the Portal and does not reproduce live.
- Gemini thought_signature survives on Gemini hosts/providers even when the
  model id is an alias.
- Vendor keep-reasoning flags (docs-only): GLM thinking.clear_thinking=false,
  DashScope preserve_thinking / clear_thinking, Kimi K2.x thinking.keep=all.
- stale_thinking_reaches_wire follows the same table, so compaction trigger
  and tail walks agree with what is sent.
2026-10-10 19:22:07 -07:00
Teknium
408cc0d12e Merge origin/main (#32: 36 commits to cf23a1a5cc) into feat/unified-gateway-runtime
17 conflicts, all from main's lint sweep (ruff UP007/UP017/UP022/UP028/UP031/UP037/UP041,
FURB188/FURB192); no other main commit touches a conflicted file. Resolution: the branch side
of each file plus main's exact autofix (ruff 0.15.10, main's ruff.strict.toml, --fix
--unsafe-fixes). ruff.strict.toml takes main's copy. The pool-retirement live fixture stays
deleted with the pooled backend this branch retires.
2026-10-09 10:24:04 -07:00
Maciej Lisiewski
2ff58849f4 ci: ruff UP037 fixes 2026-10-09 17:34:38 +02:00
Teknium
607a23e858 Merge origin/main (#30: 54 commits to 1744a19e0d) into feat/unified-gateway-runtime
8 conflicts, all from main's lint sweep (#135281 "Harder linter fixes" + the RUF series:
implicit-Optional, unused-unpacked-variable, next(...) for [...][0]). No other main commit touches
a conflicted file. Resolution: the branch side of each file plus main's exact autofix
(ruff 0.15.10, main's ruff.strict.toml, --fix --unsafe-fixes) on it. ruff.strict.toml takes main's
copy (the newly enabled rules). tests/cron/test_bot_chat_delivery_child_env.py stays deleted
(1cc9cb9199 retired its lane).
2026-10-08 21:38:54 -07:00
Maciej Lisiewski
9d9a3840d1 ci: address code review 2026-10-08 22:16:26 +02:00
Maciej Lisiewski
4278b6aa24 ci: RUF013, RUF015 2026-10-08 21:29:48 +02:00
Teknium
65bec86e37 Merge origin/main (#27: 19 commits to 517b5e10fe) into feat/unified-gateway-runtime
45 conflicts, all from #135177 (lefthook + `ruff check --fix` over 2,366 files). No other main commit
touches a conflicted file. Resolution: the branch side of each file, then main's exact autofix
(ruff 0.15.10, `--config ./ruff.strict.toml --fix`) on it — rewrites only (typing generics, noqa
drops, import forms), no import removed. tests/cron/test_bot_chat_cli_home.py stays deleted
(1cc9cb9199 retired its lane).
2026-10-08 12:09:24 -07:00
Maciej Lisiewski
b4e436c115 ci: don't cast int to int 2026-10-08 19:28:23 +02:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
Teknium
b09c202d9e Merge origin/main (#21: 191 commits to e675225af2) into feat/unified-gateway-runtime
Brings #134209 onboarding (setup chat, /initiate-setup, setup_choose/start_chat cards) and
889eddcd86 (/yolo survives a gateway restart).

Conflicts (6):
- gateway/run_turn.py, tui_gateway/server.py: the branch moved these blocks into siblings;
  main's edits ported there (run_turn_prepare: first-contact `message`/setup_command, the
  _restore_session_yolo call after _hmwa_open_session; agent_factory: coding_selection
  session-platform toolsets, setup_choose/start_chat lifecycle tools; session_registry:
  _lazy_resume_info default route).
- tests/gateway/test_yolo_command.py: both tests kept.
- Desktop composer submit / slash / wiring: main's parked-card answering and submitWhileBusy
  with the branch's busy-input policy in its steer branch; slash `hidden` folds into the
  prepared-submission journal; wiring keeps main's onboarding chain without the removed pool.

Semantic fixes:
- gateway/session_busy_controls.yolo_config writes main's persisted SessionEntry.yolo before
  the live flag, so an owner `/yolo` OFF is not revived by _restore_session_yolo next turn
  (new test test_owner_yolo_off_is_not_revived_by_the_persisted_restore).
- wiring runKickoffSlash awaits the branch's Promise<boolean> slash dispatcher.
- de/es/fr/ja/zh-hant: translate the branch's composer keys main's overlay-completeness test
  now requires.
2026-10-07 17:09:40 -07:00
Teknium
4f05b94c96 refactor(agent): move Ollama num_ctx init helpers to agent_init_ollama
_configure_ollama_num_ctx and _clamp_compressor_to_ollama_num_ctx move
unchanged into agent/agent_init_ollama.py; agent_init imports them back.
Code-health FILE_LINES ratchet on PR #106742 (agent_init.py 2512 > 2496).

(cherry picked from commit c95b2f558d1f9c16ab0dba17f1caa9a1995710fc)
2026-10-07 10:57:32 -07:00
Teknium
ca38632fc0 Merge origin/main (#17: 454 commits to e6757f2029) into feat/unified-gateway-runtime
12 conflicted files, resolved in three lanes:
- gateway/run.py: take the branch split; main's tirith removal and spool-replay
  ordering ported into run_runtime_init.py / run_bootstrap.py.
- config migrations: main keeps v50 (tirith); the branch's bot-chat timeout removal
  becomes v51 (_config_version 51, template + test updated).
- hermes_state_usage.py: main's voice_chat task route threaded through the branch's
  owner transaction; worker.persist usage allowlist accepts task.
- tui_gateway/server.py: branch side; main's edits applied where the code now lives
  (agent_factory, session_registry). Desktop sessions get the catalog toolset on the
  authority path; daemon-run finite CLI turns are not watched turns; lazy session info
  reports nous/welcome on the free tier.
- Desktop/Ink: one branch-child spinner fix (main's route-token check); main's
  uninstall i18n keys kept, pool keys stay removed; voice_turn forwarded and accepted
  by the authority submit (surface_v1.voice_turn).
- chat_ws / PTY keepalive test: main's stricter test kept.
2026-10-07 06:48:09 -07:00
alt-glitch
17646902e1 Merge remote-tracking branch 'origin/main' into sid/onboarding 2026-10-07 13:28:50 +05:30
Brooklyn Nicholson
3bbe2a1ce2 fix(copilot): recompute api_mode on fallback and stop stale-mode veto (#46527)
Port of #46542 by @MarkVLK onto current main:

- hermes_cli/runtime_provider.py: _copilot_runtime_api_mode must not veto
  a stale configured codex_responses mode for chat-only Copilot models;
  recompute from the live model capabilities.
- agent/transports/codex.py: request summary:"auto" on the GitHub
  Responses API so reasoning summaries surface.
- agent/agent_init.py: recompute api_mode at init-time fallback so the
  fallback provider/model gets its own mode (and the primary-runtime
  snapshot reflects it).
- tests: regression tests for the stale-mode veto, the GitHub Responses
  summary, and the init-time fallback recompute.

Conflicts resolved against main's refactored fallback ladder
(agent/chat_completion_helpers.py) and its expanded transport tests.

Co-authored-by: Mark Vlcek <markvlcek@gmail.com>
Fixes #46527
2026-10-06 23:54:51 -05:00
alt-glitch
8b89b68fb4 Merge origin/main into sid/onboarding
Brings the onboarding branch up to main 0c2ff854a5. Where a Wave A PR
already landed a reviewed version of a piece of this branch (free tier
#134049, keyless web #134048, app resolver #134050, bundle and uninstall
#134051, catalog card and toolsets #134052, built-in tour #134054, stdin
guard #134055, retired key #126146), main's version wins. The PM long-path
files also take main's version: that work lands through #130430.

Kept from the branch on top of main:
- the setup and start_chat toolsets, declared with main's platforms key
  (desktop only), and the setup_choose server request contract;
- the setup-profile marker file (.setup-profile.json) instead of the
  profile.yaml role, as c3f85bc54f decided;
- the first-contact note's message argument beside main's internal flag;
- the setup-profile gate on the shared-metrics consent dialog;
- window sizing (window-growth) in place of chat-onboarding-window.

Desktop i18n follows main's per-section sibling files. The onboarding
strings go into them (modelMenu.localSetup, handoffTour.localTitle and
localText) and setupChoose/startChat stay in en.ts. guidedGreeting is
gone. The shared-metrics copy uses the branch's rewrite in English, with
the pre-opt-in sentence corrected for the fresh-install note
(d3674513c8); locales keep main's translations, with installId and
consentWindow folded into the new sending key.

The built-in tour reads local-model eligibility from the local-setup
offer store, the one place that rule lives on this branch. The gateway
contract and the onboarding skill docs pages are regenerated.
2026-10-07 03:27:01 +05:30
Teknium
1e500ebce2 Merge origin/main (#16: 4,465 commits to 9dcab1e440) into feat/unified-gateway-runtime
99 conflicted files resolved in nine area lanes (Desktop composer, Desktop renderer/shared
client, Electron main, Ink, tui_gateway, gateway, state, CLI/config, cron/tools/CI). The
unified runtime's architecture wins where it deliberately replaced a mechanism (pool,
fallback lanes, claim poller, renderer queue); every orthogonal main change is kept, ported
into the <stem>_<topic> sibling that now owns relocated code.

Notable ports and repairs in this merge:
- tui_gateway/server.py relocated regions: atomic _attach_built_agent (#49852), slash ranking
  registry names, minted-key helpers methods_session.py calls, request_overrides, service tier.
- gateway/run_turn*.py: i18n accessors for the removed reply constants, first-contact
  internal/DM rule, rotated-compression persist, fast-mode tiers, prompt-pin rehydration.
- webhook: route_from_chat_id decodes main's opaque webhook:v2 chat ids (old ids still read).
- ws.py: main's per-connection dispatch queue with authority-first dispatch inside it.
- state: schema event for runtime revision renumbered to 31; worker mirrors updated for
  main's message uid/merge fields, on_contended lease arg, compression columns.
- config: branch's bot_chat_delivery_timeout removal renumbered v47 -> v50.
- Electron: primary-profile pin, redirect header scoping, remote fetchJsonForBackend, SSH
  teardown on profile delete, held-update dial gate restored (lost in earlier merges).
- Desktop: canonical clarify.request mapped to main's questions[] card; replay truncation vs
  snapshot_required; periodic secondary prune tick restored; DELETE already_absent restored.
- cron/tools: diagnostic category on cron failure notices restored; owner_holds_delivery
  ported onto the authority; admitted receipts can no longer be cancelled locally.
2026-10-06 14:24:24 -07:00
Siddharth Balyan
de1626d666 Free tier: a rate limit ends a watched turn at once with the reset time (#134049)
* fix(agent): free-tier rate limits end an attended turn at once

A free-tier (no sign-in) session that hit the service-wide rate limit slept
up to 600 s, retried into the same refusal, slept again, and then sent its
third attempt on a guest JWT that had expired during the wait. The welcome
host answered 403 "invalid jwt", which read as the tier being switched off.
The user watched a spinner for about 18 minutes and then saw the wrong card.

- An attended session (desktop, TUI, the interactive CLI, ACP) on the free
  model ends the attempt cycle at once when the cooldown is longer than
  60 s: fallback first, else the reset time and the sign-in / model doors.
  "Attended" is keyed on the session source, so `hermes chat -q`, cron and
  messaging sessions keep the long wait. The source vocabulary moves from
  run_agent.py into agent/session_source.py, which adds is_attended().
- on_free_model() (welcome host + anonymous credential) is the one free-tier
  check, used by the cutoff, the "free model is busy" wait copy and the
  outage copy.
- A welcome-host 403 "invalid jwt" is its own route kind, session_expired:
  the existing one-shot route heal re-exchanges the credential and retries;
  if that fails the card is the retryable outage card.
- interruptible_backoff_sleep adopts a fresh Nous key after each wait.
  _adopt_nous_key_before_expiry owns its refresh failure, so both call
  sites drop their try/except.
- A retry wait over 60 s is announced in the transcript when it starts, for
  every provider; shorter waits stay buffered. Every wait line names the
  attempt that runs after it.
- max_retries_exhausted_result's max_retries becomes attempts (what it
  carries); a one-attempt rate-limit end gets its own lead.
- One Retry-After reader, retry_utils.provider_retry_after_seconds, shared
  by compute_error_backoff and the recovery ladder.
- _session_default_route replaces _session_default_model everywhere in
  tui_gateway, so a not-yet-built free-tier session reports nous/welcome on
  create, reuse, resume, branch and row persist, not the silent default.

* fix(agent): free-tier cutoff no longer ends subagent or library turns, paid waits look like main (review)

A delegated child of a TUI/Desktop session and a library caller (no platform) are unattended, so they keep waiting.
Rate-limit wait lines keep main's attempt numbers and stay buffered for every provider; only a non-rate-limit Retry-After over 60 s is announced, as on main.
The unattended free-tier wait line keeps the reset time beside "The free model is busy".
The free-tier cutoff names the reset time for any cooldown it fires on (over 60 s), not only from 120 s.
session.info for an env-seeded model off the free tier carries the model alone again, as on main.
Behaviour tests for the cutoff, the subagent and unattended waits, and a paid long wait.
2026-10-06 12:31:21 -07:00
alt-glitch
901da1cb6a fix(catalog): sessions off the desktop no longer see manage_catalog through tool_search (review)
An agent stores its session platform's gated toolsets in disabled_toolsets at load, so the tool_search listing, the bridge's search, MCP refreshes and delegate children drop manage_catalog too.
InstallPhase moves to the leaf hermes_cli/plugin_install_phase.py; the gateway contracts no longer import the installer.
The per-home enable lock moves from the plugins_cmd facade to plugins_cmd_install._enable_placed.
Reusing an installed catalog tree reads the install record through catalog_install_record, so older top-level catalog_name records match.
A failed row no longer redacts the Advanced choices (profile name, commit); only credentials are redacted.
The profiles.py role comment no longer says a role grants the setup toolset.
2026-10-07 01:01:14 +05:30
alt-glitch
c2b13dc3d8 feat(desktop): every desktop chat can install catalog plugins; tools gated by session platform
Toolsets that exist only for one kind of session now say so on their spec:
`platforms=frozenset({"desktop"})`. `TOOLSET_SESSION_PLATFORMS` is derived
from the specs that carry the key, `all` / `*` / no selection skip those
toolsets, and `toolsets.agent_tool_drops(agent)` removes their tools from any
agent whose own session platform is not listed. `agent_init._load_tools` and
`tools/mcp_tool_agent.py` (MCP refresh and prefix restore) call that one
helper. `tool_search._DIRECT_SURFACE_TOOLSETS` is derived from
`CLIENT_SURFACE_TOOLSETS` and `TOOLSET_SESSION_PLATFORMS`.

This replaces the profile-role gate: `profile_role_toolsets`, the role code in
`_with_session_toolsets` and the explicit-pin branch, the strip step in
`_select_tool_names`, and main's `setup` toolset (whose only tool moves out)
are deleted. `manage_catalog` moves into a new `catalog` toolset, which the
desktop client folds into every desktop chat like `project` and `desktop_ui`.
It is deferred behind tool_search by default (`config_defaults` defer list).
The shared-metrics schemas' toolset enum follows (`setup` out, `catalog` in).

The install card works outside the setup chat (#129650, with review fixes):
- Parallel installs: `_set_plugin_enabled` holds a per-home lock around the
  read-then-admit section, so rows enabled at once no longer refuse each other.
- A catalog plugin already on disk and not enabled is enabled in place, so Try
  again after a refused enable can finish.
- A failed catalog row counts as resolved (`contract.resolves`), so it no longer
  holds the turn to the 300 s deadline. The snapshot carries `resolved`, and the
  card reads it instead of a hand copy of the backend's rule.
- Each card draws its own operation by op id, because models reuse call ids.
- The row carries the approved non-secret choices (`approved`: force, enable,
  ref) and the chosen profile, so Try again after the card settled repeats them.
- Install phases are ids (`InstallPhase`, wire `CatalogInstallPhase`) and the
  installed-row notes are fields (`enabled`, `missing_env`, `server_errors`,
  `already_installed`, `requires_hermes`); the card words them in English
  strings (translations follow later). Failure reasons stay raw text, and
  `detail` keeps the English notes for the model.
- Installs and search target the calling chat's own home, carried as a path;
  the row's profile name is only a label, with no `'default'` fallback in
  Python or TypeScript.
- `dashboard_install_plugin` is split into `_resolve_source`, `_place_tree` and
  `_enable_placed`.

Desktop English strings for the card move to `en_catalog_install.ts` /
`types_catalog_install.ts`, which offsets the growth of `en.ts` and `types.ts`.
2026-10-07 01:01:14 +05:30
kshitijk4poor
3ffd44e4d3 fix(agent): an init-time fallback carries its own identity into requested_provider
The init-time fallback in _routed_client_kwargs switched agent.provider to the
fallback entry but left requested_provider naming the primary. The
answer_in_reasoning gate now scopes trust by requested_provider, so a primary
that fell back at construction to a same-base_url sibling inherited the
primary's opt-in. The runtime fallback, /model switch and MoA paths already set
both fields; this one now does too.
2026-10-06 13:01:39 +05:30
kshitijk4poor
0044d3a7d0 refactor(agent): drop the constructor answer_in_reasoning seed now the gate reads the route
52e8ecd495 merged the constructor `capabilities=` answer_in_reasoning bool
into runtime_capabilities at startup so a provider-level opt-in reached
the promotion gate. The gate now re-reads the provider-level
`capabilities:` block on the live route (previous commit), which covers
CLI/TUI and /model switches the seed never did, so the seed is redundant.
Forward removal, not a revert: 52e8ecd495's test coverage stays, but the
fixture now opts in through the custom_providers entry-level
`capabilities` block instead of the constructor (fold2 finding 1).
2026-10-06 13:01:39 +05:30