Commit Graph

4187 Commits

Author SHA1 Message Date
Teknium 8c4012fac0 Merge branch 'simp/r3-35' into hermes/simplify-codebase 2026-09-03 04:34:20 -07:00
Teknium e010327ff7 Merge branch 'simp/r3-34' into hermes/simplify-codebase 2026-09-03 04:34:19 -07:00
Teknium 3bff2a581d Merge origin/main (562ee8ab76): fold usage-less empty-response guard, unterminated tool-call strip, skills-first memory guidance into the simplified modules 2026-09-03 04:31:46 -07:00
Teknium 562ee8ab76 fix(prompt): agent routes task-learned knowledge (incl. user preferences/corrections) to skills; memory is the every-session exception
The memory guidance led with 'Save proactively' and the memory tool schema
ranked 'user preferences & corrections' as top priority, while the skills
nudge was a conditional 'offer to save'. In practice that asymmetry made
the agent end sessions writing memory entries (fighting a 2,200-char
budget) and skip updating the skill it had just used, even though the
procedure was the reusable artifact. Both surfaces now state the same
rule with skills first: what you learn doing a task, including the user's
preferences and corrections for that kind of work, goes in the task's
skill; memory is only for facts that apply to every session.
2026-09-03 04:02:35 -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 23b9ffc4fa fix(integration): restore subprocess stdin=DEVNULL / utf-8 encoding guards and windows-footgun gates dropped by round-3 compaction
Repo scanners (check_subprocess_stdin, check-windows-footguns --all) flagged 21 sites where
the r3 single-line collapses lost stdin=DEVNULL, encoding='utf-8'/errors='replace', the
'# windows-footgun: ok' same-line marker, or the getattr(os, 'geteuid') gate. Each guard is
restored at the call site (real portability/hang fixes, not suppressions).
2026-09-03 02:46:19 -07:00
Teknium 561b053f79 perf(agents): run per-child timers on one shared scheduler thread
A fan-out of N in-process subagents used to add one sleeping daemon
thread per delegated child (delegate heartbeat, 30s) and one or two per
active turn (durable turn-lease refresher; turn-liveness watchdog).  A
profiled session with ~130 children was carrying ~1000 threads.  All
of these timers now run on a single process-wide daemon thread.

- agent/periodic_scheduler.py (new): heap-ordered periodic scheduler on
  one Condition-driven daemon thread.  schedule(fn, interval) -> handle;
  handle.cancel(wait=) blocks for an in-flight run like the old join.
  A callback returning False stops itself; a raising callback is logged
  at debug and rescheduled, so one bad timer cannot kill the rest.
- tools/delegate_tool.py: _heartbeat_loop body -> _heartbeat_tick,
  scheduled at _HEARTBEAT_INTERVAL; stale-cycle closure state and
  idle/in-tool thresholds unchanged; cancel(wait=5) in finally where the
  stop-event + join(5) lived.
- run_agent.py: _refresh_durable_turn_lease body scheduled at
  _lease_refresh_interval; lease-lost / refresh-error interrupt paths
  and the stop-event fencing are unchanged; the join(timeout=1.0) is now
  cancel(wait=1.0) so the interrupt clear still runs after any in-flight
  tick.
- agent/turn_liveness.py: TurnLivenessWatchdog.make_thread/start ->
  schedule(); the poll body is _tick(), same sampling state machine.

