Commit Graph

533 Commits

Author SHA1 Message Date
kshitijk4poor 170a73637d fix(openai): drop prompt_cache_options from Astra requests — not an SDK kwarg, 30m is the server default
Every direct-API (api.openai.com) Astra request raised
``TypeError: Responses.create() got an unexpected keyword argument 'prompt_cache_options'``
before reaching the network: openai 2.24.0's Responses.create has no such parameter and no
**kwargs, and neither send path relocates it into extra_body. The PR's tests stopped at
build_kwargs/preflight so the SDK boundary was never crossed.

OpenAI's prompt-caching guide states ``prompt_cache_options.ttl`` accepts only ``30m`` and that
``30m`` is the default, so the field carried no information: sending nothing yields the same
cache lifetime. The sanitizer now only removes what the API rejects (none/minimal effort,
sampling/logprob knobs, the pre-5.6 ``prompt_cache_retention``) and never adds a field, which
also keeps the request body byte-stable for the cache prefix.

Also: none/minimal→low no longer needs a bespoke {"", "none", "disabled", "off"} set —
``clamp_effort`` against CODEX_ASTRA_EFFORTS already resolves to the floor (``low``); and the
auxiliary adapter derives ``is_codex_backend`` from ``classify_responses_route`` (the declared
single owner of that predicate) instead of re-implementing the host test inline.

Tests reshaped to contracts: the two proxy/subdomain cases collapse into one parametrised
"exact host only" test asserting effort and temperature pass through untouched.
2026-09-07 21:43:54 +05:30
Eva 5a82258626 fix(openai): keep Astra rules on eligible routes
(cherry picked from commit f92fb9d9964e6e8ea118035c548aae812054f504)
2026-09-07 21:43:54 +05:30
Eva c990017482 test(openai): close Astra baseline review gaps
(cherry picked from commit 8c27b7c9316ba675e4d9ebcc7a659754f37f18ef)
2026-09-07 21:43:54 +05:30
Teknium 37fb7adfd6 fix: structured reasoning no longer breaks chat consumers
Normalize incoming reasoning at the shared heading boundary and completed
extraction, and flatten auxiliary content and reasoning before accumulation.
Reuse the existing text flattener with no implicit fragment separators.

