Commit Graph

27 Commits

Author SHA1 Message Date
Teknium
f4a935b47a fix(agent): a plugin claiming a host never replaces core's reasoning gate there
R4 W6. _supports_reasoning_extra_body asked the host-claiming profile
(profile_for_host) before the LM Studio / Ollama Cloud / OpenRouter gates, and
_build_chat_completions_kwargs swapped the generic reasoning body for the
profile's payload on any claimed host. A plugin listing openrouter.ai or
ollama.com in hostnames for catalog/aux routing (without overriding
reasoning_payload) silently turned reasoning off on those routes.

_reasoning_endpoint_profile() is the one lookup for both: it returns the
claiming profile except on endpoints core gates itself (Nous Portal, Vercel AI
Gateway, Ollama Cloud, OpenRouter, the lmstudio provider). Documented on
ProviderProfile.hostnames. No in-tree profile claims those hosts; Copilot hosts
are unaffected.
2026-10-25 22:22:48 -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
a4a992645b refactor(providers): one memoized endpoint->profile lookup; drop duplicated api_mode helpers
- providers.profile_for_host is the single host->profile lookup (declared hostnames, exact or
  subdomain), memoized per (hermes_home_key, host, metadata) and invalidated by a registry
  generation counter bumped on every registration (process-wide or per-home layer).
- agent/provider_route_hooks.route_profiles = named profile, then profile_for_host(base_url);
  replaces L1's every-profile scan, L2's conversation_loop._credential_refresh_profile host scan
  and L3's agent/endpoint_profile.py + ProviderProfile.serves_endpoint (deleted).
- Copilot hostnames gain models.github.ai (the L3 Responses/reasoning gate host); per-site
  differences (carriers, editor headers, initiator) stay in the plugin hooks keyed on base_url.
- Pure per-request hooks (request_headers, max_tokens_param) are memoized per argument set so a
  plugins.isolation: host proxy pays one IPC call per request shape.
- hermes_cli/models.py: delete _should_use_copilot_responses_api / copilot_model_api_mode;
  runtime_provider routes per-model providers through api_mode_for_model generically.
- credential_refresh_notice seam restores main's Copilot refresh status lines.
- auth._env_key_auto_detected: ambient-credential check reads list_providers once instead of a
  per-pid get_provider_profile miss that walked the provider ladder (welcome_trial regression).
2026-10-25 19:00:01 -07:00
Teknium
0ae220ff4e refactor(providers): generic endpoint seams for Responses quirks, reasoning payloads and carriers
Core no longer branches on the Copilot/GitHub Models hosts in the Responses adapter, transports,
reasoning params or reasoning-carrier replay. A provider profile claims its backend through
ProviderProfile.serves_endpoint(base_url) (default False) and fills generic L3 fields/hooks:
responses_replay_item_ids, responses_prompt_cache_key, responses_issuer_kind,
responses_trusts_completed_status, responses_native_compaction, responses_profile_reasoning,
message_carrier_opaque/_text, replays_tool_call_signatures, reasoning_payload(),
replay_message_carriers(), replays_function_thought_signature().

The in-tree copilot plugin fills them from plugins/model-providers/copilot/responses.py, keeping the
persisted "github_responses" issuer stamp and hermes.native_assistant record keys. Persisted carrier
records whose declaring plugin is gone are stripped by their own keys.

Parity: an offline oracle over 2079 Copilot cases (main request kwargs incl. preflight, aux Responses,
carrier shaping/capture, reasoning gate, native compaction) is byte-identical to the base on the agent
paths in both registry states.
2026-10-25 18:20:23 -07:00
Teknium
90bc28af98 fix(hold-stream): rows a held user never got stay hidden in history
The hidden-row step covered only the tool-call row of run_tool_round.
Other assistant rows a held turn appends and flushes without showing them
were stored displayable, so reopening the session (TUI/Desktop
display_projection, dashboard, classic CLI resume) showed the original text
even when the final was rewritten:

- the attempted answer a late LSP verdict, verify-on-stop or pre_verify
  sends back (_append_interim_answer), and the kanban stop-guard answer;
- length-continuation fragments of a reply that then recovered (the final
  row holds the rewrite of the whole, so the raw pieces also duplicated it);