Bench (evals/fanout_resource_bench.py, 30 children / 10 worktrees,
ok=30/30 both): peak threads 168 -> 132.  At peak the old tree held 30
"Thread-N (_heartbeat_loop)" threads; the new one holds zero plus one
"hermes-periodic-scheduler".
2026-09-03 02:44:24 -07:00
Teknium 1ce9ced0a6 refactor(tools): skills_sync_client write_sync_state uses utils.atomic_write_text (skill_usage._atomic_write was unified away) 2026-09-03 01:48:35 -07:00
Teknium 8cd2dbe6e8 merge simp/r3-34-F pass2 into simp/r3-34 2026-09-03 01:31:07 -07:00
Teknium 7664005a5d refactor(tools): pack tts constant tables, writelines for elevenlabs, lease release result literal 2026-09-03 01:23:19 -07:00
Teknium 01262a79eb refactor(tools): fold sniff/read into one with-block, lifecycle timing locals 2026-09-03 01:21:30 -07:00
Teknium b33d84bb21 merge simp/r3-34-H pass2 into simp/r3-34 2026-09-03 01:21:16 -07:00
Teknium 0f66267bf4 merge simp/r3-34-G pass2 into simp/r3-34 2026-09-03 01:21:15 -07:00
Teknium e9bed90bb3 merge simp/r3-34-D pass2 into simp/r3-34 2026-09-03 01:21:15 -07:00
Teknium 7f87550c68 refactor(tools): fold gemini base_url/xai rate locals, lease result merge 2026-09-03 01:20:15 -07:00
Teknium 5752c2dd68 refactor(tools): iter-sentinel drain, fold ogg repair guard, speaker init tuple, PEP8 blank fix 2026-09-03 01:17:43 -07:00
Teknium 58b0f218c4 refactor(tools): fold tts voice-delivery native branch, config-load fallthrough, speaker one-liners 2026-09-03 01:15:20 -07:00
Teknium e0df9656bb refactor(tools): group H — BM25 loop fold, catalog/selection/limits micro-collapses, sync-manager walrus 2026-09-03 01:13:51 -07:00
Teknium ff44eca74f refactor(tools): compact STT module docstrings and section banners, keep every invariant 2026-09-03 01:13:03 -07:00
Teknium f0cac15ad1 refactor(tools): collapse tts delivery profile/packing locals, speaker aligner tail, wrap long import 2026-09-03 01:12:56 -07:00
Teknium 31017623e9 refactor(tools): tool_result_storage/backend_helpers/validation — flatten persist branch, comprehension-based budget candidates, single-return raw section, path formatting fold 2026-09-03 01:11:35 -07:00
Teknium 636bf247e8 refactor(tools): wrap over-long tts call lines (AST-neutral) 2026-09-03 01:09:56 -07:00
Teknium d2f2862d51 refactor(tools): fold single-use readiness helpers, compact module docstrings, wrap long lines 2026-09-03 01:09:55 -07:00
Teknium 136ac31065 refactor(tools): group H — _registry_toolset helper unifies deferral/source lookups, partial() config loaders, Counter/dict-comprehension folds, legacy-config path collapse 2026-09-03 01:09:12 -07:00
Teknium df4547570a refactor(tools): squeeze in-body and banner blank lines in tts modules 2026-09-03 01:09:11 -07:00
Teknium d3fdabe5c9 merge simp/r3-34-C pass2 into simp/r3-34 2026-09-03 01:07:38 -07:00
Teknium a3ce6dd4cb refactor(tools): compact tts providers/openai/speaker — fold aux-reply parsing, iter sentinels, blank squeeze 2026-09-03 01:07:09 -07:00
Teknium 0994c01d1d refactor(tools): group H — pack multi-line signatures, config-default one-liners, exact-match score fold 2026-09-03 01:03:20 -07:00
Teknium 198fe72a35 refactor(tools): compact TTS command/streaming/normalizer docstrings, keep every invariant 2026-09-03 01:02:21 -07:00
Teknium cf48ad80f3 refactor(tools): todo/tool_search — fold validate/normalize guards, dedupe key expression, arguments-null default 2026-09-03 01:01:57 -07:00
Teknium 6df5cbb6d1 refactor(tools): collapse tts_tool/delivery/local/lifecycle/plugins guards and single-use locals; tighten docstrings 2026-09-03 01:00:06 -07:00
Teknium 5645bc3cd0 refactor(tools): fold tool_search_names into tool_search_catalog (single importer pair), dict-dispatch modal backend selection, compact registry.register calls and shebangs 2026-09-03 00:59:55 -07:00
liuhao1024 b462989a68 fix(vision): honor supports_vision_tool_messages=False in tool-result media gates
A ProviderProfile that declares supports_vision_tool_messages=False accepts
images in user messages but rejects list-type tool-result content with 400
(xiaomi/MiMo "text is not set"). supports_vision=True alone used to flip
_supports_media_in_tool_results to True, and a vision-capable capability
lookup could re-open _should_use_native_vision_fast_path — so the native
multimodal envelope landed in a role:tool message and 400'd every turn.

