Commit Graph

187 Commits

Author SHA1 Message Date
Maciej Lisiewski
f8bbe77f1a Merge pull request #156484 from sdyckjq-lab/fix/codex-app-server-persist-redaction
fix(security): redact codex app-server reasoning and content at the storage boundary
2026-11-18 19:36:53 +01:00
Teknium
06f48b59e6 fix(caching): keep-alive accounting writes through the agent's storage handle
Main's persistence interface makes the agent's store a storage handle with no
queue_token_counts; the warmer's keep-alive accounting called it on
agent._session_db directly and silently lost every refresh's usage. It now goes
through turn_usage.queue_usage, which takes the handle's usage repository (and
the worker store otherwise) with the session id and surface the keep-alive
captured when it was scheduled.
2026-11-18 03:40:34 -08:00
Teknium
bf9b193d7c refactor(caching): one owner per helper, no cross-module private imports
- Keep-alive totals go through turn_usage.add_session_usage, the same fold a response uses
  (it now also counts reasoning tokens, as a response does).
- PromptCacheWarmer._with_aux_hooks is auxiliary_hooks.run_with_aux_hooks with a lazy
  normalized= view; _rough_tokens is conversation_compression_manual.estimate_request_tokens.
- prompt_cache_is_cold lives in prompt_cache_clock (its only inputs), ending the
  turn_proactive_prune -> turn_preflight -> turn_proactive_prune circle; the read-dedup reset
  after a committed prune happens once, in _proactive_tool_result_prune, not at three call sites.
- Public names for the helpers other modules import: turn_usage.cache_clock_column /
  agent_session_source, context_compressor_summary.accepts_keyword_argument.
- archive_pruned_originals / archive_compaction_drops lose the never-passed skip= parameter.

Co-authored-by: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com>
2026-11-18 03:40:34 -08:00
yoniebans
db4d50b9e7 refactor(agent): the agent stores and repairs conversations through the persistence interface
The agent, run_agent.py and their helpers take a persistence handle instead of SessionDB. The store-side transcript repair moves beside the legacy store until the store is removed; agent/transcript_repair.py keeps the marker logic.

session_rules.turns is the one home of the message rules the agent shares with storage: the 56 agent functions whose bodies equal a session_rules.turns function are deleted, the agent and every other caller import them from session_rules.turns, and agent/message_content.py and agent/context_compressor_retry.py, left empty, go.
2026-11-17 17:51:20 +01:00
Kiro 有点Yes
f414c90ce1 fix(security): redact codex app-server rows at the storage boundary
The codex app-server runtime builds its assistant rows in
CodexEventProjector and flushes them from _persist_projected_messages,
bypassing build_assistant_message. A credential the model quoted in its
reasoning or reply therefore reached state.db (and the FTS index) verbatim,
while the chat-completions path masks both since #155288.

Scrub each projected assistant row there with the chat path's helpers:
redact_assistant_reply for content and redact_reasoning_fields for the
reasoning copy. Both follow security.redact_secrets, so redaction off stays
verbatim. The scrub runs after _transform_codex_reply, which locates the
final row by its raw text; masking inside the projector would hide a held
turn's final answer. Tool-call arguments stay verbatim (#43083).

Refs #43666
2026-11-16 10:43:57 +00:00
Teknium
58886fc81e fix(cache): coverage deadlines, guaranteed vs estimated ends, durable generation
The clock modelled every route as "expires = last touch + tier", which is wrong for OpenAI
GPT-5.6+: a read refreshes coverage to at least 30 minutes after it and never restarts a
12h write. It also treated documented minimums as expiries and lost or revived saved state.

- Coverage deadlines per tier with per-route refresh rules: Anthropic family restarts the tier
  on read; OpenAI keeps max(existing, read + 30m) and a 12h deadline stays at write + 12h.
- Windows carry guaranteed_until (earliest deadline, so mixed tiers in one response are only as
  warm as the shorter) and estimated_until (OpenAI: last touch + 24h retention ceiling; pre-5.6
  in_memory 1h). cache_certainly_warm / cache_certainly_cold are the two consumer helpers.
  /context: warm until / may still be warm until / expired / unknown.
