Commit Graph

3728 Commits

Author SHA1 Message Date
Teknium 052582de2d refactor(agent): compact monitoring/* and lsp/workspace — contextlib.suppress, shared platform error-code helper, nearest_root marker probe, docstring compaction 2026-09-02 18:32:02 -07:00
Teknium 1a1716ee64 refactor(agent): compact outbound_webhooks — fold list-check into iter_configured_targets, tighten delivery logging 2026-09-02 18:24:14 -07:00
Teknium 4f2553c5f9 refactor(agent): compact iron_proxy — inline single-use download/token helpers, unify listen readers, contextlib.suppress 2026-09-02 18:21:43 -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
Teknium aa0163d361 Merge branch 'simp/agent-runtime' into simp/integration
Conflict in agent/error_classifier.py: both simp/agent-chat and
simp/agent-runtime simplified the same file. Kept simp/agent-chat's
rule-table version, which already subsumes agent-runtime's
billing/rate-limit/overflow verdict helpers (as _V_* verdicts + _first_match
rule tables) and its dead _THINKING_SIG_PATTERNS removal. Verified with a
60k-case differential fuzz: identical ClassifiedError output vs base and vs
agent-runtime's version.
2026-09-02 14:44:19 -07:00
Teknium 3721bcfd41 Merge branch 'simp/hclia-models' into simp/integration 2026-09-02 14:19:39 -07:00
Teknium 74e56381d4 Merge branch 'simp/hclia-providers' into simp/integration 2026-09-02 14:19:39 -07:00
Teknium 796e81b391 Merge branch 'simp/hclia-prompt' into simp/integration 2026-09-02 14:19:39 -07:00
Teknium b226b80752 Merge branch 'simp/hclia-review' into simp/integration 2026-09-02 14:19:39 -07:00
Teknium 0b18fe0bcd Merge branch 'simp/hclia-aux' into simp/integration 2026-09-02 14:19:39 -07:00
Teknium 583e49ab4f Merge branch 'simp/hclia-transports' into simp/integration 2026-09-02 14:19:38 -07:00
Teknium db03f855c7 Merge branch 'simp/hclia-runtime' into simp/integration 2026-09-02 14:19:38 -07:00
Teknium 6ad4ed9fba Merge branch 'simp/hclia-adapters' into simp/integration 2026-09-02 14:19:38 -07:00
Teknium db46847dbf Merge branch 'simp/hclia-creds-c' into simp/integration 2026-09-02 14:19:38 -07:00
Teknium 52028c4464 Merge branch 'simp/hclia-creds-b' into simp/integration 2026-09-02 14:19:38 -07:00
Teknium 343ceb6abe Merge branch 'simp/hclia-creds-a' into simp/integration 2026-09-02 14:19:38 -07:00
Teknium 4dfd383765 Merge branch 'simp/agent-loop' into simp/integration 2026-09-02 14:19:36 -07:00
Teknium 673b2c6d5a Merge branch 'simp/agent-runagent' into simp/integration 2026-09-02 14:19:36 -07:00
Teknium 8c40fc4aba Merge branch 'simp/agent-ctxcomp' into simp/integration 2026-09-02 14:19:35 -07:00
Teknium 082dd91c79 Merge branch 'simp/agent-convcomp' into simp/integration 2026-09-02 14:19:35 -07:00
Teknium 7c6a581d38 Merge branch 'simp/agent-chat' into simp/integration 2026-09-02 14:19:35 -07:00
Teknium 53ab9d1ed0 Merge branch 'simp/agent-init-pb' into simp/integration 2026-09-02 14:19:35 -07:00
Teknium c43c0bcfa6 Merge branch 'simp/agent-init-moa' into simp/integration 2026-09-02 14:19:35 -07:00
Teknium 44982309b8 refactor(agent/prompt): dispatch tables and helper extraction in display, context refs, breakdown, compaction
build_tool_preview -> _PREVIEW_BUILDERS per-tool table; git @refs -> _GIT_REFERENCE_ARGS; context_breakdown
_skills_block/_append_overflow dedupe; prune_pre_checkpoint_items summary retention folded into one closure;
build_skill_invocation_message reuses _render_skill_block; ruff SIM collapses; restored two compacted
cache-policy invariant comments.
2026-09-02 13:53:58 -07:00