Commit Graph

3748 Commits

Author SHA1 Message Date
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 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
Teknium 7a08103c14 refactor(agent/auxiliary_client): split recovery ladder into rung helpers, unify call_llm twins 2026-09-02 18:47:58 -07:00
Teknium 4bd0569264 refactor(agent/auxiliary_client): dedupe resolver/fallback region — shared classifier core, refresher dispatch, twin unification 2026-09-02 18:37:07 -07:00
Teknium 210f668e22 refactor(agent/auxiliary_client): split Codex/Anthropic adapter god methods into a stream guard + phase helpers 2026-09-02 18:31:27 -07:00
Teknium 33b6ca4992 refactor(agent/auxiliary_client): compact module docstring 2026-09-02 18:30:50 -07:00
Teknium d477279ceb refactor(agent/auxiliary_client): compact header region, unify model-slug + semaphore helpers 2026-09-02 18:29:33 -07:00
Teknium eee3f2d5dc refactor(agent/auxiliary_client): split _build_call_kwargs into phase helpers, share stream plan/close, compact request+streaming region 2026-09-02 18:26:59 -07:00
Teknium 5fb24e4ab9 refactor(agent/auxiliary_client): split vision routing + task provider resolution into phase helpers
- resolve_vision_provider_client: 178 -> 53 LOC via _finalize_vision_client,
  _vision_main_provider_client, _vision_auto_route; ZAI URLs as module tuple
- _resolve_strict_vision_backend: if/elif chain -> _STRICT_VISION_BACKENDS dispatch
- _resolve_task_provider_model: 137 -> 68 LOC; nested closures hoisted to
  module helpers (_unwrap_moa_provider, _expand_direct_api_alias,
  _preserve_provider_with_base_url) + _read_task_route_config; base_url tail
  collapsed to one branch; duplicate task/no-task 'auto' tails merged
- _get_cached_client: hit/stale paths merged under one loop_ok predicate
- cleanup_stale_async_clients / _is_openrouter_client / accepts_slash: collapsed
- docstring/comment compaction in region only
2026-09-02 18:26:03 -07:00
Teknium 722f0f04d5 refactor(agent/auxiliary_client): drop dead _AUTO_PROVIDER_LABELS table 2026-09-02 18:10:02 -07:00
Teknium 56202613ef Merge branch 'simp/r2-loop' into simp/integration2 2026-09-02 17:49:25 -07:00
Teknium 7dc43c94d1 refactor(turn): sub-split handle_api_error / check_api_response / run_tool_round so no new turn_* function exceeds 300 LOC 2026-09-02 17:28:22 -07:00
Teknium 013c528ef8 refactor(tool_executor): inline memory_manager_executor into resolve_invoke_tool_executor
Single-caller factory replaced by the equivalent closure; comment compaction only
otherwise.
2026-09-02 17:07:36 -07:00
Teknium c6136d946f refactor(tool_executor): split execute_tool_calls_concurrent into _ConcurrentBatch + shared result helpers
Behavior-neutral extraction of the 686-LOC concurrent executor and the 429-LOC
sequential executor into focused helpers:

- _ConcurrentBatch (run_worker / submit_all / await_completion / run) and
  _StartOrderGate replace the nested closures + nonlocal counters; _ToolOutcome
  replaces the 7-tuple result slots; _ParsedCall/_parse_tool_call replaces the
  6-tuple parsed-call rows in both executors (-> 2 sites).
- _append_skipped_tool_results unifies the four cancelled/skipped-result loops
  (concurrent pre-flight, sequential pre-tool interrupt, sequential
  KeyboardInterrupt, sequential post-tool interrupt) -> 4 sites; absorbs
  _append_cancelled_tool_results.
- _observe_tool_result / _commit_tool_result / _finalize_tool_batch /
  _print_tool_completed / _tool_progress_enabled unify the post-execution
  guardrail-observe -> append+flush -> tool.completed -> budget -> /steer tail
  shared by the concurrent, sequential and segmented paths (-> 2-3 sites each).