- Events bind to the session's durable context generation (rows a compaction or prune archived,
  SessionDB.prompt_cache_generation), kept as saved on restore; a resumed agent restores and
  validates the saved event before folding its first response.
- Route identity is provider + normalize_route_base_url (scheme, host, port, path) + model.
- Agentless session.context_breakdown reads the saved clock (stored_cache_window).
- Codex app-server activity is recorded as an explicit unknown (it sets its own cache options).
- MoA records the resolved aggregator route and the payload the MoA client sent.
- effective_cache_ttl applies the route ceiling on the measured-provider path too.
2026-11-15 12:04:54 -08:00
Teknium
4a89bc6c02 feat(cache): one prompt-cache clock per session; Nous 5m ceiling as data
Every consumer that needs "when does this session's cached prompt expire?" now reads one
answer, agent/prompt_cache_clock.py:cache_window(), instead of re-deriving it from _cache_ttl.

- Per successful attempt the clock records the tier actually on the wire (cache_control ttl,
  prompt_cache_options.ttl, prompt_cache_retention, read from the sent payload), the send time,
  and the tier the response proved: Anthropic cache_creation.ephemeral_5m/1h_input_tokens,
  OpenAI Responses cache_write_tokens_details.ttl_30m/12h_tokens. normalize_usage keeps that
  split as CanonicalUsage.cache_write_by_ttl instead of dropping it.
- Per-route rules are a dict of small handlers: native Anthropic proves via the split;
  OpenRouter Claude is declared (live-probed to honour 1h); routes with a ceiling are clamped;
  other Anthropic-wire gateways assume 5m; OpenAI GPT-5.6+ proves via ttl_30m/12h or declares
  the documented 30m minimum; pre-5.6 assumes ~30m (5m on in_memory); implicit caches are
  unknown. expires = latest read-or-write send time + the written tier. A route switch,
  fallback, session rotation or compaction makes it unknown.
- Route TTL ceiling is data: ProviderProfile.prompt_cache_max_ttl (Nous ships "5m", because
  the Portal's upstream drops 1h after ~7 min and bills 5m), overridden per provider by config
  prompt_caching.route_ttl_ceilings. effective_cache_ttl uses the same helper, so Hermes stops
  asking Nous for 1h. A custom endpoint at the Portal host gets the Nous ceiling.
- Persisted as nullable sessions.prompt_cache_clock (JSON) through the existing token batch;
  restored lazily on resume, falling back to the newest assistant row (assumed).
- Codex app-server: read cacheWriteInputTokens instead of hard-coding cache_write_tokens=0.
- /context shows "Prompt cache: warm until HH:MM (…; 1h, proven)", "expired … ago" or
  "unknown (…)". The surface is absorbed from #142387 (render/duration helpers, the
  SessionContextBreakdownResult.prompt_cache contract and translations), reworked onto the clock.

Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
2026-11-15 12:04:54 -08:00
Teknium
bae3e59a75 fix(codex): redact secrets in native exec_command progress and tool cards
The bridge's display redactor (redact_tool_args_for_display) is identity
for native exec_command, and the commandExecution preview read the raw
item, so an API key in a codex shell command reached the progress preview
and both start/complete cards, including completion-only items.

