Commit cb539ea
Fix free thinking: add context, dedup, and reorganize tests (jaredlockhart#837)
* Fix free thinking: add context, dedup, and reorganize tests
Free thinking cycles were missing context (profile, previous thoughts,
dislikes) and skipping embedding dedup entirely. This caused Penny to
fixate on the same topics (quantum computing, exoplanets) across dozens
of free thinking cycles with no dedup catching the repetition.
The root cause was special-casing free thinking as a distinct codepath
rather than treating preference_id=None as a valid filter value. Now
all thinking modes (seeded, free, news browse) follow the same codepath
— the only difference is the initial prompt.
Changes:
- ThoughtStore.get_recent_by_preference accepts preference_id: int | None
- ThinkingAgent removes _free_thinking flag and all branching on it
- get_context, _build_thought_context, _is_duplicate_thought, and
handle_text_step all use the same codepath regardless of mode
- Tests reorganized: comprehensive integration tests first (seeded +
free), then special cases, then error cases, then unit tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix flaky news browsing test: force non-free-thinking path
The test had no monkeypatch on random.random, so it sometimes hit the
free-thinking path instead of the news browse fallback, causing the
assertion on "news" in the prompt to fail on CI.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Jared Lockhart <119884+jaredlockhart@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ffb7043 commit cb539ea
File tree
3 files changed
+303
-496
lines changed- penny/penny
- agents
- database
- tests/agents
3 files changed
+303
-496
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
43 | 37 | | |
44 | 38 | | |
45 | 39 | | |
| |||
66 | 60 | | |
67 | 61 | | |
68 | 62 | | |
69 | | - | |
70 | 63 | | |
71 | 64 | | |
72 | 65 | | |
| |||
75 | 68 | | |
76 | 69 | | |
77 | 70 | | |
78 | | - | |
79 | 71 | | |
80 | 72 | | |
81 | 73 | | |
82 | 74 | | |
83 | 75 | | |
84 | | - | |
85 | 76 | | |
86 | 77 | | |
87 | 78 | | |
| |||
97 | 88 | | |
98 | 89 | | |
99 | 90 | | |
100 | | - | |
| 91 | + | |
101 | 92 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 93 | + | |
| 94 | + | |
105 | 95 | | |
106 | | - | |
107 | | - | |
108 | 96 | | |
109 | 97 | | |
110 | 98 | | |
| |||
113 | 101 | | |
114 | 102 | | |
115 | 103 | | |
116 | | - | |
| 104 | + | |
117 | 105 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 106 | + | |
| 107 | + | |
121 | 108 | | |
122 | | - | |
123 | | - | |
124 | 109 | | |
125 | 110 | | |
126 | 111 | | |
127 | 112 | | |
128 | 113 | | |
129 | 114 | | |
130 | 115 | | |
131 | | - | |
| 116 | + | |
132 | 117 | | |
133 | 118 | | |
134 | 119 | | |
| |||
202 | 187 | | |
203 | 188 | | |
204 | 189 | | |
205 | | - | |
206 | | - | |
| 190 | + | |
| 191 | + | |
207 | 192 | | |
208 | 193 | | |
209 | 194 | | |
| |||
248 | 233 | | |
249 | 234 | | |
250 | 235 | | |
251 | | - | |
252 | | - | |
| 236 | + | |
253 | 237 | | |
254 | 238 | | |
255 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
62 | | - | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
0 commit comments