Both gates now go through one _profile_rejects_tool_media() veto.

Refs #89981

(cherry picked from commit daed88f940a6a475f12bb435498e48181da60f4d, trimmed)
2026-09-03 00:57:40 -07:00
Teknium 412ddb6772 refactor(tools): drop unreachable legacy TTS strip fallback and duplicated streamer sample rates; STT/TTS config wrappers as partials 2026-09-03 00:57:29 -07:00
Teknium dc5ca5a461 refactor(tools): skills group pass 2c — walrus/guard folds in skill_usage and skills_guard, ast_audit suppress(), skillevaluator/provenance header compaction, docstring tightening 2026-09-03 00:55:09 -07:00
Teknium 282d714837 refactor(tools): AST-neutral layout compaction of tts modules (hug brackets, join closers) 2026-09-03 00:54:51 -07:00
Teknium 9bcf3069eb refactor(tools): dedup stat check, secret-capture walrus, comment reflow 2026-09-03 00:53:28 -07:00
Teknium d85b86e97a refactor(tools): AST-neutral closer/bracket hug pass over STT/TTS modules 2026-09-03 00:53:14 -07:00
Teknium 404a324ea5 refactor(tools): fold local STT loader/gates and TTS normalizer passes into table-driven substitutions 2026-09-03 00:52:11 -07:00
Teknium 05c6da2985 refactor(tools): drop test-only _has_any_command_tts_provider, fold tts provider write paths and speaker text pump 2026-09-03 00:51:58 -07:00
Teknium 9197b7926f refactor(tools): bundled-ops/sync guard folds (reset messages, read_for_diff, orphan recovery) 2026-09-03 00:51:10 -07:00
Teknium 2ad265ea78 refactor(tools): tool_search — hug import/__all__/frozenset closers 2026-09-03 00:49:48 -07:00
Teknium 78203e36f8 refactor(tools): tool_search_validation/output_limits/spill_safety — flatten required probe and section guard, pack signatures, compact docstrings 2026-09-03 00:48:26 -07:00
Teknium 97b554f200 refactor(tools): fold command/plugin STT and audio prep bodies — inline single-use locals, merged guards, squeezed blanks 2026-09-03 00:48:24 -07:00
Teknium fcc969d6a7 refactor(tools): skills group pass 2b — skill_usage state/relocate/archive collapse, _backfilled merge, dedup ints; skills_guard ignore constants inlined, verdict/report joins, single stat; ast_audit/skillevaluator flattening 2026-09-03 00:48:19 -07:00
Teknium c37eff79e3 refactor(tools): skills_tool_setup folds setup-metadata normalizer into the env-var merge 2026-09-03 00:48:15 -07:00
Teknium 45fb404019 refactor(tools): share tts _origin/_section/_remove_quietly via delivery module; fold gemini json body parsing, media tag, stream reinit 2026-09-03 00:47:54 -07:00
Teknium f6f12e3586 refactor(tools): todo/tour/tip — fold status/parent guards, pack signatures and error strings, drop in-body blank lines 2026-09-03 00:47:02 -07:00
Teknium 3c5292f7dd refactor(tools): skills_tool guard collapses (plugin stale-entry, disabled check, search dirs); sync comment compaction 2026-09-03 00:46:45 -07:00
Teknium 35c32f6498 refactor(tools): fold cloud STT request builders — single-use locals, hoisted ASR regex, merged with-blocks 2026-09-03 00:46:20 -07:00