One helper, _codex_display_args, now force-redacts the command text with
redact_sensitive_text (as the terminal tool's display path does) and feeds
the preview and both cards; the raw item and the started map stay
unmodified, so execution is unaffected.

The browser_type MCP test is replaced: browser_* tools are deliberately
not in the hermes-tools EXPOSED_TOOLS, so it guarded an unreachable path.
2026-11-13 16:41:36 -08:00
Teknium
044162fe11 fix(codex): redact tool args in the app-server event bridge's display callbacks
The codex app-server event bridge sent raw tool args to tool_progress_callback,
tool_start_callback and tool_complete_callback, the one tool-progress display
path that skipped redact_tool_args_for_display. A secret typed by a Hermes tool
run through the hermes-tools MCP server showed up in chat. The started-dict and
the executed args stay raw; only what the display hooks see is masked.

Part of #72298
2026-11-13 16:41:36 -08:00
Teknium
a995b69417 fix(state,codex): a dedupe claim never drops a different message; a cut codex stream retries
Review H on #144938:

- Codex: the narration recovery for an announced answer item now needs a terminal frame. A stream that
  ends mid-turn (answer announced, partial text, a call announced, no terminal frame) raises "did not
  emit a terminal response" and retries, as on main, instead of completing on the cut-off sentence with
  the call lost. Text deltas follow the phase of the item they name, so commentary that arrives after a
  call announcement is no longer fused into the recovered answer.
- Compaction carry: a dict that names its row by _row_id claims only that row; a message_uid claim needs
  the same identity (a same-uid row with newer content is kept and cloned); an identity+timestamp claim
  is refused when the dict's uid differs from the row's. Rows claimed by identity alone are archived as
  compacted history instead of rewound, so a wrong claim stays visible in display.
- Flush guard: a restored dict whose uid is ACTIVE is skipped only when it serializes to that row's owned
  columns; an edit since the restore inserts, as on main.
2026-10-27 11:49:40 -07:00
Teknium
7d1c2dc612 fix(codex): recover answer text only from an announced answer message item
The narration fix synthesized a message from any buffered output_text deltas
whenever no answer message item completed. That also promoted bare
output_text beside a commentary item, which main's completion contract
(test_auxiliary_codex_completion_status
[tool-call-like-output-text-beside-commentary]) keeps as narration with
finish_reason=length. Beside calls/commentary, synthesize only when an
assistant answer message (not commentary/analysis) was announced via
output_item.added and its done event never arrived; the no-output plain-text
synthesis is unchanged.
2026-10-27 11:49:40 -07:00
Teknium
e4347f96b1 fix(codex): keep answer text sent beside a tool call when its message item never completes
_CodexResponseAssembler.result() synthesized a message from buffered output_text deltas only when the
stream carried no tool call. A backend that announces a call, streams narration in a message item and
never sends that item's done event (the relay shapes in #143893) lost the narration whenever a
commentary item was also present, because the normalizer's output_text fallback is skipped once a
commentary phase is seen. The turn then stored an empty assistant row and showed no bubble.

result() now synthesizes the message whenever no answer-phase message item exists, tool calls or
not, and places it before the first call. Commentary and analysis deltas never enter text_deltas, so
they are unaffected.

Live (real tui_gateway.entry + scripted codex_responses stub): base stores '' for the narration
turn and the resumed transcript lacks it; head stores and paints it.
2026-10-27 11:49:40 -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
6030e77121 fix(hold-stream): no side path delivers a held turn's original text
Independent review of the hold_stream feature found four paths that still
let the untransformed reply or commentary reach the user:

- History loads showed held commentary. The tool-call assistant row of a
  held turn is now typed display_kind="hidden" before its first flush
  (withhold_held_commentary), so TUI/Desktop display_projection, the
  dashboard and classic CLI resume skip it. display_kind never reaches the
  wire: the model's context and cached prefix are unchanged (test replays
  the resumed session and compares the request bytes). The TUI projection
  still labels the hidden row's tool cards from its calls. Codex held turns
  type their earlier agentMessages hidden the same way.
- A plugin reload mid-turn could empty the hook registry before the final
  transform. The held turn now snapshots its transform_llm_output callbacks
  together with the hold decision under the discovery lock
  (held_stream_transforms) and runs that snapshot at the final. If no
  callback rewrote and one raised or timed out, the user gets a fixed
  "reply withheld" notice instead of the original (fail closed).
- Classic CLI replay-gap recovery painted and spoke pre_transform_response.
  A held turn's result (generic and codex) no longer carries the original
  at all (public_pre_transform), so receipts, recovery and post-stream
  suffix painting only ever see the rewrite.
- Codex error-after-text returned the raw agentMessage. The codex reply is
  now transformed whenever it has text, also when the turn errored (and,
  when held, when interrupted).

Same class, also fixed: the end-of-stream scrubber flush recorded a held
tail as streamed text (an interrupted turn could return it as an
untransformed partial final), and quiet-mode CLI printed held commentary
via _vprint.
2026-10-25 06:18:48 -07:00
Teknium
995dac1bec fix(codex): sync external memory with the transformed codex reply
The codex app-server bookkeeping passed turn.final_text (pre-transform)
to _sync_external_memory_for_turn, so a memory provider stored the text
a transform_llm_output plugin removed. Pass the reply the user got, as
the generic loop's finalizer does.