- _unfinished_tool_result, _blocked_tool_result, _abandoned_sequential_result
  collapse the duplicated synthesize-result + terminal post_tool_call blocks.
- _registered_tool_worker / _interrupt_worker_tids unify worker tid tracking and
  interrupt fan-out between the two middleware runners (-> 2 / 3 sites).
- _run_with_activity_heartbeat extracts the heartbeat thread wrapper.
- _resolve_sequential_dispatch + _SequentialDispatch turn the 5-branch
  inline/delegate/context-engine/memory/registry if/elif into a resolver with
  per-branch spinner/error/KeyboardInterrupt policy, preserving branch order.
- _cancelled_tool_result and _managed_values inlined (single caller each).

Public signatures (execute_tool_calls_concurrent/sequential/segmented, both
middleware runners, every symbol imported by run_agent.py/agent/tests) are
unchanged; middleware/hook/persistence/progress-callback order is identical.
2026-09-02 17:07:35 -07:00
Teknium 0c27101562 refactor(turn): split finalize_turn into phase helpers (576 -> 264 LOC) 2026-09-02 17:07:35 -07:00
Teknium a0b0ae9ce3 refactor(turn): split recover_from_overflow into per-error handlers on a _Recovery state (501-LOC function -> max 76) 2026-09-02 17:07:35 -07:00
Teknium 656f1c1c13 Merge branch 'simp/r2-loop-tex' into simp/integration2 2026-09-02 17:05:13 -07:00
Teknium eb807c026f Merge branch 'simp/r2-loop-fin' into simp/integration2 2026-09-02 17:05:12 -07:00
Teknium e037d3d55e Merge branch 'simp/r2-loop' into simp/integration2 2026-09-02 17:05:02 -07:00
Teknium 0f1c1d9388 refactor(turn): module docstrings list every helper in turn_iteration_prep / turn_api_call 2026-09-02 16:57:55 -07:00
Teknium 3d0e9af47a refactor(tool_executor): inline memory_manager_executor into resolve_invoke_tool_executor
Single-caller factory replaced by the equivalent closure; comment compaction only
otherwise.
2026-09-02 16:51:42 -07:00
Teknium 3f93fdfc95 refactor(tool_executor): split execute_tool_calls_concurrent into _ConcurrentBatch + shared result helpers
Behavior-neutral extraction of the 686-LOC concurrent executor and the 429-LOC
sequential executor into focused helpers:

- _ConcurrentBatch (run_worker / submit_all / await_completion / run) and
  _StartOrderGate replace the nested closures + nonlocal counters; _ToolOutcome
  replaces the 7-tuple result slots; _ParsedCall/_parse_tool_call replaces the
  6-tuple parsed-call rows in both executors (-> 2 sites).
- _append_skipped_tool_results unifies the four cancelled/skipped-result loops
  (concurrent pre-flight, sequential pre-tool interrupt, sequential
  KeyboardInterrupt, sequential post-tool interrupt) -> 4 sites; absorbs
  _append_cancelled_tool_results.
- _observe_tool_result / _commit_tool_result / _finalize_tool_batch /
  _print_tool_completed / _tool_progress_enabled unify the post-execution
  guardrail-observe -> append+flush -> tool.completed -> budget -> /steer tail
  shared by the concurrent, sequential and segmented paths (-> 2-3 sites each).
- _unfinished_tool_result, _blocked_tool_result, _abandoned_sequential_result
  collapse the duplicated synthesize-result + terminal post_tool_call blocks.
- _registered_tool_worker / _interrupt_worker_tids unify worker tid tracking and
  interrupt fan-out between the two middleware runners (-> 2 / 3 sites).
- _run_with_activity_heartbeat extracts the heartbeat thread wrapper.
- _resolve_sequential_dispatch + _SequentialDispatch turn the 5-branch
  inline/delegate/context-engine/memory/registry if/elif into a resolver with
  per-branch spinner/error/KeyboardInterrupt policy, preserving branch order.
- _cancelled_tool_result and _managed_values inlined (single caller each).

