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
Teknium
593c8e9146
refactor(agent/prompt): split build_system_prompt_parts into tier helpers; unify model-gate resolver
...
_tool_guidance_block, _skills_prompt, _bot_mode_parts, _active_profile_line, _platform_hint, _memory_parts,
_zone_bits, _timestamp_line lifted out of the 600-line builder; tool_use_enforcement and execution_guidance
gates share _model_gate. Emitted prompt text is byte-identical.
2026-09-02 13:53:57 -07:00
Teknium
be5c6a2fd8
refactor(agent/prompt): remove dead code, unify duplicated helpers, compact docstrings across prompt/skill/redaction modules
...
Dead (zero refs): coding_system_blocks, get_friendly_tool_labels, get_scan_ordered_skills_dirs,
_project_quarantine_cache_clear, clear_stable_prefixes, _redact_http_request_target_query_params,
_has_http_method_substring, PromptCachePlan.marker_count, display _diff_* colour thunks (-> _diff_ansi),
pass-through RedactingFormatter.__init__.
Unified: _slugify -> slugify_skill_name; reload diff -> diff_command_snapshots; _is_summary_item ->
is_compaction_summary_message alias; sanitizer walkers -> _sanitize_messages/_sanitize_structure;
assignment redaction passes -> _redact_assignments/_should_redact_assignment; quiet-mode tool lines -> _CUTE_LINES table.
2026-09-02 13:53:57 -07:00
Teknium
96e952a4f8
refactor(agent/providers): one ProviderRegistry engine behind every *_registry module
...
- provider_registry.py: ProviderRegistry (global + per-scope maps, lock,
generation counters, register/list/get/snapshot/restore/reset) with
export() binding the historical module-level names and _providers/
_scoped_providers/_lock test hooks into each *_registry module
- is_available_safe / configured_provider_name replace the 4 nested
_is_available_safe closures and 2 config-reading blocks
- browser/image_gen/video_gen/web_search/terminal_env/tts/transcription
registries keep their public API, log strings, error strings, builtin
collision policy (warn vs raise) and key normalization (strip vs lower)
2026-09-02 13:53:28 -07:00