Review: https://github.com/NousResearch/hermes-agent/pull/144266#discussion_r4369545047
2026-10-25 06:18:48 -07:00
Teknium
53b086aee8 fix(codex): run transform_llm_output on codex app-server replies
The codex app-server runtime returns before finalize_turn, so
transform_llm_output never ran there (pre-existing): a rewriting
plugin's change never reached the user or the stored assistant row,
and with hold_stream the user waited only to get the raw reply.
Apply the transform before the projected rows are persisted and return
response_transformed / pre_transform_response like the generic loop.

Review: https://github.com/NousResearch/hermes-agent/pull/144266#discussion_r4369515509
2026-10-25 06:18:48 -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
mnajafian-nv
1c97c0ec35 fix(relay): emit no compaction mark from an uninstrumented turn or a detached fork
A second concurrent turn on a live session (a background-review fork or
a concurrent gateway turn) runs with Relay instrumentation off, but its
compaction mark fell back to the live session's scope. The mark claimed
the live conversation was compacted when only the fork's throwaway
transcript was, and the reserved compaction name reset the live agent
scope's freshness. That also bypassed the opt-out resolve_execution_context
honors.

_resolve_target now returns nothing when relay_instrumentation_enabled()
is false. Publishing also skips persistence-detached agents
(_persist_disabled, set on background-review forks), as micro-compaction
already does in the turn finalizer.

The proactive prune mark moves from ContextCompressor to its caller in
turn_preflight, the one place that knows the agent. That lets it skip a
fork, name the agent's session (a compressor without a bound session id
used to drop the mark), and measure tokens with the same rough message
estimate the attempt record uses.

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
(cherry picked from commit 37e177f1494570303f4a010534273a64760b30d3)
2026-10-10 04:27:27 -07:00
mnajafian-nv
a64501e60c feat(relay): emit compaction marks from the compression attempt record
Hermes rewrites a session's history in several ways (batch summary,
deterministic fallback, micro-compaction, proactive tool-result prune,
Codex thread compaction) but never told Relay about any of them. A Relay
consumer could not see what was compacted, why, when, how long it took
or whether it went through compress_context, and Relay never reset
LLM-history freshness after a rewrite, so LLM starts after a compaction
stayed projected to the current user turn.

agent/compaction_events.py builds one flat, content-free
hermes.compaction v1 record per rewrite with closed enums (kind, scope,
official, method, trigger, trigger_class, outcome, failure_class) and an
other fallback, plus the effect counts and timings the attempt record
already carries. agent/relay_compaction.py emits it with the existing
scope.event API on the owning session's scope stack: under the live turn
of the same session, else under the session scope, else not at all.

A committed history or provider rewrite uses Relay's reserved
compaction mark name, which resets freshness for the session's agent
scope; every other outcome is a compaction.attempt mark. Records come
from the single attempt telemetry seam (so blocked, Codex-routed and
aborted attempts are covered), the micro-compaction telemetry record,
the proactive prune commit and Codex-native compactions Hermes observes.
No payload carries message, summary, focus-topic, error or path text,
and publishing never raises into compaction.

