1---2name: llm3description: Llm subsystem in TTA.dev: execute and related code. 171 symbols | 30 files | Cohesion: 67%4---56# Llm78171 symbols | 30 files | Cohesion: 67%910## When to Use1112- Working on `llm`-related functionality in TTA.dev13- Modifying `execute`14- Navigating `ttadev/primitives/llm/hardware_detector.py`, `ttadev/primitives/llm/ollama_primitive.py`1516## Key Files1718| File | Symbols |19|------|---------|20| `tests/primitives/llm/test_model_router.py` | _make_router, _ctx, test_raises_value_error_for_unknown_mode, test_error_message_lists_available_modes, test_calls_ollama_and_returns_response (+27) |21| `tests/primitives/llm/test_task_selector.py` | test_known_coding_model_scores_above_zero, test_returns_float_between_0_and_1, test_gemini_flash_scores_for_coding, test_unknown_model_with_large_params_scores_above_tiny, test_completely_unknown_model_gets_minimal_score (+11) |22| `ttadev/primitives/llm/hardware_detector.py` | max_params_b, summary, to_dict, detect, filter_ollama_models (+10) |23| `ttadev/primitives/llm/ollama_primitive.py` | _get_client, _list_models, _running_models, _show_model, _pull_model (+6) |24| `tests/primitives/llm/test_hardware_detector.py` | test_detect_cached, test_detect_force_re_reads, _profile, test_can_run_small_model_on_4gb_gpu, test_cannot_run_70b_on_4gb_gpu_limited_ram (+5) |25| `ttadev/primitives/llm/provider_dispatch.py` | build_openai_tool_kwargs, call_openai_compat, call_openai, call_openrouter, call_xai (+4) |26| `tests/primitives/llm/test_model_advisor.py` | test_recommend_tier_threshold_met_returns_valid_model, test_recommend_tier_ollama_preferred_when_score_meets_threshold, _make_tier_map, test_recommend_tier_returns_tier_recommendation, test_recommend_tier_no_threshold_met_returns_best_available (+4) |27| `ttadev/primitives/llm/model_registry.py` | _list, _has_benchmark, _select, _key, _get (+3) |28| `ttadev/primitives/llm/task_selector.py` | general, _extract_param_size_b, score_model_for_task, sort_key, coding (+2) |29| `tests/primitives/llm/test_free_model_tracker.py` | _make_httpx_response, test_returns_only_free_models, test_passes_api_key_as_auth_header, test_no_api_key_sends_no_auth_header, test_handles_null_pricing_gracefully (+2) |3031## Entry Points3233Start here when exploring this area:3435- **`execute`** (Function) — `ttadev/primitives/llm/model_router.py:351`36- **`test_raises_value_error_for_unknown_mode`** (Function) — `tests/primitives/llm/test_model_router.py:164`37- **`test_error_message_lists_available_modes`** (Function) — `tests/primitives/llm/test_model_router.py:173`38- **`test_calls_ollama_and_returns_response`** (Function) — `tests/primitives/llm/test_model_router.py:187`39- **`test_ollama_tier_without_model_raises`** (Function) — `tests/primitives/llm/test_model_router.py:210`4041## Key Symbols4243| Symbol | Type | File | Line |44|--------|------|------|------|45| `execute` | Function | `ttadev/primitives/llm/model_router.py` | 351 |46| `test_raises_value_error_for_unknown_mode` | Function | `tests/primitives/llm/test_model_router.py` | 164 |47| `test_error_message_lists_available_modes` | Function | `tests/primitives/llm/test_model_router.py` | 173 |48| `test_calls_ollama_and_returns_response` | Function | `tests/primitives/llm/test_model_router.py` | 187 |49| `test_ollama_tier_without_model_raises` | Function | `tests/primitives/llm/test_model_router.py` | 210 |50| `test_calls_openrouter_with_pinned_model` | Function | `tests/primitives/llm/test_model_router.py` | 224 |51| `test_openrouter_without_model_uses_tracker` | Function | `tests/primitives/llm/test_model_router.py` | 247 |52| `test_auto_uses_tracker_to_pick_model` | Function | `tests/primitives/llm/test_model_router.py` | 280 |53| `test_falls_through_to_next_tier_on_failure` | Function | `tests/primitives/llm/test_model_router.py` | 313 |54| `test_raises_runtime_error_when_all_tiers_fail` | Function | `tests/primitives/llm/test_model_router.py` | 356 |55| `test_raises_runtime_error_when_no_tiers` | Function | `tests/primitives/llm/test_model_router.py` | 378 |56| `test_override_skips_to_specified_tier` | Function | `tests/primitives/llm/test_model_router.py` | 392 |57| `test_override_out_of_range_raises_value_error` | Function | `tests/primitives/llm/test_model_router.py` | 413 |58| `test_unknown_provider_raises_runtime_error` | Function | `tests/primitives/llm/test_model_router.py` | 427 |59| `test_calls_groq_with_pinned_model` | Function | `tests/primitives/llm/test_model_router.py` | 455 |60| `test_groq_defaults_to_first_free_model_when_no_model` | Function | `tests/primitives/llm/test_model_router.py` | 482 |61| `test_calls_together_with_pinned_model` | Function | `tests/primitives/llm/test_model_router.py` | 514 |62| `test_together_without_model_raises` | Function | `tests/primitives/llm/test_model_router.py` | 543 |63| `test_bare_model_id_gets_models_prefix` | Function | `tests/primitives/llm/test_model_router.py` | 589 |64| `test_model_with_prefix_is_not_double_prefixed` | Function | `tests/primitives/llm/test_model_router.py` | 614 |6566## Execution Flows6768| Flow | Type | Steps |69|------|------|-------|70| `Main → _build_messages` | cross_community | 7 |71| `Main → Resolve_model_id` | cross_community | 7 |72| `Handle_model_command → Rank_models_for_task` | cross_community | 6 |73| `Handle_model_command → _classify_entry` | cross_community | 6 |74| `Get_ranked_openhands_free_models → Resolve_model_id` | cross_community | 6 |75| `Llm_hardware_profile → _run` | cross_community | 6 |76| `Llm_viable_ollama_models → _run` | cross_community | 6 |77| `Test_router_ollama_skip_small → _build_messages` | cross_community | 6 |78| `Test_router_ollama_allow_large → _build_messages` | cross_community | 6 |79| `Main → _build_kwargs` | cross_community | 4 |8081## Connected Areas8283| Area | Connections |84|------|-------------|85| Unit | 18 calls |86| Tests | 1 calls |87| Integration | 1 calls |88| Model_advisor | 1 calls |89| Cli | 1 calls |90| Control_plane | 1 calls |9192## How to Explore93941. `gitnexus_context({name: "execute"})` — see callers and callees952. `gitnexus_query({query: "llm"})` — find related execution flows963. Read key files listed above for implementation details