1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Object-safe trait abstraction over the concrete `LlmClient`.
//!
//! Why: The multi-turn agent loop must be unit-testable without issuing real
//! HTTP requests. The concrete `LlmClient` performs network I/O in its inherent
//! `chat` method, so the loop depends on this trait instead — production wires in
//! the real `LlmClient`, tests wire in a scripted mock. Defining the seam here
//! keeps `LlmClient` itself free of test-only machinery.
//! What: Declares `LlmClientTrait` with a single `chat` method mirroring
//! `LlmClient::chat`, and provides the blanket-free impl for `LlmClient` that
//! delegates to the existing inherent method.
//! Test: `client_trait::tests::llm_client_implements_trait` proves `LlmClient`
//! satisfies the trait via a `dyn` coercion; the loop's mock (in
//! `agent_loop::tests`) exercises the trait independently of the network.
use async_trait;
use ;
/// Object-safe interface for issuing a single chat-completions call.
///
/// Why: Lets `AgentLoop` accept an `Arc<dyn LlmClientTrait>` so the network
/// client can be swapped for a deterministic stub in tests. `Send + Sync` are
/// required because the loop runs under `tokio` and may be shared across tasks.
/// What: A one-method async trait whose signature matches `LlmClient::chat`
/// exactly, so the concrete client implements it by trivial delegation.
/// Test: `llm_client_implements_trait`.
// ── Tests ─────────────────────────────────────────────────────────────────────