The marks are on whenever the Relay runtime is live; Relay exporters are
configured separately, so this adds no outbound path and no config key.

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
(cherry picked from commit dc5fd0875e7ec895b7826ee829bfc1b7f082de97)
2026-10-10 04:27:27 -07:00
ethernet
8ac5c74432 Harder linter fixes (#135281)
* ci: fix B004 linter rule

* ci: prefix unused variables with underscore (RUF059)

* ci: don't cast int to int

* ci: remove unnecessary if/else where both blocks yield same result

* ci: RUF024

* ci: fix RUF017, RUF018, RUF022

* ci: RUF013, RUF015

* ci: RUF007

* ci: RUF009

* ci: address code review
2026-10-08 18:56:50 -04:00
Teknium
a9e2716c9b fix(codex): confirm a pending call whose call_id first appears on its done item
When the announcement carries no call_id and the done item does, the
call_id-exclusive lookup found nothing and left the announcement pending;
response.completed then settled it as a second call. Fall back to the
item/index match only when the matched announcement has no call_id of its
own, so a conflicting call_id still never evicts an unrelated call.
2026-10-08 14:10:45 -07:00
VictorYXL
c3302dd4fb fix(codex): integrate pending call-id aliases with stream correlation
Port PR #94708 to _CodexResponseAssembler, preserving rotating argument IDs and output ordering. Coalesce all matching call_id aliases, inherit earliest announcement metadata, and protect unrelated calls from conflicting item/index identities.

Adapted from commit 70b311ee50a0350b79c6c2b6123754d6aa6505da (PR #94708).

Verification: 130 focused tests passed; independent review passed.

Co-authored-by: DragonLi-Mi <4321063+DragonLi-Mi@users.noreply.github.com>
2026-10-08 14:10:45 -07:00
DragonLi-Mi
5e24de476d fix(codex): preserve calls across rotating stream item IDs
Match pending argument and completion events by output_index when item IDs change. Preserve authoritative arguments and successful output ordering without settling the same call twice.

Verification: independent code review passed; 75 focused tests passed; live Copilot Responses probe passed.
2026-10-08 14:10:45 -07:00
Maciej Lisiewski
74f1f17a7e ci: fix RUF017, RUF018, RUF022 2026-10-08 19:54:07 +02:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
kshitijk4poor
c61242020b fix(codex): hermes chat -q codex exec/apply_patch approvals fail closed at once
_ensure_codex_session handed the codex app-server session whatever CLI panel
callback the thread had. `hermes chat -q` registers one, so every codex
exec/apply_patch approval request in a -q (kanban worker) turn waited the
full panel timeout for nobody. With no callback the session's existing
"decline" path answers immediately; an approval bypass still auto-approves.
2026-10-05 20:08:11 +05:30
kshitijk4poor
cdb8fd3ef2 test(codex): give the no-socket drain-skip test deterministic teeth
The test previously asserted only wall-clock elapsed < 2s, which passes
whether or not the drain is skipped because the fake stream ends
immediately. Record any read past the terminal frame and assert there
were none, so re-enabling the drain without a shutdown-capable socket
fails deterministically. Also inline the single-use _post_terminal_socket
helper at its call site (keeping the exception guard, since the drain
sits outside the inner try; _socket_from_response already handles a
None response), and drop `x and` / bare-truthiness preambles that the
following set-equality asserts already imply.
2026-10-03 16:31:39 +05:30
kshitijk4poor
06be0643c9 refactor(codex): share response socket walk and simplify post-terminal drain
_post_terminal_socket duplicated the response -> network_stream/stream ->
connection-candidate walk from _shutdown_stale_attempt_socket. Hoist it into
agent_runtime_helpers._socket_from_response (next to _socket_from_candidate)
and use it from both sites; each caller keeps its own error handling. Drop
the dead event_stream argument: ManagedLlmStream has no .response, only the
raw SDK stream does.

Fold watchdog.start() into the drain try so cancel/join lives once in the
finally (join only when a thread was actually started), replacing the
duplicate start-failure branch and its suppress-wrapped join.

Close guard: relay_llm.stream is ManagedLlmStream, whose close() always
exists and owns the provider stream, so the raw stream only needs closing
when construction failed (event_stream is None). Behaviour-equivalent to the
callable(close) probe.
2026-10-03 16:31:39 +05:30
kshitijk4poor
b342fe5ee8 refactor(codex): drop unused close return and logger suppress wrappers
_close_event_stream's new bool return has no caller that reads it, so
restore the original None-returning shape (and the original comment).
The suppress(Exception) blocks around logger.debug/warning calls in the
post-terminal drain guard against nothing real: logging already swallows
handler errors, and wrapping them hides genuine bugs in the arguments.

Fixes #127390.

Co-authored-by: Eva <239388517+100yenadmin@users.noreply.github.com>
2026-10-03 16:31:39 +05:30
JoaoMarcos44
025ca0021b fix(codex): avoid duplicate raw stream close
(cherry picked from commit ce144487fad926a0494d2b5712a7fdd2e13ff3b2)
2026-10-03 16:31:39 +05:30
JoaoMarcos44
a1cb9794d8 fix(codex): keep post-terminal stream close on reader thread
(cherry picked from commit 9cfbf157c7b5c4d524fa47ff8ee3e773e683d8f4)
2026-10-03 16:31:39 +05:30
kshitijk4poor
3f4aedb37e fix(codex): Ultra stays codex's harness mode on the app-server
The app-server turn effort was clamped to the Responses vocabulary, so a Hermes
`ultra` pick reached codex as `max` and never ran codex's Ultra harness mode.
Live on codex-cli 0.147 with ChatGPT auth, `turn/start.effort = "ultra"` runs on
gpt-5.6-sol and gpt-5.6-luna (ladders reach `max`) and fails with 400
"'max' is not supported" on gpt-5.5, so `ultra` is now kept wherever the
model's ladder reaches `max` and clamped as before everywhere else. One rule,
route_supported_efforts(..., api_mode="codex_app_server"), drives the turn and
the labels: session.info's reasoning_effort_wire (the Desktop pill) and the CLI
and gateway /reasoning status read "ultra" instead of "ultra (sends max on this
route)" there. A named custom codex provider keeps the clamp.

From #130965 (Ultra passthrough and route-aware labels), narrowed to the
models that accept it.

Co-authored-by: FroRaut <79215537+Froraut@users.noreply.github.com>
2026-10-03 16:29:34 +05:30
kshitijk4poor
961035ab90 refactor(codex): resolve app-server turn settings inside the turn's failure handler
The wire model, effort and tier were computed before the try around
run_turn, so an exception there skipped the failed-turn path (log, close
the session, fall back to /codex-runtime auto). They are computed inside it
again, as the wire model was before. The effort clamp reuses
classify_responses_route (also counts a chatgpt.com/backend-api/codex base
URL and xAI) instead of a provider check, and the codex tier names live in
fast_mode.CODEX_TIER_WORDS beside the other tier tables.
2026-10-03 16:29:34 +05:30
kshitijk4poor
9cc737019b fix(codex): send the app-server service tier Hermes requests, only when it changes
The forwarded tier was agent.service_tier mapped by hand, so "auto",
"cold" and "ultrafast" went to codex verbatim, and a null went out on every
normal turn, overriding a tier configured in codex itself.

- The tier now comes from effective_request_overrides(agent), the same
  source the Responses path sends: a static /fast tier pinned per
  model/route by every surface, or an open auto/cold window. It goes out in
  codex's words (OpenAI "priority" is codex "fast"); a tier codex has no
  word for (ultrafast) is not sent.
- The session remembers the tier its thread last received and sends
  serviceTier only on a change. A new thread starts from codex's configured
  default. A resumed thread is treated as unknown, so its first turn sends
  Hermes' tier even when that is a clearing null: CLI /fast rebuilds the
  agent, and "/fast off" must reach a thread that still carries fast.
2026-10-03 16:29:34 +05:30
kshitijk4poor
02d1c689a7 fix(codex): clamp the app-server turn effort to the route's vocabulary
The forwarded effort was Hermes' raw reasoning_effort, and Hermes has levels
the backend does not: live on codex-cli 0.147 with ChatGPT auth, a turn
with effort "ultra" fails with 400 "Unsupported value: 'max' is not
supported". Resolve it through the Responses transport's _resolve_reasoning
(nearest weaker supported level, "none" only where the route accepts it),
and only when Hermes has an explicit reasoning setting, so codex's own
configured default is otherwise left alone.
2026-10-03 16:29:34 +05:30
Apoorva Garg
349bfd4c94 fix(codex): propagate app-server runtime overrides
Hermes built turn/start with only threadId and input, so the app-server
kept codex's inherited settings after Hermes changed its live agent state:
reasoning effort and /fast never reached the codex thread. Each turn now
carries the active reasoning effort (none when reasoning is disabled) and
the service tier (Hermes "priority" -> codex "fast"; null clears an
earlier tier), alongside the per-turn model main already sends.

Salvaged from #65599 onto current main; the per-turn model part landed via
#130735, so this keeps the reasoning effort and service tier.
2026-10-03 16:29:34 +05:30
kshitijk4poor
8eb8f2da0a fix(codex): an in-place provider switch retires the app-server thread
turn/start can change the model but not modelProvider, which is fixed when the thread starts. With the model now forwarded per turn, switching in place between codex's own provider and a named custom provider would send the new provider's model to the old provider's thread. Record the thread's model provider next to its prompt composition and retire the thread when either changes.
2026-10-01 23:33:52 +05:30
kshitijk4poor
8b3e565936 fix(codex): codex's own provider gets the bare model slug on the app-server
The OpenAI API-key rung reaches the app-server as provider=custom with no
codex model_providers id, and its model is not vendor-normalized at agent
init (only openai-codex is), so a configured "openai/gpt-5.5" now went to
codex verbatim where it was previously dropped for codex's default. When
codex's own provider serves the turn, normalize the slug the way
openai-codex does; a named custom provider's model ids pass through.

The provider lookup moves into _codex_model_provider and is passed to
_codex_wire_model, and the session comment now says model is sent for every
provider, modelProvider only for named custom providers.
2026-10-01 23:33:52 +05:30
kshitijk4poor
78cd32c81c fix(codex): an in-place /model switch reaches the live app-server thread
The CLI/TUI /model switch mutates the running agent, and its codex session
(and thread) is reused, so the model fixed at thread/start stayed in force
for the rest of the session. turn/start accepts a model that codex applies
to that turn and later ones (codex 0.147 schema; live: a thread started on
codex's default ran a turn on gpt-5.5 with modelContextWindow 258400).
Every turn now sends the agent's current wire model.
2026-10-01 23:33:52 +05:30
kshitijk4poor
922eb16da7 fix(codex): send the base slug for -900k picker variants to the app-server
With the model now forwarded, a selected -900k alias reached codex verbatim
and every turn failed: live on codex 0.147 with ChatGPT auth,
thread/start {model: "gpt-5.6-sol-900k"} -> turn 400 "The
'gpt-5.6-sol-900k' model is not supported when using Codex with a ChatGPT
account". The alias is Hermes-side only (the Responses transport already
strips it); codex applies the catalog's extended window to the base slug on
its own (thread/tokenUsage reports modelContextWindow 828400 for
gpt-5.6-sol). Strip the valid suffix before it goes on the wire.
2026-10-01 23:33:52 +05:30
cucurigoo
27f2c5a486 fix(codex): preserve session model in app-server threads
Codex homes are service-scoped while Hermes model selection is profile and
session scoped. thread/start only carried the model for named custom
providers, so openai/openai-codex sessions on model.openai_runtime:
codex_app_server silently ran codex's own default model, whatever /model or
config.yaml selected. Forward the agent's model on every thread/start;
the custom-provider modelProvider id and the no-credential payload are
unchanged.

Salvaged from #83269 onto current main (the session already accepts model=
since #115905; the forwarding was narrowed to custom providers there).
2026-10-01 23:33:52 +05:30
kshitijk4poor
bdde674296 feat(fast): /fast ultrafast for GPT-6 Astra, priced at the served tier
OpenAI's Ultrafast service tier (service_tier="ultrafast") is broadly
available for GPT-6 Astra in the API and Codex (Pro 500 / Enterprise),
billed at 6x Standard. GPT-6.1 Sol Ultrafast is announced as coming soon.

- One tier table: agent.fast_mode.parse_service_tier / STATIC_TIERS now
  back the CLI, gateway and TUI config loaders (three hand-copied parsers).
- resolve_fast_mode_overrides(tier="ultrafast") sends the tier only for
  Ultrafast models on api.openai.com / chatgpt.com; anything else gets
  nothing rather than a silent swap to another paid tier.
- /fast ultrafast on CLI, gateway (typed + picker when supported) and TUI;
  static-tier attach sites pass the tier through.
- Pricing: the response's SERVED service_tier is folded into usage (Codex
  stream assembler keeps it); served ultrafast prices from a published
  6x row (272K whole-request tier included). A request asking for
  Ultrafast but served at default bills at Standard.
