Commit Graph

3742 Commits

Author SHA1 Message Date
Teknium adbac330c7 refactor(agent/context_compressor): repack implicitly-concatenated string literals (values byte-identical) 2026-09-02 19:46:07 -07:00
Teknium 7b8d547ffc refactor(agent/context_compressor): normalize blank lines (ruff E302/E303/E305) 2026-09-02 19:43:18 -07:00
Teknium 939305f186 refactor(agent/context_compressor): pack multi-line def signatures (AST-identical) 2026-09-02 19:42:06 -07:00
Teknium b233420b3d refactor(agent/context_compressor): shared real-user index helper, folded guard ladders, telemetry loop cleanup 2026-09-02 19:39:24 -07:00
Teknium 1d7fb737cd refactor(agent/context_compressor): prompt scaffolding helpers, shared real-usage reset, compact text/length helpers 2026-09-02 19:25:44 -07:00
Teknium 5f716407b9 refactor(agent/context_compressor): move per-section summarizer instructions into a keyed table (text byte-identical) 2026-09-02 19:21:58 -07:00
Teknium a7e616ee5f refactor(agent/context_compressor): flatten _scan_window_handoffs around an early return 2026-09-02 19:17:16 -07:00
Teknium e468577b13 refactor(agent/context_compressor): shared content-part text helpers for handoff projection/unwrapping 2026-09-02 19:13:23 -07:00
Teknium 9a89ce5548 refactor(agent/context_compressor): pack short literal collections and call arguments (AST-identical) 2026-09-02 19:08:33 -07:00
Teknium 34f96ff29c refactor(agent/context_compressor): reflow short multi-line call statements 2026-09-02 19:01:32 -07:00
Teknium 6fe54ec6d7 refactor(agent/context_compressor): AST-identical reflow of short multi-line statements and headers 2026-09-02 19:00:02 -07:00
Teknium 6549a8bfb6 refactor(agent/context_compressor): extract _call_summary_llm and a summary-failure classifier dataclass 2026-09-02 18:51:31 -07:00
Teknium f00024ecc8 refactor(agent/context_compressor): lift static-fallback helpers to module level, extract anchor collection 2026-09-02 18:48:29 -07:00
Teknium 83168ff4e4 refactor(agent/context_compressor): split _prune_old_tool_results into boundary/dedupe/demote/pressure helpers 2026-09-02 18:45:36 -07:00
Teknium 608e8560fe refactor(agent/context_compressor): split compress() into phase helpers (494 -> ~130 LOC) 2026-09-02 18:33:40 -07:00
Teknium 6bbdb45df1 refactor(agent/context_compressor): unify durable read/write/load helpers and cooldown persistence paths 2026-09-02 18:27:34 -07:00
Teknium 806d2c3274 refactor(agent/context_compressor): dedupe image-part stripping, summarizer one-liners into dispatch table, alias coerce helper 2026-09-02 18:24:29 -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