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 InferenceAdapter for offline task-execution testing (#2056).
FanoutEchoLlmClient
A deterministic, scripted InferenceAdapter exercising a FAN-OUT to two concurrently-delegated python-engineer sub-agents (DOC-39 AC-13’s acceptance proof).
RecallEchoLlmClient
A deterministic, scripted InferenceAdapter exercising the PM calling recall_session (DOC-39 Slice C’s e2e proof).
SearchEchoLlmClient
A deterministic, scripted InferenceAdapter exercising the engineer’s search_code tool (DOC-39 Slice B’s mandatory real-wire e2e proof that Event::SearchPerformed.hits carries real per-hit path/score data, not just a count).
SoakEchoLlmClient
A deterministic, offline InferenceAdapter for issue #3869’s compression-effectiveness soak harness (epic #3866 Slice C).
SoakLoadEchoLlmClient
A deterministic, offline InferenceAdapter driving load-realistic per-turn payload sizes for the compression-effectiveness follow-up soak (epic #3866).

Constants§

MOCK_LLM_ECHO
The TCODE_MOCK_LLM value that selects EchoLlmClient.
MOCK_LLM_ECHO_FANOUT
The TCODE_MOCK_LLM value that selects FanoutEchoLlmClient (DOC-39 AC-13).
MOCK_LLM_ECHO_RECALL
The TCODE_MOCK_LLM value that selects RecallEchoLlmClient (DOC-39 Slice C).
MOCK_LLM_ECHO_SEARCH
The TCODE_MOCK_LLM value that selects SearchEchoLlmClient (DOC-39 Slice B).
MOCK_LLM_ECHO_SOAK
The TCODE_MOCK_LLM value that selects SoakEchoLlmClient (issue #3869, epic #3866 Slice C).
MOCK_LLM_ECHO_SOAK_LOAD
The TCODE_MOCK_LLM value that selects SoakLoadEchoLlmClient (epic #3866’s load-realistic follow-up soak).
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 InferenceAdapter> task.run executions share.