- i18n: 4 new keys in all 17 locales; option lists mention ultrafast.
2026-09-29 23:54:34 +05:30
Teknium
a5bd246865 Old pre-decomposition import paths are gone: plugin compat layer removed on schedule (#126164)
* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule

The PLUGIN-COMPAT layer (2776813df3 + d63e380324 + 0a5164cebe) kept pre-#102117 import paths
alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader
has already been skipping plugins that use the old paths. This removes the layer itself:

- 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party
  names, restored dead definitions) and the three re-export stub modules
  (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils)
- COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step
- the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section,
  the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the
  `plugins.allow_deprecated_imports` escape hatch

An external plugin that still imports an old path now fails to load with its ImportError as the
reason in `hermes plugins list`, the same path as any broken plugin.

hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect,
summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout
swap (tests/compat/old_updater_surface.json).

In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its
`shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for
the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed
`run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the
seam production reads, like every sibling test in that file.

* chore: retrigger CI (zero-job startup_failure phantom)

* test: drop resolution allowlist rows for the two deleted which() sites

hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available
(a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires
their allowlist entries go with them.
2026-09-28 10:21:41 -07:00
h4ck200711
4e0d638023 fix(codex): keep Codex web searches in stored history as tool calls
Codex app-server webSearch items fire the live tool bubble under
codex_web_search_<itemId>, but the projector had no entry for them, so the
stored transcript kept an opaque "[codex webSearch] {json}" note instead.
Any transcript refresh or reopen then replaced the search card with raw
JSON.

The projector now records webSearch as a web_search tool_call under the
same id and name the live bubble uses. The tool result is
{"provider": "codex", "status": ...}, so a later non-Codex turn can tell
Codex ran the search.

Salvaged from #66995: only the webSearch projection is kept, reworked
onto the _TOOL_PROJECTIONS table and the live web_search name. The MCP
elicitation trust change is not included.
2026-09-28 19:11:05 +05:30
kshitijk4poor
7fb8736a1e refactor(codex): single source for app-server delta methods and delta text
The event bridge listed the text-delta methods twice (display handlers and
the #118410 liveness set) and duplicated _fire_delta's text extraction.
Derive both from _CODEX_TEXT_DELTA_METHODS, share _delta_text(), and hoist
the progress item-type set to a module constant (no per-event frozenset).
2026-09-24 22:38:35 +05:30
zxd
94727893b2 fix(codex): refresh turn liveness from app-server progress
(cherry picked from commit 677fde44763a0db4cba457de831bfd049f6c2b17)
2026-09-24 22:38:35 +05:30
kshitijk4poor
3d704f53e1 docs(agent): keep the comment next to the line it explains
Final-gate quality nit: the comment was stale or sat away from its line.
2026-09-24 15:58:19 +05:30
kshitijk4poor
628094ee0e test(agent): give watchdog stubs progress_timeout; drop eager time.time() from stream-open log
The attempt-local first-progress deadline added `progress_timeout` to
`_NonStreamWatchdogs`, but the SimpleNamespace stubs in
test_nonstream_wait_notice.py and test_wait_notice_cadence.py were not
updated. `_emit_wait_notice` reads `wd.progress_timeout` inside its
blanket `except Exception`, so the AttributeError silently produced no
notice and no liveness touch: 11 tests red.

The new "Codex stream opened" debug line also called `time.time()`
eagerly, consuming a tick of the 3-tick stub in
test_codex_first_event_timing.py and shifting the first-event stamp.
The first-event log a few lines below already carries the attempt's
timeline anchor, so the open marker logs without an epoch.
2026-09-24 15:58:19 +05:30
kshitijk4poor
6a116551dc refactor(codex): log stream-open marker at debug level
The per-attempt "first parsed event" / "first substantive progress" /
"physical retry" markers are what an operator needs to see where a
lifecycle-only Codex attempt stalled, so they stay at info. The
"stream opened" line fires on every attempt and carries no diagnostic
value on its own, so it goes to debug to keep the default log quiet.

Co-authored-by: JoaoMarcos44 <joaomarcosdias444@gmail.com>
2026-09-24 15:58:19 +05:30
JoaoMarcos44
48b300843e fix(agent): keep Codex first-progress deadline attempt-local
(cherry picked from commit 13013f63f2e6fdc19c28cd3d7dfea4120fb7ab6f)
2026-09-24 15:58:19 +05:30