Public signatures (execute_tool_calls_concurrent/sequential/segmented, both
middleware runners, every symbol imported by run_agent.py/agent/tests) are
unchanged; middleware/hook/persistence/progress-callback order is identical.
2026-09-02 16:51:42 -07:00
Teknium 629e6eb1b5 refactor(turn): split finalize_turn into phase helpers (576 -> 264 LOC) 2026-09-02 16:46:33 -07:00
Teknium 529f1ac0aa refactor(turn): drop section-banner comments in turn_facade_lease 2026-09-02 16:43:09 -07:00
Teknium b4c38f2aa9 refactor(turn): lift run_conversation lease/liveness closures into agent.turn_facade_lease 2026-09-02 16:43:09 -07:00
Teknium 74b928b6a3 refactor(turn): compact log-call formatting in turn_context_compaction 2026-09-02 16:43:08 -07:00
Teknium d6ef4190cc refactor(turn): collapse preflight estimator branch, build_api_messages pops, docstrings; add turn_context_compaction tests 2026-09-02 16:42:25 -07:00
Teknium 84c2e326f2 refactor(turn): split build_turn_context into helpers; extract turn-start compaction to turn_context_compaction.py 2026-09-02 16:40:40 -07:00
Teknium 2769937936 refactor(turn): lift iteration entry/announce, Nous rate guard, API interrupt, retry-restart consumer and preflight-timeout result out of run_conversation 2026-09-02 16:37:14 -07:00
Teknium 4d1880e0bf fix(integration): restore subprocess encoding/stdin guards dropped in simplification
Simplification workers collapsed subprocess call sites into shared kwargs
helpers and dropped the Windows/TUI safety kwargs on the way:

- encoding='utf-8', errors='replace' restored on text=True runs in
  copilot_acp_client, hermes_cli/setup (vercel install), managed_uv
  (codesign steps), local_runtime/hardware._stdout, a2a adapter.
- stdin=subprocess.DEVNULL restored on copilot probe, verify/runner
  _SUBPROCESS_KW, iron_proxy._run, google_meet playwright/system_profiler,
  simplex convert, whatsapp _RUN_TEXT, mem0 ollama serve Popen.
  google_meet sudo/brew install keeps inherited stdin (user-confirmed,
  may prompt) — marked noqa: subprocess-stdin.
- Windows-safe SIGKILL: getattr(signal, 'SIGKILL', SIGTERM) in
  verify/runner; photon _kill call re-marked windows-footgun: ok
  (unreachable on win32).
- scripts/check_subprocess_stdin.py now recognizes **kwargs splats
  (**_KW / **_kw(...)) ONLY when the same-file definition provably sets
  stdin= — covers tui_gateway _capture_run_kwargs/run_kw. Parity test added.
2026-09-02 16:36:10 -07:00
Teknium a56f731ac6 refactor(turn): extract preflight gate + per-iteration transcript prep into agent/turn_preflight_gate.py, agent/turn_iteration_prep.py 2026-09-02 16:27:44 -07:00
Teknium 9780739e12 refactor(turn): extract per-iteration request assembly (api_messages/MoA/cache plan/pressure) into agent/turn_request_assembly.py 2026-09-02 16:10:07 -07:00
Teknium 9fda4e5bac refactor(turn): extract retry-loop API error handler, request build, provider call and response check into agent/turn_api_*.py + agent/turn_response_check.py 2026-09-02 16:07:51 -07:00
Teknium 0dc36e0934 refactor(turn): extract tool round + final text response branches into agent/turn_tool_round.py, agent/turn_final_response.py 2026-09-02 15:40:17 -07:00
Teknium 67ef2e50fe refactor(turn): extract response intake (normalize/hooks/scratchpad/codex-incomplete) into agent/turn_response_intake.py 2026-09-02 15:37:47 -07:00
Teknium 9c99769ad8 refactor(turn): split recover_from_overflow into per-error handlers on a _Recovery state (501-LOC function -> max 76) 2026-09-02 15:29:36 -07:00
Teknium d42282ae9e refactor(turn): extract outer-loop exception handler into agent/turn_loop_errors.py 2026-09-02 15:29:00 -07:00