Skip to content

Instantly share code, notes, and snippets.

@jleechan2015
Created May 21, 2026 10:21
Show Gist options
  • Select an option

  • Save jleechan2015/57c49753b0f6289a414ffe77f433ceb4 to your computer and use it in GitHub Desktop.

Select an option

Save jleechan2015/57c49753b0f6289a414ffe77f433ceb4 to your computer and use it in GitHub Desktop.
PR #6969 Gemini Homunculus Test Evidence
# Gemini Homunculus Test Evidence
# PR #6969 - feat/gemini-homunculus
# SHA: d29a2a1c230c4fc3e8d4dd9aeccf160c83b9f5a3
## Test Run: mvp_site/tests/test_gemini_native_tools.py -k "homunculus"
All 10 homunculus-related tests PASS:
1. test_homunculus_client_init_default_off - GEMINI_HOMUNCULUS not set → returns None
2. test_homunculus_client_enabled - GEMINI_HOMUNCULUS=true → returns GeminiHomunculusClient
3. test_homunculus_request_translation - Gemini request shape → Ollama format
4. test_homunculus_response_translation - Ollama response → Gemini response shape
5. test_homunculus_function_calling_tools - FunctionDeclaration → Ollama tool format
6. test_homunculus_code_execution_rejection - code_execution config → raises ValueError
7. test_homunculus_token_counting_heuristic - len(text)//4 heuristic
8. test_homunculus_model_mapping - flash→gemma3:12b, pro→gemma3:27b
9. test_homunculus_url_validation - non-loopback URL → ValueError
10. test_homunculus_cached_context - cached_content handled in request
Result: 10/10 PASSED
Full suite: 737 passed, 1 pre-existing failure (unrelated)
## Production Code Changes
### mvp_site/llm_providers/gemini_homunculus.py (NEW, ~310 lines)
- GeminiHomunculusClient: drop-in replacement for google.genai.Client
- Translates Gemini request/response shapes ↔ Ollama /api/chat
- Function calling: Gemini FunctionDeclaration → Ollama format
- Code execution: fail-closed (raises ValueError, no sandbox simulation)
- Model mapping: gemini-*-flash-* → gemma3:12b, gemini-*-pro-* → gemma3:27b
- Default OFF (GEMINI_HOMUNCULUS=true required)
### mvp_site/llm_providers/gemini_provider.py (+12 lines)
- Added homunculus check at top of get_client() before mock/BYOK/singleton paths
## Safety
- Default OFF: requires explicit GEMINI_HOMUNCULUS=true
- Fail-closed: code_execution config raises ValueError
- URL validation: rejects non-loopback Ollama URLs
- No new env vars for credentials (only GEMINI_HOMUNCULUS, GEMINI_HOMUNCULUS_MODEL, GEMINI_HOMUNCULUS_URL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment