Skip to main content

Module mock_llm

Module mock_llm 

Source
Expand description

Deterministic, offline “echo” LLM client for #2056’s mandatory offline testability (no live model, no API key).

Why: task execution needs a live LLM in production, but the e2e/CI suite must exercise the FULL flow (create -> attach -> run -> live tool events -> done) without one. Setting TCODE_MOCK_LLM=echo (checked by build_llm_client) swaps this deterministic client in for the real LlmClient — the daemon still starts and serves ping/health/ session.* fine with neither set; only task.run needs one or the other. What: EchoLlmClient replays a FIXED script exercising exactly the shape #2056 wires: the PM delegates once to python-engineer, which runs one bash tool call then stops, after which the PM sees the result and stops too. This is production code (not #[cfg(test)]) because the REAL tcode binary, spawned as a subprocess in tests/task_e2e.rs, must be able to construct it with no test harness in scope. Test: task::mock_llm::tests::*; exercised end-to-end (as a real subprocess) by tests/task_e2e.rs.

Structs§

EchoLlmClient
A deterministic, scripted LlmClientTrait for offline task-execution testing (#2056).

Constants§

MOCK_LLM_ECHO
The TCODE_MOCK_LLM value that selects EchoLlmClient.
MOCK_LLM_ENV
Environment variable selecting the mock LLM. Set to MOCK_LLM_ECHO to enable EchoLlmClient instead of a real OpenRouter client.

Functions§

build_llm_client
Build the Arc<dyn LlmClientTrait> task.run executions share.