Combine the earliest related work from zsuroy (#85791), the diagnosis and
patch from 2025hcsmile2010-hue (#104711, #104848), and completed extraction
work from liuhao1024 (#104717) as a slim redo, not a verbatim cherry-pick.

Two invariant tests exercise the real SDK and local HTTP fixture across
main streaming, Relay collection, auxiliary sync/async and completed output.
The standalone matrix improves from 32/84 to 84/84, preserving answers.

Co-authored-by: suroy <suroy@qq.com>
Co-authored-by: 2025hcsmile2010-hue <2025hcsmile2010@gmail.com>
Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>
2026-09-07 08:24:54 -07:00
Teknium bdf45abd7c fix: prefer owned Anthropic grants and bind auxiliary refresh to request credentials
Port owned-before-borrowed resolution from #104624, crediting the root cause in #104622. Include the synchronous and asynchronous auxiliary fallback recovery sites: forward the failed request key so an unrelated borrowed login never owns that refresh. Local-wire probes preserve the borrowed file and exchange only the owned grant. Broader validation remains queued; do not treat this commit as ready.

Co-authored-by: liuhao1024 <sunsky.lau@gmail.com>

Co-authored-by: d-bow-dev <24577047+dwb1991@users.noreply.github.com>
2026-09-07 08:07:26 -07:00
Teknium cb1a42d33b refactor: isolate custom health identity and trim redundant alias tests 2026-09-07 07:06:58 -07:00
fangliquanflq 84bbf176a3 fix(agent): preserve route URL path identity 2026-09-07 07:06:58 -07:00
fangliquanflq e3ff3e78d1 fix(agent): quarantine failed fallback destination 2026-09-07 07:06:58 -07:00
fangliquanflq e033bbaa3c fix(agent): quarantine bare custom aliases by endpoint 2026-09-07 07:06:58 -07:00
fangliquanflq 3fcbf13ddb fix(agent): scope named custom health by endpoint 2026-09-07 07:06:58 -07:00
fangliquanflq b40998bc3c fix(agent): isolate custom endpoint billing health 2026-09-07 07:06:58 -07:00
Teknium fd3565deec fix: remove dedicated user-facing output cap controls 2026-09-07 06:15:43 -07:00
Teknium ebe4e7bb44 fix: sanitize resolved auxiliary chat requests before dispatch
Extend the destination-boundary approach from PR #87840 to synchronous, asynchronous and streaming auxiliary dispatch, including prepared MoA requests. Keep native adapter replay intact.

Co-authored-by: siyoon <siyoon@friendli.ai>
2026-09-07 06:02:22 -07:00
Teknium 08b140d14e fix: gpt-6 Astra on Codex OAuth gets the 85% compaction autoraise
Codex OAuth caps gpt-6-astra at the same 272K window as gpt-5.4/5.5/5.6,
so the global 50% trigger compacted at ~136K. Extend the existing
codex_gpt55_autoraise gate to any slug containing "astra" (minus the
opt-in -900k picker variants, which already unlock the wider window).
Other routes (OpenAI direct, OpenRouter) keep the user threshold.
2026-09-06 23:08:45 -07:00
PeaceMaker-best 463d4bcd15 fix(agent): defer codex idle watchdog until progress
Signed-off-by: PeaceMaker-best <221849497+PeaceMaker-best@users.noreply.github.com>
2026-09-07 00:41:09 +05:30
Teknium 7166071fca fix(auxiliary): ResourceExhausted spellings reach the payment/quota fallback gate
The compression/aux fallback ladder decides "payment error" via
_is_payment_error(), which only knew the spaced "resource exhausted". NVIDIA NIM
and gRPC-style wrappers serialize the same quota signal as ResourceExhausted /
RESOURCE_EXHAUSTED / resource-exhausted, so a 403/429/status-less body carrying
it re-raised instead of walking the configured fallback_chain, and compression
fell to the lossy emergency path. Add the three separator variants to
_PAYMENT_KEYWORDS (same status gate, no broader "exhausted" matching).

evals/auxiliary_resource_exhausted.py drives the real call_llm/async_call_llm
against two local OpenAI-compatible listeners (nvidia profile primary, named
custom fallback) for the before/after check. #85649
2026-09-06 05:48:39 -07:00
Teknium 2776813df3 compat(plugins): temporary import-path shims for external plugins — ONE commit, revert on schedule
The Sep 2026 decomposition (PR #102117) makes internal import paths a non-API: names now live in
the focused modules that define them. This commit is the ONLY thing keeping the old paths alive,
so external plugins have time to update. It is deliberately a single, unsquashed commit:

    git revert <this sha>

removes every shim, stub and manifest at once on the announced date. Nothing in-tree may depend on
these pointers: scripts/check_compat_pointers.py (wired into lint.yml) fails CI if it does.

What it adds (see COMPAT_MANIFEST.md, compat_manifest.json):
- 332 facade modules get one delimited `PLUGIN-COMPAT` block appended at the end of the file
- 1,172 moved names resolved lazily via a module `__getattr__` (PEP 562) — never a top-level import,
  so no import cycles; facades that already had `__getattr__` get a chained one
- 592 third-party/stdlib names the old modules used to expose, with their original import statements
- 266 public definitions that had been deleted as unused, restored byte-for-byte from the pre-decomposition
  tree (+40 private helpers and 16 imports pulled in only because a restored definition needs them)
- 3 deleted modules recreated as re-export stubs (gateway/startup_watchdog, hermes_cli/observability/
  relay_runtime, tools/environments/modal_utils)
- private names (`_x`) get no pointer: they were never API (3,792 skipped)

Verified: all 335 touched modules import under a fresh HERMES_HOME and every manifest name resolves;
the lint reports zero in-tree uses; ruff clean; targeted suites unchanged.
2026-09-03 17:13:22 -07:00
Teknium 7a33369e81 simplify(compat): interrupt — drop _ThreadAwareEventProxy/_interrupt_event legacy alias, repoint 2 test files
No runtime consumer read the proxy (terminal_tool/environments call is_interrupted()/set_interrupt()
directly); its only users were tests patching tools.interrupt._interrupt_event, which had no effect on
the code under test. tools/terminal_tool.py's own re-export of the name is owned by another worker.
2026-09-03 14:00:59 -07:00
Teknium c93ace77c2 simplify(compat): config/runtime_provider/plugins/commands/secrets_cli/kanban — drop 96 re-exports (incl. PEP 562 facades) + 3 aliases (get_pre_tool_call_directive/_block_message, get_telegram_handler_factories), repoint 56 callers + 50 test files 2026-09-03 14:00:17 -07:00
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 fcbe4acbef simplify(compat): tools/mcp_tool — repoint 20 non-test callers to the defining mcp_tool_* siblings 2026-09-03 13:29:35 -07:00
Teknium d179f28307 simplify(compat): anthropic_adapter — drop 30 re-exports + 1 alias, repoint 22 caller files (32 sites), 38 test files (~125 sites) 2026-09-03 13:16:47 -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 0071ba9965 Merge origin/main (561b053f79) into simp/forwardport: forward-port 220 main commits into the simplified tree 2026-09-03 03:31:03 -07:00
Teknium ad46b3a812 Merge branch 'simp/r3-03' into simp/integration3 2026-09-02 22:39:25 -07:00
Teknium 17412822d9 refactor(agent): try/except/pass -> contextlib.suppress (28 sites, AST round-trip verified) 2026-09-02 22:00:23 -07:00
Teknium c09ba4b4c2 Merge branch 'simp/r3-03-aux-J' into simp/integration3 2026-09-02 21:59:14 -07:00
Teknium 139396995a feat(opencode): send x-opencode-session on every OpenCode request for backend affinity
OpenCode pins requests sharing an x-opencode-session value to one upstream
backend, which is what keeps its prompt cache warm across a conversation.
Hermes never sent it, so cache ratios on OpenCode traffic were poor.

- agent/opencode_affinity.py: single owner of the header — target detection
  (built-in zen/go/free, custom opencode-* providers, any opencode.ai URL)
  and the key (affinity scope → conversation root → session id, cron
  timestamp stripped), same resolution as OpenRouter/xAI affinity hints.
- build_api_kwargs: merged once after the per-mode builder, so
  chat_completions, codex_responses and anthropic_messages all carry it.
- auxiliary _build_call_kwargs: same key from the runtime-main session so
  compression/title/vision calls stay on the conversation's backend; the
  aux Codex and Anthropic adapters now forward extra_headers.

Closes #81584, #81832 (deepseek-v4-flash 400 without the header).
2026-09-02 21:46:36 -07:00
Teknium d0adf6486e refactor(agent): hug/pack bracket spans in async_utils + aux_accounting, fix E305 blank lines 2026-09-02 21:38:20 -07:00
Teknium 116ca1db1e fix: sibling Nous 401 recovery adopts a peer's refresh instead of rotating again
The stampede fix added a `stale_access_token` hint to
resolve_nous_runtime_credentials() so a process whose bearer just 401'd
adopts a token a sibling already rotated instead of re-POSTing the shared
grant — but only the credential-pool caller passed it. The main agent's
401 path (run_agent._try_refresh_nous_client_credentials), the auxiliary
client rebuild, and the proxy adapter all called force_refresh=True with
no hint, so `_already_rotated_by_peer` could never fire: N subagents
hitting hourly expiry still issued N serialized refreshes, each one
invalidating the token a sibling had just adopted.

Live 12-process A/B against a fake Portal: 12 refresh POSTs / 9 distinct
final tokens before, 1 POST / 1 token after.
2026-09-02 21:22:07 -07:00
Teknium 5e15b982d5 refactor(agent/auxiliary_client): keep _candidate_context_window as a probe-referenced helper 2026-09-02 20:48:04 -07:00
Teknium eea9b1f164 Merge branch 'simp/r3-03-aux-I' into simp/r3-03-aux 2026-09-02 20:33:47 -07:00
Teknium b848a36eab refactor(agent/auxiliary_client): densify relay/runtime-main/client-builder/classifier/pool-recovery/fallback-destination region (-202 LOC, -142 code; inline _pool_error_context; AST-identical elsewhere) 2026-09-02 20:28:32 -07:00
Teknium 183657afa7 Merge branch 'simp/r3-03-aux-L' into simp/r3-03-aux 2026-09-02 20:27:08 -07:00
Teknium d9d7da1309 Merge branch 'simp/r3-03-aux-K' into simp/r3-03-aux 2026-09-02 20:27:07 -07:00
Teknium 97096d9581 Merge branch 'simp/r3-03-aux-J' into simp/r3-03-aux 2026-09-02 20:27:05 -07:00
Teknium 43049d6107 Merge branch 'simp/r3-03-aux-H' into simp/r3-03-aux 2026-09-02 20:27:04 -07:00
Teknium 002d5125f3 refactor(agent/auxiliary_client): densify fallback chains + provider router (inline 4 single-use helpers, collapse defensive layers, compact docstrings) 2026-09-02 20:24:50 -07:00
Teknium 369bfe4a87 refactor(agent/auxiliary_client): densify adapter/credential region (inline single-use helpers, compact docs; -214 LOC) 2026-09-02 20:19:57 -07:00
Teknium 7946921ff6 refactor(agent/auxiliary_client): density pass on vision routing, client cache, task routing, fast lane, and _build_call_kwargs (-220 LOC) 2026-09-02 20:16:29 -07:00
Teknium a6696d464e refactor(agent/auxiliary_client): densify call_llm tail region (stream helpers, recovery ladder, impls): inline single-use rung helpers, pack literals/log calls, strip body blanks 2026-09-02 20:14:01 -07:00
Teknium 5af3deeced refactor(agent/auxiliary_client): densify header region (pre-_CodexCompletionsAdapter): inline _nous_policy_blocks/_TRUTHY_ENV_VALUES/_VERSION_CHUNK_RE, collapse guards, drop in-body blanks, compact docs (-214 lines) 2026-09-02 20:11:16 -07:00
Teknium cffa8206d8 refactor(agent/auxiliary_client): mechanical layout pass (hug closers, pack bracket spans; AST-identical) 2026-09-02 19:37:19 -07:00
Teknium 8542d822ac Merge branch 'simp/r3-03-aux-B' into simp/r3-03-aux 2026-09-02 19:33:04 -07:00
Teknium e65c6a9216 Merge branch 'simp/r3-03-aux-F' into simp/r3-03-aux 2026-09-02 19:05:08 -07:00
Teknium 16246ee4cf Merge branch 'simp/r3-03-aux-E' into simp/r3-03-aux 2026-09-02 19:05:05 -07:00
Teknium 9c92689551 Merge branch 'simp/r3-03-aux-D' into simp/r3-03-aux 2026-09-02 19:05:04 -07:00
Teknium f375304c0e Merge branch 'simp/r3-03-aux-C' into simp/r3-03-aux 2026-09-02 19:05:01 -07:00
Teknium 42b266d7b6 Merge branch 'simp/r3-03-aux-A' into simp/r3-03-aux 2026-09-02 19:04:59 -07:00
Teknium 769add5ea2 refactor(agent/auxiliary_client): split resolve_provider_client into per-provider branch helpers + dispatch table; phase-split _resolve_auto_route 2026-09-02 18:57:09 -07:00