Teknium
8dcb2b6ada
refactor(agent/providers): shared ProviderBase/CatalogProviderBase and provider_media; compact contract docs
...
- provider_base.py: ProviderBase (name/display_name/get_setup_schema) and
CatalogProviderBase (default_model/list_models/is_available) replace the
identical default-method bodies duplicated across 7 provider ABCs
- provider_media.py: one save_b64/save_bytes/save_url/cache_dir implementation
behind image_gen_provider and video_gen_provider
- memory_manager.py: _each_provider fan-out helper replaces per-hook
try/except loops; _signature_params/_has_var_kwargs unify signature probes
- image_routing.py: _resolve_inference_value shared by base_url/api_key
resolution; _dict_or_empty/_clean_str/_custom_provider_entries helpers
- MemoryProvider/ContextEngine/TTS/browser/web/terminal-env ABC docstrings
compacted to their invariants; method names and signatures unchanged
2026-09-02 13:53:28 -07:00
Teknium
b6e1037730
refactor(agent/lsp): table-driven server registry, shared client/manager helpers, compact docs
...
- servers.py: per-language _root_*/_spawn_* functions collapsed into declarative
ServerDef entries built by _make_spec/_simple_spawn/_markers_root (-707 LOC)
- client.py: _write/_send_reply/_cancel_task helpers replace repeated
try/except blocks; handler dispatch tables for server->client requests
- manager.py: _broken_key unifies the (server_id, root) key derivation
- install.py/cli.py/eventlog.py/workspace.py/protocol.py/range_shift.py/
reporter.py: dedupe helpers (_find_binary, _link_into_bin, _run_installer,
_emit_once, _walk_up), drop dead log_no_server_configured, compact docs
2026-09-02 13:53:27 -07:00
Teknium
2273f2bd20
refactor(agent/models): unify model_metadata TTL disk memos
...
_ttl_memo_get/_ttl_memo_put back both the local-probe and endpoint-metadata
disk caches (file layout, key order and log strings verified identical).
2026-09-02 13:52:52 -07:00
Teknium
684e8322ff
refactor(agent/models): extract LM Studio and llama.cpp /props branches from fetch_endpoint_model_metadata
...
_lmstudio_native_models and _apply_llamacpp_props; the router-mode child probe
shares one /v1/props -> /props fallback helper. HTTP call sequence verified
identical old vs new across 10 fake-endpoint scenarios.
2026-09-02 13:52:52 -07:00
Teknium
771045655b
refactor(agent/models): table-driven credits header parsing, unified account-usage fetchers
...
- credits_tracker: _MICROS_FIELDS/_USD_FIELDS/_BOOL_FIELDS drive parse_credits_headers;
_sticky_notice() replaces repeated AgentNotice literals; collapsed defensive layers
- account_usage: _USAGE_FETCHERS dispatch table replaces provider if/elif; shared
fetch/parse helpers across the codex/anthropic/openrouter fetchers; drop dead
_resolve_codex_usage_url
- billing_links, fast_mode: compacted docstrings, collapsed if/return chains
- model_metadata: fold effective_provider inference into one expression
Notice keys, header names, URLs, log strings and dataclass defaults unchanged.
2026-09-02 13:52:52 -07:00
Teknium
d465b45f38
refactor(agent/models): compact model_metadata comment essays to their invariants
...
Every non-obvious rule, ordering, failure mode and WHY is kept (1-3 lines);
issue numbers, dates and narrative dropped. Data tables unchanged.
2026-09-02 13:52:51 -07:00
Teknium
4a65e98f50
refactor(agent/models): extract get_model_context_length steps into helpers
...
_validate_cached_context_length (step 1), _resolve_bedrock_context_length (1b),
_resolve_custom_endpoint_context_length (2-3); resolution order and every log
message unchanged. Compact the per-step comment essays to their invariants.
2026-09-02 13:52:51 -07:00
Teknium
f3a46eb5d0
refactor(agent/models): dedupe model_metadata probe helpers
...
- _server_root / _ollama_show_context / _longest_key_match / _probe_local_context_length /
_endpoint_model_entry replace 5 copies of the same local-probe and lookup bodies
- detect_local_server_type waterfall as an ordered (name, probe) table
- output-cap error classification via phrase-group tables shared by
is_output_cap_error and parse_available_output_tokens_from_error
- endpoint-scoped context overrides as a data table
- drop dead _fetch_codex_oauth_context_lengths, _resolve_codex_oauth_context_length,
_estimate_message_chars (zero refs repo-wide)
Verified with a differential harness (old vs new module, ~700 pure-function probes, 0 mismatches).
2026-09-02 13:52:51 -07:00
Teknium
77743eac8a
refactor(agent/models): compact pricing snapshot, billing/subscription views, reasoning helpers
...
- usage_pricing: _snap() builder for official-docs pricing entries (table values identical, verified by dump), shared source/version dicts, drop dead DEFAULT_PRICING
- models_dev: _registry_models/_iter_model_entries/_extract_limit helpers replace repeated registry walking; drop dead ModelInfo.format_cost
- billing_view/subscription_view: OrgRoleCapability mixin replaces duplicated is_admin/can_change_plan; shared fetch_portal_state/parse_org_fields
- reasoning_effort/timeouts/summaries, thinking_timeout_guidance, portal_tags: dispatch tables and compacted comment essays; drop dead CODEX_RESPONSES_EFFORTS alias and _match_any
2026-09-02 13:52:51 -07:00
Teknium
95177359f8
refactor(agent/aux): ruff SIM cleanups; compact vision custom-runtime recovery
2026-09-02 13:33:04 -07:00
Teknium
05d1136dea
refactor(agent/aux): fallback reason via ordered predicate table; single loop for stale-credential re-walk
2026-09-02 13:33:01 -07:00
Teknium
d8ef59a415
refactor(agent/aux): recovery-ladder rungs via one _rung() generator helper with named accept predicates
2026-09-02 13:33:01 -07:00
Teknium
da388692e4
refactor(agent/aux): one _field accessor for dict/object wire payloads
2026-09-02 13:32:58 -07:00
Teknium
6320c54552
refactor(agent/aux): _to_async_client header selection via _endpoint_default_headers
2026-09-02 13:32:56 -07:00
Teknium
0d41e9bdbc
refactor(agent/aux): shared pool loader; restore @_relay_auxiliary_call placement on call_llm
2026-09-02 13:32:55 -07:00
Teknium
14ec5874a5
refactor(agent/aux): collapse cancel-check readers and Codex-route model predicates
2026-09-02 13:32:53 -07:00
Teknium
b40d76823f
refactor(agent/aux): shared creds-pair and Nous pool entry-state helpers
2026-09-02 13:32:51 -07:00
Teknium
9001ed2365
refactor(agent/aux): shared _prepare_aux_request head for call_llm/async_call_llm
2026-09-02 13:32:49 -07:00
Teknium
d46aa77cde
refactor(agent/aux): extract named-custom credential resolution, Bedrock and Vertex client builders out of resolve_provider_client
2026-09-02 13:32:45 -07:00
Teknium
e3d352872b
refactor(agent/aux): shared chain-label aliases, context-window screen, event-loop helper
2026-09-02 13:32:41 -07:00
Teknium
575cd5f34e
refactor(agent/aux): shared hook ticker and _is_specialized_aux_client predicate
2026-09-02 13:32:41 -07:00
Teknium
5dfda6a615
refactor(agent/aux): compact _fallback_destination
2026-09-02 13:32:12 -07:00
Teknium
28c3cb1561
refactor(agent/aux): shared _endpoint_default_headers, single primary-attempt closure in call_llm impls, vision tail dedupe
2026-09-02 13:32:09 -07:00
Teknium
936c8bb626
refactor(agent/aux): split _CodexCompletionsAdapter.create into request build / final-response parse; dedupe stream/client close paths
2026-09-02 13:32:07 -07:00
Teknium
312378d9b1
refactor(agent/aux): unify _read_main_{model,provider,api_key,base_url} and relay call-context builders
2026-09-02 13:32:03 -07:00
Teknium
4022e69e69
refactor(agent/aux): lift max_tokens forwarding policy and Nous dual-wire check out of _build_call_kwargs
2026-09-02 13:32:00 -07:00
Teknium
dcbf263a09
refactor(agent/aux): unify same-provider retry and fallback-candidate prep across sync/async (_prepare_same_provider_retry, _plan_fallback_candidate)
2026-09-02 13:31:57 -07:00
Teknium
127a179ae5
refactor(agent/aux): share call_llm/async_call_llm route resolution (_resolve_call_client) and recovery ladder (_aux_recovery_ladder generator) across sync/async wires
2026-09-02 13:31:57 -07:00
Teknium
369ebf7532
refactor(agent/aux): resolve_provider_client — single _route() for sync/async return, dedupe named-custom OpenAI-wire build
2026-09-02 13:30:38 -07:00
Teknium
c408601937
refactor(agent/review): simplify curator, background_review, verify, insights, title and learning modules (-22% LOC)
...
Cluster: agent/{curator,curator_backup,background_review,review_engine,
review_idle_queue,insights,learning_graph,learning_graph_render,
learning_mutations,learn_prompt,verification_evidence,verification_stop,
verify_hooks,side_question,title_generator,turn_summary,
manual_compression_feedback,trajectory,moa_trace,trace_upload,verify/*}.
13662 -> 10693 LOC (-2969, -21.7%), behavior-neutral.
- Dead code: 27 private helpers with zero references removed
(_auto_title_session, _resolve_review_model, _parse_make_targets,
_filter_verifiable_paths, _find_subsequence, _is_under_root/_temp_dir,
_merge_runs, learning_graph_render bucket/period/node helpers,
_memories_dir/_memory_local_index/_node_detail, _cron_jobs_file,
_retention_cutoff, _scope_for_args, _clean_token, _count_diff_lines,
_ordered_verbs, _hermes_meta, _iter_skill_files).
- Unified helpers: _read_config_section (curator + curator_backup),
_write_file/_write_json (4 curator report writers), _msg_text
(background_review <- side_question), _report_failure/_notify_title
(title_generator instant/auto paths), _is_under (verification_evidence),
_scoped SQL pair builder + _query (insights), _optional_lock
(background_review), verify.recipes table-driven detection.
- if/elif routing -> dict dispatch: side_question role labels,
curator_backup summary bits, learning_graph_render buckets, insights
section rendering, verify recipe pickers.
- Redundant defensive layers, single-use wrappers and verbose narrative
comments collapsed; every non-obvious WHY/invariant kept in compact form.
Verification: parity.py (all REMOVED symbols zero-ref), import smoke for
every module + cli/run_agent/gateway.run/hermes_cli.main/
agent.conversation_loop/tui_gateway.server, old-vs-new fuzz parity on all
shared pure functions, SQL trace parity for insights and
verification_evidence, cluster tests 1354 passed / 0 failed (46 files).
2026-09-02 13:30:25 -07:00
Teknium
ab48b1ddc5
refactor(agent): extract per-call API message build into turn_context.build_api_messages
2026-09-02 13:30:23 -07:00
Teknium
30b0759bb3
refactor(agent): extract content_filter refusal handling into turn_truncation.handle_content_policy_refusal
2026-09-02 13:30:23 -07:00
Teknium
4f53d7bd28
refactor(agent): extract post-tool-call compression decision into turn_preflight.compress_after_tool_results
2026-09-02 13:30:23 -07:00
Teknium
f0d2355e26
refactor(agent): extract text-response stop gates (verify-on-stop, pre_verify hook, kanban guard) into agent/turn_stop_gates.py
2026-09-02 13:30:23 -07:00
Teknium
22cba7dd41
refactor(agent): extract classified-error routing (compaction gate, long-context tier, eager/auth fallback, Nous 429) into turn_recovery.route_classified_error
2026-09-02 13:30:23 -07:00
Teknium
ef9dc88348
refactor(agent): drop write-only _bot_capability_refreshed attribute (zero readers repo-wide)
2026-09-02 13:30:22 -07:00
Teknium
7df9d3be5c
refactor(agent): extract pre-API preflight compression gate into agent/turn_preflight.py
2026-09-02 13:30:21 -07:00
Teknium
0028951f35
refactor(agent): extract tool-call name/JSON validation into agent/turn_tool_validation.py
2026-09-02 13:30:21 -07:00
Teknium
d398d91529
refactor(agent): extract empty/thinking-only response recovery ladder into agent/turn_empty_response.py
2026-09-02 13:30:20 -07:00
Teknium
df42f37e09
refactor(agent): extract response-shape validation, invalid-response diagnostics and Codex incomplete continuation
2026-09-02 13:30:19 -07:00
Teknium
8b958e1b0f
refactor(agent): unify interruptible backoff sleeps and fallback-restart arming; extract compute_error_backoff
2026-09-02 13:30:18 -07:00
Teknium
661c9af826
refactor(agent): extract finish_reason=length truncation recovery into agent/turn_truncation.py
2026-09-02 13:30:18 -07:00
Teknium
645db06053
refactor(agent): extract 413/context-overflow compression recovery into agent/turn_overflow.py
2026-09-02 13:30:17 -07:00
Teknium
5543e7ae0f
refactor(agent): resume — extract API-error attempt logging into turn_recovery.log_api_error_attempt (verified partial work)
2026-09-02 13:30:17 -07:00
Teknium
25b165add5
refactor(agent): extract terminal API-failure result builders into agent/turn_recovery.py
2026-09-02 13:30:16 -07:00
Teknium
649c227e9e
refactor(agent): extract per-response usage accounting into agent/turn_usage.py
2026-09-02 13:30:16 -07:00
Teknium
b12e4a90c4
refactor(agent/aux): dedupe api-key auto-chain client build (pool vs env creds) and provider-profile header lookup
2026-09-02 13:30:15 -07:00
Teknium
fefc471deb
refactor(agent): extract post-classification one-shot recovery chain into agent/turn_recovery.py
2026-09-02 13:30:15 -07:00
Teknium
7e9c8a714e
refactor(agent/aux): unify Codex/Anthropic/Bedrock chat shims + async adapters into _ChatShim/_AsyncCompletionsAdapter/_AsyncAuxiliaryClientBase
2026-09-02 13:30:15 -07:00
Teknium
d7c6cef154
refactor(agent/aux): drop zero-reference helpers (_resolve_single_provider, get_async_text_auxiliary_client, _is_streaming_rejected_error, get_accounting_context, unused copy import)
2026-09-02 13:30:15 -07:00