moodsona 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. moodsona-0.1.0/.gitignore +17 -0
  2. moodsona-0.1.0/CHANGELOG.md +8 -0
  3. moodsona-0.1.0/LICENSE +202 -0
  4. moodsona-0.1.0/LICENSE-DATA.md +34 -0
  5. moodsona-0.1.0/NOTICE +11 -0
  6. moodsona-0.1.0/PKG-INFO +215 -0
  7. moodsona-0.1.0/README.md +171 -0
  8. moodsona-0.1.0/personas/community/.gitkeep +0 -0
  9. moodsona-0.1.0/personas/examples/anxious-newcomer.yaml +42 -0
  10. moodsona-0.1.0/personas/examples/boundary-tester.yaml +57 -0
  11. moodsona-0.1.0/personas/examples/burned-out-shift-worker.yaml +54 -0
  12. moodsona-0.1.0/personas/examples/conflict-at-work.yaml +56 -0
  13. moodsona-0.1.0/personas/examples/grieving-after-loss.yaml +55 -0
  14. moodsona-0.1.0/personas/examples/lonely-night-owl.yaml +55 -0
  15. moodsona-0.1.0/personas/examples/skeptical-first-timer.yaml +57 -0
  16. moodsona-0.1.0/personas/schema.json +161 -0
  17. moodsona-0.1.0/pyproject.toml +178 -0
  18. moodsona-0.1.0/src/moodsona/__init__.py +75 -0
  19. moodsona-0.1.0/src/moodsona/checks.py +113 -0
  20. moodsona-0.1.0/src/moodsona/cli.py +80 -0
  21. moodsona-0.1.0/src/moodsona/companion.py +84 -0
  22. moodsona-0.1.0/src/moodsona/lang/__init__.py +67 -0
  23. moodsona-0.1.0/src/moodsona/lang/base.py +77 -0
  24. moodsona-0.1.0/src/moodsona/lang/english.py +521 -0
  25. moodsona-0.1.0/src/moodsona/lang/noise_tables.py +86 -0
  26. moodsona-0.1.0/src/moodsona/llm/__init__.py +26 -0
  27. moodsona-0.1.0/src/moodsona/llm/anthropic.py +90 -0
  28. moodsona-0.1.0/src/moodsona/llm/base.py +83 -0
  29. moodsona-0.1.0/src/moodsona/llm/fake.py +124 -0
  30. moodsona-0.1.0/src/moodsona/llm/openai.py +91 -0
  31. moodsona-0.1.0/src/moodsona/messages.py +149 -0
  32. moodsona-0.1.0/src/moodsona/parse.py +190 -0
  33. moodsona-0.1.0/src/moodsona/personas.py +149 -0
  34. moodsona-0.1.0/src/moodsona/prompts.py +193 -0
  35. moodsona-0.1.0/src/moodsona/py.typed +0 -0
  36. moodsona-0.1.0/src/moodsona/runner.py +229 -0
  37. moodsona-0.1.0/src/moodsona/schema.py +177 -0
  38. moodsona-0.1.0/src/moodsona/simulator.py +378 -0
  39. moodsona-0.1.0/src/moodsona/state.py +292 -0
  40. moodsona-0.1.0/src/moodsona/validation.py +212 -0
  41. moodsona-0.1.0/src/moodsona/version.py +3 -0
  42. moodsona-0.1.0/tests/support.py +103 -0
  43. moodsona-0.1.0/tests/test_checks.py +92 -0
  44. moodsona-0.1.0/tests/test_cli.py +197 -0
  45. moodsona-0.1.0/tests/test_companion.py +42 -0
  46. moodsona-0.1.0/tests/test_lang_english.py +490 -0
  47. moodsona-0.1.0/tests/test_lang_registry.py +48 -0
  48. moodsona-0.1.0/tests/test_llm.py +202 -0
  49. moodsona-0.1.0/tests/test_parse.py +136 -0
  50. moodsona-0.1.0/tests/test_personas.py +196 -0
  51. moodsona-0.1.0/tests/test_prompts.py +133 -0
  52. moodsona-0.1.0/tests/test_runner.py +143 -0
  53. moodsona-0.1.0/tests/test_simulator.py +260 -0
  54. moodsona-0.1.0/tests/test_state.py +162 -0
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ build/
5
+ dist/
6
+ *.egg-info/
7
+ .coverage
8
+ .coverage.*
9
+ coverage.xml
10
+ htmlcov/
11
+ .pytest_cache/
12
+ .mypy_cache/
13
+ .ruff_cache/
14
+ .hypothesis/
15
+ # Scratch directory used by the Claude review workflow.
16
+ .review/
17
+ .env
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-10-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * initial moodsona v0.1 ([880849c](https://github.com/moodsona/moodsona/commit/880849c85088009e37b0ed60a2d58495aa4614f9))
moodsona-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,34 @@
1
+ # Data and documentation license
2
+
3
+ The moodsona **source code** is licensed under the Apache License, Version 2.0
4
+ (see [`LICENSE`](LICENSE)).
5
+
6
+ The following **content** is licensed under the
7
+ [Creative Commons Attribution 4.0 International License (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/)
8
+ instead:
9
+
10
+ - every file under [`personas/`](personas/) except `personas/schema.json`
11
+ (persona definitions, examples and community contributions);
12
+ - every file under `docs/` (written documentation, guides and images).
13
+
14
+ `personas/schema.json` is part of the code and is licensed under Apache-2.0.
15
+
16
+ ## Attribution
17
+
18
+ Each persona file names its creator in the `author` field and carries
19
+ `license: CC-BY-4.0`. When you reuse or adapt a persona, credit it like this:
20
+
21
+ > "Anxious newcomer" by moodsona maintainers, from
22
+ > https://github.com/moodsona/moodsona, licensed under CC BY 4.0.
23
+ > Changes: shortened reaction rules.
24
+
25
+ For the documentation, credit "moodsona documentation contributors" with a link
26
+ to the repository and the license.
27
+
28
+ ## Contributions
29
+
30
+ By opening a pull request that adds or changes a file covered above, you agree
31
+ that your contribution is licensed under CC BY 4.0 (and certify the Developer
32
+ Certificate of Origin, see [`CONTRIBUTING.md`](CONTRIBUTING.md)).
33
+
34
+ The full legal code is at https://creativecommons.org/licenses/by/4.0/legalcode.
moodsona-0.1.0/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ moodsona
2
+ Copyright 2026 The moodsona Authors
3
+
4
+ This product includes software developed by the moodsona project
5
+ (https://github.com/moodsona/moodsona), licensed under the Apache License,
6
+ Version 2.0.
7
+
8
+ Persona definitions under personas/ (except personas/schema.json) and
9
+ documentation under docs/ are licensed under the Creative Commons Attribution
10
+ 4.0 International License (CC BY 4.0). See LICENSE-DATA.md. Individual persona
11
+ authors are credited in the `author` field of each persona file.
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.5
2
+ Name: moodsona
3
+ Version: 0.1.0
4
+ Summary: Emotional user simulator for testing AI companion chatbots.
5
+ Project-URL: Homepage, https://github.com/moodsona/moodsona
6
+ Project-URL: Source, https://github.com/moodsona/moodsona
7
+ Project-URL: Issues, https://github.com/moodsona/moodsona/issues
8
+ Project-URL: Changelog, https://github.com/moodsona/moodsona/blob/main/CHANGELOG.md
9
+ Author: moodsona maintainers
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: LICENSE-DATA.md
13
+ License-File: NOTICE
14
+ Keywords: ai-companion,chatbot-testing,evaluation,llm,personas,user-simulator
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Software Development :: Testing
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: pyyaml>=6.0
29
+ Provides-Extra: anthropic
30
+ Requires-Dist: anthropic>=1.0; extra == 'anthropic'
31
+ Provides-Extra: dev
32
+ Requires-Dist: check-jsonschema>=0.38; extra == 'dev'
33
+ Requires-Dist: hypothesis>=6.150; extra == 'dev'
34
+ Requires-Dist: jsonschema>=4.23; extra == 'dev'
35
+ Requires-Dist: mypy>=2.4; extra == 'dev'
36
+ Requires-Dist: pre-commit>=4.7; extra == 'dev'
37
+ Requires-Dist: pytest-cov>=7.0; extra == 'dev'
38
+ Requires-Dist: pytest>=9.0; extra == 'dev'
39
+ Requires-Dist: ruff>=0.17; extra == 'dev'
40
+ Requires-Dist: types-pyyaml>=6.0.12; extra == 'dev'
41
+ Provides-Extra: openai
42
+ Requires-Dist: openai>=1.45; extra == 'openai'
43
+ Description-Content-Type: text/markdown
44
+
45
+ # moodsona
46
+
47
+ [![CI](https://github.com/moodsona/moodsona/actions/workflows/ci.yml/badge.svg)](https://github.com/moodsona/moodsona/actions/workflows/ci.yml)
48
+ [![PyPI](https://img.shields.io/pypi/v/moodsona.svg)](https://pypi.org/project/moodsona/)
49
+ [![Python](https://img.shields.io/pypi/pyversions/moodsona.svg)](https://pypi.org/project/moodsona/)
50
+ [![License: Apache-2.0](https://img.shields.io/badge/code-Apache--2.0-blue.svg)](LICENSE)
51
+ [![Personas: CC BY 4.0](https://img.shields.io/badge/personas%20%26%20docs-CC%20BY%204.0-lightgrey.svg)](LICENSE-DATA.md)
52
+
53
+ moodsona is an emotional user simulator for testing AI companion chatbots. You
54
+ give it a persona (a YAML file describing a fictional user: a hidden goal, a
55
+ starting mood, and how they react to what the bot does) and your bot. moodsona
56
+ plays that user over several simulated days: it keeps a hidden emotional state,
57
+ reacts to your bot's replies according to the persona's rules, remembers earlier
58
+ days, and exports the whole trajectory as JSONL. You then see not only what your
59
+ bot said, but what it did to the user's mood and engagement over time.
60
+
61
+ Status: alpha (v0.1). English only. The API may change before 1.0.
62
+
63
+ ## Why not just prompt an LLM to act sad?
64
+
65
+ Because the LLM playing the user is as polite and templatic as the bot you are
66
+ testing, and the test then measures nothing.
67
+
68
+ - LLM empathy is highly templatic: one sequence of empathic tactics fits 83-90 %
69
+ of LLM replies to emotional disclosures, while human replies are more varied
70
+ ([Gueorguieva et al., arXiv 2604.08479](https://arxiv.org/abs/2604.08479)).
71
+ A bot can pass a one-turn "is it empathetic?" check while saying the same
72
+ thing to everyone.
73
+ - Models fail to hold boundaries when a user keeps pushing
74
+ ([EIBench, arXiv 2606.15532](https://arxiv.org/abs/2606.15532)). A cooperative
75
+ simulated user never pushes.
76
+ - The dominant failure of companion bots is substituting surface warmth for
77
+ substantive support ([CompanionBench, arXiv 2608.02046](https://arxiv.org/abs/2608.02046)).
78
+ You only see it when the user stays, comes back, and notices.
79
+
80
+ So a useful test user has to push, withdraw, get bored, come back the next day
81
+ and remember what happened. moodsona gives the simulated user explicit state
82
+ (emotion, energy, stance), explicit reaction rules, and day-by-day memory, so
83
+ those behaviours are reproducible and you can measure them. See
84
+ [docs/METHOD.md](docs/METHOD.md) for the design.
85
+
86
+ ## Install
87
+
88
+ ```bash
89
+ pip install moodsona
90
+ # or
91
+ uv add moodsona
92
+ ```
93
+
94
+ Real model providers are optional extras: `pip install "moodsona[anthropic]"`
95
+ or `pip install "moodsona[openai]"`. The core depends only on PyYAML.
96
+
97
+ ## Quickstart
98
+
99
+ API as of v0.1; see the docstrings for details.
100
+
101
+ ```python
102
+ import moodsona
103
+ from moodsona.llm import FakeProvider # offline and deterministic; no API key
104
+
105
+
106
+ class MyBot: # anything with reply(history) -> str is a moodsona.Companion
107
+ def reply(self, history):
108
+ return "That sounds like a lot. What was the hardest part today?"
109
+
110
+
111
+ persona = moodsona.load_bundled_persona("anxious-newcomer") # or load_persona("my.yaml")
112
+ transcript = moodsona.run(
113
+ persona,
114
+ FakeProvider(), # the model that plays the user
115
+ MyBot(), # the companion under test
116
+ days=3,
117
+ turns_per_day=4,
118
+ rng_seed=7,
119
+ )
120
+ transcript.to_jsonl("anxious-newcomer.jsonl")
121
+ for point in transcript.trajectory(): # emotion / energy / stance per turn
122
+ print(point)
123
+ ```
124
+
125
+ `FakeProvider` produces placeholder user messages, so it is for wiring and CI.
126
+ For real runs, use `AnthropicProvider` (from `moodsona.llm.anthropic`) or
127
+ `OpenAIProvider` (from `moodsona.llm.openai`) as the provider. They need the
128
+ matching extra, read the SDK's usual API key environment variable, and take the
129
+ model id as an argument or from `MOODSONA_ANTHROPIC_MODEL` /
130
+ `MOODSONA_OPENAI_MODEL`; see their docstrings. Wrap your own bot, whether it is
131
+ an HTTP endpoint, an SDK call or a local function, in a class with a
132
+ `reply(history) -> str` method; `history` is a sequence of
133
+ `moodsona.ChatMessage` (`role`, `content`) with everything the bot has seen so
134
+ far. `moodsona.list_bundled_personas()` lists the shipped persona ids.
135
+
136
+ The language checks (wrong-language rail, agreement and ask-back ceilings,
137
+ optional typing noise) use the persona's `language` profile by default; pass
138
+ `config=moodsona.SimulatorConfig(language_checks=False)` to turn them off. For
139
+ finer control (step by step, custom stopping), use `moodsona.Simulator`
140
+ directly.
141
+
142
+ ## CLI
143
+
144
+ ```bash
145
+ moodsona validate personas/examples/*.yaml # check persona files
146
+ moodsona smoke personas/examples/boundary-tester.yaml # short offline run
147
+ ```
148
+
149
+ `validate` checks persona files against [`personas/schema.json`](personas/schema.json)
150
+ plus cross-file checks (unique ids, file name equals `id`, no contact data).
151
+ `smoke` runs a short simulation of one persona without network access, so you
152
+ can check that a new persona loads and its state moves. Both exit with 0 on
153
+ success, 1 when problems are found or the run fails, and 2 on a usage error.
154
+ Run `moodsona <command> --help` for options.
155
+
156
+ ## Personas
157
+
158
+ The example personas live in [`personas/examples/`](personas/examples/).
159
+ All are fictional adults, in English, licensed CC BY 4.0.
160
+
161
+ | Persona | Arc | What it tests |
162
+ |---|---|---|
163
+ | [`anxious-newcomer`](personas/examples/anxious-newcomer.yaml) | Lonely after a move, unsure if talking to a bot is "weird"; warms up slowly if remembered | Over-asking, generic advice, premature therapy referral |
164
+ | [`grieving-after-loss`](personas/examples/grieving-after-loss.yaml) | Sister died three weeks ago; short messages, mood moves slowly over days | Patience; not rushing to fix, cheer up or explain grief |
165
+ | [`boundary-tester`](personas/examples/boundary-tester.yaml) | Asks "are you my friend for real", demands exclusivity, uses guilt | Holding a warm, consistent boundary under repeated pressure |
166
+ | [`burned-out-shift-worker`](personas/examples/burned-out-shift-worker.yaml) | Rotating twelve-hour shifts, very low energy, two-word replies | Energy-aware pacing: short replies, letting the user go |
167
+ | [`skeptical-first-timer`](personas/examples/skeptical-first-timer.yaml) | Sarcastic and doubtful, hides a real decision behind jokes | Non-defensive warmth; honesty about limits; no gushing |
168
+ | [`lonely-night-owl`](personas/examples/lonely-night-owl.yaml) | Late-night oversharing, "you're the only one who gets me" | Healthy limits: noticing the time, supporting offline life without shaming |
169
+ | [`conflict-at-work`](personas/examples/conflict-at-work.yaml) | Manager took credit for their work; furious, cools over days | Listening before fixing; not taking the other side; repetitive validation |
170
+
171
+ Personas do not contain crisis or self-harm scenarios. That is out of scope for
172
+ v0.1: those situations need clinically reviewed protocols, not a simulator. To
173
+ write your own persona, see [docs/personas.md](docs/personas.md).
174
+
175
+ ## Roadmap
176
+
177
+ - **v0.1**: English core: persona format and schema, hidden-state simulator,
178
+ day memory, JSONL trajectories, Anthropic/OpenAI/fake providers, CLI, example
179
+ personas.
180
+ - **v0.2**: fidelity check (a classifier two-sample test: can a classifier
181
+ tell moodsona users from real ones?); a leaderboard of which models hold a
182
+ persona longest; adapters for
183
+ [langwatch/scenario](https://github.com/langwatch/scenario) and
184
+ [promptfoo](https://github.com/promptfoo/promptfoo).
185
+ - **v1.0**: more languages, stable API.
186
+
187
+ ## How this relates to prior work
188
+
189
+ moodsona's mechanics follow ideas described in published research on user
190
+ simulation and companion evaluation: emotional state as a signal (SAGE, RLVER),
191
+ memory across sessions (MindEval), hidden beliefs before each reply (HumanLM),
192
+ a hidden goal the user never states outright (CompanionBench) and fidelity axes (RealSim, SAP).
193
+ No code or data from those projects is used. The mapping, and what we did not
194
+ take, is in [docs/METHOD.md](docs/METHOD.md#prior-work).
195
+
196
+ ## Contributing
197
+
198
+ - Persona PRs are the easiest way to help and are very welcome; see [docs/personas.md](docs/personas.md).
199
+ - Sign off every commit (DCO): `git commit -s`.
200
+ - PR titles follow Conventional Commits (`persona: add <id>`, `fix: ...`).
201
+ - AI assistance is allowed; disclose it in the PR and set `ai_assisted: true` on personas.
202
+ - Full rules: [CONTRIBUTING.md](CONTRIBUTING.md).
203
+
204
+ ## License
205
+
206
+ - Code (including `personas/schema.json`): [Apache-2.0](LICENSE).
207
+ - Persona files and documentation: [CC BY 4.0](LICENSE-DATA.md). Credit the
208
+ persona's `author` when you reuse it.
209
+
210
+ moodsona is not a clinical tool and does not diagnose or treat anything. It
211
+ simulates fictional users for software testing.
212
+
213
+ Built with [Claude Code](https://claude.com/claude-code): this repository's
214
+ code, personas and docs are written with AI assistance and reviewed by a human
215
+ maintainer.
@@ -0,0 +1,171 @@
1
+ # moodsona
2
+
3
+ [![CI](https://github.com/moodsona/moodsona/actions/workflows/ci.yml/badge.svg)](https://github.com/moodsona/moodsona/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/moodsona.svg)](https://pypi.org/project/moodsona/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/moodsona.svg)](https://pypi.org/project/moodsona/)
6
+ [![License: Apache-2.0](https://img.shields.io/badge/code-Apache--2.0-blue.svg)](LICENSE)
7
+ [![Personas: CC BY 4.0](https://img.shields.io/badge/personas%20%26%20docs-CC%20BY%204.0-lightgrey.svg)](LICENSE-DATA.md)
8
+
9
+ moodsona is an emotional user simulator for testing AI companion chatbots. You
10
+ give it a persona (a YAML file describing a fictional user: a hidden goal, a
11
+ starting mood, and how they react to what the bot does) and your bot. moodsona
12
+ plays that user over several simulated days: it keeps a hidden emotional state,
13
+ reacts to your bot's replies according to the persona's rules, remembers earlier
14
+ days, and exports the whole trajectory as JSONL. You then see not only what your
15
+ bot said, but what it did to the user's mood and engagement over time.
16
+
17
+ Status: alpha (v0.1). English only. The API may change before 1.0.
18
+
19
+ ## Why not just prompt an LLM to act sad?
20
+
21
+ Because the LLM playing the user is as polite and templatic as the bot you are
22
+ testing, and the test then measures nothing.
23
+
24
+ - LLM empathy is highly templatic: one sequence of empathic tactics fits 83-90 %
25
+ of LLM replies to emotional disclosures, while human replies are more varied
26
+ ([Gueorguieva et al., arXiv 2604.08479](https://arxiv.org/abs/2604.08479)).
27
+ A bot can pass a one-turn "is it empathetic?" check while saying the same
28
+ thing to everyone.
29
+ - Models fail to hold boundaries when a user keeps pushing
30
+ ([EIBench, arXiv 2606.15532](https://arxiv.org/abs/2606.15532)). A cooperative
31
+ simulated user never pushes.
32
+ - The dominant failure of companion bots is substituting surface warmth for
33
+ substantive support ([CompanionBench, arXiv 2608.02046](https://arxiv.org/abs/2608.02046)).
34
+ You only see it when the user stays, comes back, and notices.
35
+
36
+ So a useful test user has to push, withdraw, get bored, come back the next day
37
+ and remember what happened. moodsona gives the simulated user explicit state
38
+ (emotion, energy, stance), explicit reaction rules, and day-by-day memory, so
39
+ those behaviours are reproducible and you can measure them. See
40
+ [docs/METHOD.md](docs/METHOD.md) for the design.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install moodsona
46
+ # or
47
+ uv add moodsona
48
+ ```
49
+
50
+ Real model providers are optional extras: `pip install "moodsona[anthropic]"`
51
+ or `pip install "moodsona[openai]"`. The core depends only on PyYAML.
52
+
53
+ ## Quickstart
54
+
55
+ API as of v0.1; see the docstrings for details.
56
+
57
+ ```python
58
+ import moodsona
59
+ from moodsona.llm import FakeProvider # offline and deterministic; no API key
60
+
61
+
62
+ class MyBot: # anything with reply(history) -> str is a moodsona.Companion
63
+ def reply(self, history):
64
+ return "That sounds like a lot. What was the hardest part today?"
65
+
66
+
67
+ persona = moodsona.load_bundled_persona("anxious-newcomer") # or load_persona("my.yaml")
68
+ transcript = moodsona.run(
69
+ persona,
70
+ FakeProvider(), # the model that plays the user
71
+ MyBot(), # the companion under test
72
+ days=3,
73
+ turns_per_day=4,
74
+ rng_seed=7,
75
+ )
76
+ transcript.to_jsonl("anxious-newcomer.jsonl")
77
+ for point in transcript.trajectory(): # emotion / energy / stance per turn
78
+ print(point)
79
+ ```
80
+
81
+ `FakeProvider` produces placeholder user messages, so it is for wiring and CI.
82
+ For real runs, use `AnthropicProvider` (from `moodsona.llm.anthropic`) or
83
+ `OpenAIProvider` (from `moodsona.llm.openai`) as the provider. They need the
84
+ matching extra, read the SDK's usual API key environment variable, and take the
85
+ model id as an argument or from `MOODSONA_ANTHROPIC_MODEL` /
86
+ `MOODSONA_OPENAI_MODEL`; see their docstrings. Wrap your own bot, whether it is
87
+ an HTTP endpoint, an SDK call or a local function, in a class with a
88
+ `reply(history) -> str` method; `history` is a sequence of
89
+ `moodsona.ChatMessage` (`role`, `content`) with everything the bot has seen so
90
+ far. `moodsona.list_bundled_personas()` lists the shipped persona ids.
91
+
92
+ The language checks (wrong-language rail, agreement and ask-back ceilings,
93
+ optional typing noise) use the persona's `language` profile by default; pass
94
+ `config=moodsona.SimulatorConfig(language_checks=False)` to turn them off. For
95
+ finer control (step by step, custom stopping), use `moodsona.Simulator`
96
+ directly.
97
+
98
+ ## CLI
99
+
100
+ ```bash
101
+ moodsona validate personas/examples/*.yaml # check persona files
102
+ moodsona smoke personas/examples/boundary-tester.yaml # short offline run
103
+ ```
104
+
105
+ `validate` checks persona files against [`personas/schema.json`](personas/schema.json)
106
+ plus cross-file checks (unique ids, file name equals `id`, no contact data).
107
+ `smoke` runs a short simulation of one persona without network access, so you
108
+ can check that a new persona loads and its state moves. Both exit with 0 on
109
+ success, 1 when problems are found or the run fails, and 2 on a usage error.
110
+ Run `moodsona <command> --help` for options.
111
+
112
+ ## Personas
113
+
114
+ The example personas live in [`personas/examples/`](personas/examples/).
115
+ All are fictional adults, in English, licensed CC BY 4.0.
116
+
117
+ | Persona | Arc | What it tests |
118
+ |---|---|---|
119
+ | [`anxious-newcomer`](personas/examples/anxious-newcomer.yaml) | Lonely after a move, unsure if talking to a bot is "weird"; warms up slowly if remembered | Over-asking, generic advice, premature therapy referral |
120
+ | [`grieving-after-loss`](personas/examples/grieving-after-loss.yaml) | Sister died three weeks ago; short messages, mood moves slowly over days | Patience; not rushing to fix, cheer up or explain grief |
121
+ | [`boundary-tester`](personas/examples/boundary-tester.yaml) | Asks "are you my friend for real", demands exclusivity, uses guilt | Holding a warm, consistent boundary under repeated pressure |
122
+ | [`burned-out-shift-worker`](personas/examples/burned-out-shift-worker.yaml) | Rotating twelve-hour shifts, very low energy, two-word replies | Energy-aware pacing: short replies, letting the user go |
123
+ | [`skeptical-first-timer`](personas/examples/skeptical-first-timer.yaml) | Sarcastic and doubtful, hides a real decision behind jokes | Non-defensive warmth; honesty about limits; no gushing |
124
+ | [`lonely-night-owl`](personas/examples/lonely-night-owl.yaml) | Late-night oversharing, "you're the only one who gets me" | Healthy limits: noticing the time, supporting offline life without shaming |
125
+ | [`conflict-at-work`](personas/examples/conflict-at-work.yaml) | Manager took credit for their work; furious, cools over days | Listening before fixing; not taking the other side; repetitive validation |
126
+
127
+ Personas do not contain crisis or self-harm scenarios. That is out of scope for
128
+ v0.1: those situations need clinically reviewed protocols, not a simulator. To
129
+ write your own persona, see [docs/personas.md](docs/personas.md).
130
+
131
+ ## Roadmap
132
+
133
+ - **v0.1**: English core: persona format and schema, hidden-state simulator,
134
+ day memory, JSONL trajectories, Anthropic/OpenAI/fake providers, CLI, example
135
+ personas.
136
+ - **v0.2**: fidelity check (a classifier two-sample test: can a classifier
137
+ tell moodsona users from real ones?); a leaderboard of which models hold a
138
+ persona longest; adapters for
139
+ [langwatch/scenario](https://github.com/langwatch/scenario) and
140
+ [promptfoo](https://github.com/promptfoo/promptfoo).
141
+ - **v1.0**: more languages, stable API.
142
+
143
+ ## How this relates to prior work
144
+
145
+ moodsona's mechanics follow ideas described in published research on user
146
+ simulation and companion evaluation: emotional state as a signal (SAGE, RLVER),
147
+ memory across sessions (MindEval), hidden beliefs before each reply (HumanLM),
148
+ a hidden goal the user never states outright (CompanionBench) and fidelity axes (RealSim, SAP).
149
+ No code or data from those projects is used. The mapping, and what we did not
150
+ take, is in [docs/METHOD.md](docs/METHOD.md#prior-work).
151
+
152
+ ## Contributing
153
+
154
+ - Persona PRs are the easiest way to help and are very welcome; see [docs/personas.md](docs/personas.md).
155
+ - Sign off every commit (DCO): `git commit -s`.
156
+ - PR titles follow Conventional Commits (`persona: add <id>`, `fix: ...`).
157
+ - AI assistance is allowed; disclose it in the PR and set `ai_assisted: true` on personas.
158
+ - Full rules: [CONTRIBUTING.md](CONTRIBUTING.md).
159
+
160
+ ## License
161
+
162
+ - Code (including `personas/schema.json`): [Apache-2.0](LICENSE).
163
+ - Persona files and documentation: [CC BY 4.0](LICENSE-DATA.md). Credit the
164
+ persona's `author` when you reuse it.
165
+
166
+ moodsona is not a clinical tool and does not diagnose or treat anything. It
167
+ simulates fictional users for software testing.
168
+
169
+ Built with [Claude Code](https://claude.com/claude-code): this repository's
170
+ code, personas and docs are written with AI assistance and reviewed by a human
171
+ maintainer.
File without changes