Harold Code Archive: Independent API Pool

in #harold • 3 hours ago (edited)

Harold Code Archive · 2026-11-14 — server_api_pool.py. This post preserves the exact source snapshot for education and recovery.

This digest is included so a recovered copy can be checked against the source archived here. Recalculating it after download is a practical way to spot accidental edits or corruption and confirm you have the intended version.

SHA-256: dbafb947f49528aeab7af23b5ed5424afd79cff053726a4ee5828f6c99bc6443.

SHA-256 is a cryptographic checksum calculated from a file's exact bytes. It is not a password or key; comparing digests is a practical integrity check, and matching values are strong evidence that two copies are identical.

~~~python """Independent server API contributors; never simulate extension execution.""" from concurrent.futures import ThreadPoolExecutor import peakebot def collect_server_api_pool(prompt): providers = [ ("google", peakebot.GOOGLE_API_KEY, peakebot._ai_chat_google), ("groq", peakebot.GROQ_API_KEY, peakebot._ai_chat_groq), ("openrouter", peakebot.OPENROUTER_API_KEY, peakebot._ai_chat_openrouter), ] configured = [(name, query) for name, key, query in providers if key] if len(configured) < 2: raise RuntimeError("Configure at least two independent non-Harold server API providers") system = ( "You are an independent assistant answering the user's question. " "Give concise reasoning and state uncertainty. Do not run tools or claim file changes. " "Do not pretend to be Cline, Kilo, CodeGeeX or Harold." ) def query_provider(provider): name, query = provider base = {"name": name, "source": "server-api"} try: answer = query(system, prompt) except (RuntimeError, ValueError, OSError, peakebot.requests.RequestException) as exc: return {**base, "error": f"Provider request failed: {type(exc).__name__}"} if not isinstance(answer, str) or not answer.strip(): return {**base, "error": "Provider returned no usable answer; inspect server provider logs"} if len(answer) > 4000: return {**base, "error": "Provider answer exceeds 4,000 characters; nothing was truncated"} return {**base, "answer": answer} # Existing provider adapters retain their configured HTTP/model timeouts. with ThreadPoolExecutor(max_workers=len(configured)) as executor: return list(executor.map(query_provider, configured)) ~~~

This module asks multiple configured providers for independent answers in parallel, rejects unusable or oversized results, and does not execute tools. The embedded source is the recovery copy; compare its SHA-256 with the value above. Future versions can be published as separate posts with an update comment linking the newer snapshot.