- the intent-ack / stall / degenerate-final continuation rows, codex
  status=incomplete partials, and commentary on a call to an unknown tool
  or with broken JSON arguments (turn_tool_validation).

Every one of them is built by AIAgent._build_assistant_message, so the
hiding now happens there: in a held turn a row with visible text comes
back typed display_kind="hidden" (withhold_held_row) before anything can
flush it, and finish_text_response publishes the one row the user gets
(publish_held_final_row: visible again and, after recovered fragments,
carrying the whole reply; api_content keeps the piece the model wrote, so
the wire is unchanged). display_kind never reaches the wire, so the
model's context and cached prefix stay byte-for-byte (the test replays the
resumed session and compares the request).

Same class, also fixed: text beside a housekeeping call reused as the
reply after an empty follow-up was flagged response_previewed/reused,
though a held turn never showed it; the classic CLI then printed nothing.

Tests (tests/agent/test_hold_stream_exits.py, red on 3a5b54d980): late
LSP verdict, recovered continuation, unknown-tool commentary, reused
commentary.

Review: https://github.com/NousResearch/hermes-agent/pull/144266#discussion_r4370678628
2026-10-25 06:18:48 -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
Teknium
f89688440e fix: a learned reasoning-field rejection survives a resumed process
A strict lane (the Portal's Fireworks :US models) rejects `reasoning` /
`reasoning_details` by name. The in-memory record stopped the 400 for the
rest of the process, but `hermes chat --resume` (or a gateway restart)
re-learned it with another 400 on its first request. The record now lives in
the session's model_config (same seam as the Anthropic rejected-thinking
fingerprints) and is loaded once per session_id. Still keyed by
(provider, host, model), so sibling models keep every carrier.
2026-10-10 19:22:07 -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
rob-maron
f86276d2eb nous portal reasoning content echo 2026-10-10 21:45:19 +05:30
kshitijk4poor
8e33fdd7af fix(agent): match Ollama "-cloud" tags; correct echo-family docs
Local Ollama exposes cloud models both as "<model>:cloud" and as
"<model>:<size>-cloud" (gpt-oss:120b-cloud). Treat the second form like
the first, requiring a ":" so provider ids such as "gmi-cloud" do not
match. Update the require-side comment and docstrings that still listed
only DeepSeek/Kimi/MiMo or claimed every member 400s without the field.
2026-10-10 15:17:05 +05:30
kshitijk4poor
ce3f83088a fix(agent): keep reasoning_content on Ollama Cloud tool-call replays
Ollama Cloud users reported reasoning being sent back wrong. Since #50480
the replay policy strips reasoning_content for every provider outside the
DeepSeek/Kimi/MiMo echo families, so on ollama-cloud an assistant tool-call
turn went back with no reasoning at all. Ollama's /v1 maps the field onto
the chat template's thinking input, so thinking models (kimi-k3, glm-5.3)
lost their own chain of thought between tool calls.

Add an "ollama" echo family (provider ollama-cloud, host ollama.com, or a
local server's ":cloud" model). Purely local Ollama models stay on the
strip side.
2026-10-10 15:17:05 +05:30
Maciej Lisiewski
2ff58849f4 ci: ruff UP037 fixes 2026-10-09 17:34:38 +02:00
kshitijk4poor
d24aadfdd1 refactor(copilot): one GitHub effort clamp for the profile and main agent
Follow-up to the #103857 salvage. The Copilot provider profile and the
main-agent GitHub reasoning path each carried the same clamp-then-medium
fallback. Both now call hermes_cli.models.clamp_github_reasoning_effort.

The offline Astra tests move next to the other Copilot effort tests, along
with a check that a structured catalog entry still wins. The main-agent
clamp now has a test pinning max/ultra -> high on the GPT-5 ladder. The
transport test no longer writes config.yaml. The two effort comments now
say the same thing.
2026-09-26 22:21:47 +05:30
Jash Lee
7a597324a1 fix(copilot): preserve Astra reasoning effort
(cherry picked from commit 108f20c553852246deb0ce86fd5474d5d7992dc1)
2026-09-26 22:21:47 +05:30
teknium1
53815e24dc fix: send reasoning_effort=medium on custom endpoints when agent.reasoning_effort is unset
An unset agent.reasoning_effort already resolves to medium on the Nous Portal,
OpenRouter, AI Gateway and Copilot routes (each profile fills it in
build_api_kwargs_extras). The custom / OpenAI-compatible profile — every
`providers.<name>` block and `--provider custom` — omitted the field instead,
so the endpoint's own default applied; for moonshotai/kimi-k3 that is `max`:
3x the reasoning tokens and ~3x the latency of medium, measured live.

The default is resolved at request time in _reasoning_config_for_wire via
ProviderProfile.default_reasoning_config (the custom profile answers medium),
so it is recorded as what actually went out and the reasoning-rejection
ladder keeps working: a 400 on the field turns the rest of the session back
to "omit". It never touches an explicit effort (low stays low, none stays
none), stays off non chat-completions transports (the Anthropic adapter's
unset = no thinking kwargs stands), off models the catalog or model_overrides
mark supports_reasoning: false, and off local Ollama models pulled without
the thinking capability. Auxiliary calls are untouched: they hand the profile
reasoning_config=None directly, which still omits the field.

Live wire capture (token-injecting proxy, providers.probe -> kimi-k3):
  before  req_reasoning: {}
  after   req_reasoning: {'reasoning_effort': 'medium'}
  agent.reasoning_effort: low  ->  {'reasoning_effort': 'low'}  (unchanged)
2026-09-20 16:03:38 -07:00
kshitijk4poor
8c6cb6f995 refactor(agent): drop the Optional import orphaned by the LM Studio helper removal 2026-09-14 20:35:28 +05:30
kshitijk4poor
488f2fc86d refactor(agent): drop the orphaned hand-rolled summary kwargs builder
`_chat_summary_attempt` now builds through `_build_api_kwargs`, leaving
`_iteration_summary_chat_kwargs` (56 lines mirroring the transport by hand)
and its only consumer `AIAgent._resolve_lmstudio_summary_reasoning_effort`
without a caller. The transport already owns every quirk they re-derived
(fixed temperature, LM Studio `reasoning_effort`, portal tags, provider
preferences, pareto router plugin), so there is nothing to keep in sync.
2026-09-14 20:35:28 +05:30
Teknium
7b8c11bcf7 simplify(compat): models — drop 52 re-exports from hermes_cli.models, repoint 16 callers + 41 test files 2026-09-03 13:48:49 -07:00
Teknium
e83816a4d1 review-fix(comments): restore lost #NNNN rationale comments across non-test source (mechanical sweep, condensed, code unchanged)
For each issue anchor present in BASE 63279301bc non-test .py and absent on HEAD, the BASE comment/docstring block was re-attached at the HEAD location of the code it explained (matched by the distinctive code line / enclosing def). Sentences already covered by an existing HEAD comment were deduped; the issue number always survives. Insert-only: no code lines changed.
2026-09-03 09:44:26 -07:00
Teknium
c13d0b023e refactor(agent/reasoning_params,rate_limit_credits): module-level helpers keep AIAgent attribute surface identical 2026-09-02 19:22:52 -07:00
Teknium
922717d538 refactor(agent/G_small): compact docstrings (keep WHY/invariants), inline constant comments 2026-09-02 19:16:38 -07:00
Teknium
270128294e refactor(agent/G_small): single-line signatures/calls, github effort fallback table, any() slot scan 2026-09-02 19:08:38 -07:00
Teknium
ca5f9f342a refactor(agent/G_small): hoist echo-family import, dataclass pending item, adopt_credits_state helper 2026-09-02 18:58:29 -07:00
Teknium
d038249b12 refactor(agent/G_small): second code pass — merged guards, table-driven compact display, joined wrapped calls 2026-09-02 18:51:24 -07:00
Teknium
d49ec401e3 refactor(agent/reasoning_params): unify LM Studio/Ollama probe caches, flatten gate ladder 2026-09-02 18:25:16 -07:00
Teknium
0ab2e9672c refactor(run_agent): extract VisionMessagePrepMixin and ReasoningParamsMixin 2026-09-02 13:29:40 -07:00