thinkless 0.5.0__tar.gz → 0.6.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 (136) hide show
  1. {thinkless-0.5.0 → thinkless-0.6.0}/CHANGELOG.md +94 -1
  2. {thinkless-0.5.0 → thinkless-0.6.0}/PKG-INFO +50 -13
  3. {thinkless-0.5.0 → thinkless-0.6.0}/README.md +43 -6
  4. {thinkless-0.5.0 → thinkless-0.6.0}/pyproject.toml +12 -3
  5. thinkless-0.6.0/src/thinkless/_version.py +1 -0
  6. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/habits.py +13 -0
  7. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/engine.py +12 -4
  8. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/apis.py +8 -2
  9. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/calls.py +6 -2
  10. thinkless-0.6.0/src/thinkless/habits/demo.py +232 -0
  11. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/gate.py +3 -1
  12. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/learn.py +54 -9
  13. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/report.py +2 -4
  14. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/runtime.py +67 -8
  15. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/transport.py +35 -9
  16. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/wire.py +34 -7
  17. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/integrations/langgraph.py +20 -4
  18. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/limits.py +2 -2
  19. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/factory.py +3 -1
  20. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/llm.py +3 -0
  21. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/systemone.py +5 -2
  22. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/wire.py +53 -45
  23. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/server/app.py +7 -4
  24. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/shadow/report.py +3 -2
  25. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/shadow/runner.py +5 -2
  26. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/summary.py +4 -1
  27. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_cli_and_viewer.py +2 -0
  28. thinkless-0.6.0/tests/unit/test_core_review.py +166 -0
  29. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_habits.py +229 -2
  30. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_integrations.py +14 -0
  31. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_openrouter.py +2 -0
  32. thinkless-0.5.0/src/thinkless/_version.py +0 -1
  33. {thinkless-0.5.0 → thinkless-0.6.0}/.gitignore +0 -0
  34. {thinkless-0.5.0 → thinkless-0.6.0}/LICENSE +0 -0
  35. {thinkless-0.5.0 → thinkless-0.6.0}/benchmarks/decisions/README.md +0 -0
  36. {thinkless-0.5.0 → thinkless-0.6.0}/benchmarks/habits/README.md +0 -0
  37. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/__init__.py +0 -0
  38. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/__main__.py +0 -0
  39. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/_hub.py +0 -0
  40. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/_json.py +0 -0
  41. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/__init__.py +0 -0
  42. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/__init__.py +0 -0
  43. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/leaderboard.py +0 -0
  44. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/run.py +0 -0
  45. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/score.py +0 -0
  46. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/tasks.json +0 -0
  47. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/tasks.py +0 -0
  48. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/decisions/verify.py +0 -0
  49. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/intents.py +0 -0
  50. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/intents_report.py +0 -0
  51. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/metrics.py +0 -0
  52. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/report.py +0 -0
  53. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/bench/support.py +0 -0
  54. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/__init__.py +0 -0
  55. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/decisions.py +0 -0
  56. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/main.py +0 -0
  57. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/serve.py +0 -0
  58. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/shadow.py +0 -0
  59. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/cli/traces.py +0 -0
  60. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/confidence.py +0 -0
  61. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/data/pricing.toml +0 -0
  62. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/data/viewer.html +0 -0
  63. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/decision.py +0 -0
  64. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/__init__.py +0 -0
  65. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/__init__.py +0 -0
  66. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/agent.py +0 -0
  67. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/data/calibration.jsonl +0 -0
  68. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/data/scenarios.jsonl +0 -0
  69. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/data/world.json +0 -0
  70. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/questions.py +0 -0
  71. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/stack.py +0 -0
  72. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/demo/support/world.py +0 -0
  73. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/errors.py +0 -0
  74. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/__init__.py +0 -0
  75. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/features.py +0 -0
  76. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/proxy.py +0 -0
  77. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/sites.py +0 -0
  78. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/habits/student.py +0 -0
  79. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/integrations/__init__.py +0 -0
  80. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/integrations/_messages.py +0 -0
  81. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/integrations/core.py +0 -0
  82. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/integrations/openai_agents.py +0 -0
  83. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/__init__.py +0 -0
  84. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/anthropic.py +0 -0
  85. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/base.py +0 -0
  86. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/local.py +0 -0
  87. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/openai_compat.py +0 -0
  88. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/openrouter.py +0 -0
  89. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/llm/scripted.py +0 -0
  90. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/logs.py +0 -0
  91. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/pricing.py +0 -0
  92. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/__init__.py +0 -0
  93. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/base.py +0 -0
  94. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/gliner.py +0 -0
  95. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/hf.py +0 -0
  96. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/laya.py +0 -0
  97. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/providers/rules.py +0 -0
  98. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/py.typed +0 -0
  99. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/questions.py +0 -0
  100. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/server/__init__.py +0 -0
  101. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/server/mcp.py +0 -0
  102. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/settings.py +0 -0
  103. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/shadow/__init__.py +0 -0
  104. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/shadow/compare.py +0 -0
  105. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/__init__.py +0 -0
  106. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/console.py +0 -0
  107. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/export.py +0 -0
  108. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/otel.py +0 -0
  109. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/sinks.py +0 -0
  110. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/span.py +0 -0
  111. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/tracer.py +0 -0
  112. {thinkless-0.5.0 → thinkless-0.6.0}/src/thinkless/tracing/viewer.py +0 -0
  113. {thinkless-0.5.0 → thinkless-0.6.0}/tests/__init__.py +0 -0
  114. {thinkless-0.5.0 → thinkless-0.6.0}/tests/conftest.py +0 -0
  115. {thinkless-0.5.0 → thinkless-0.6.0}/tests/local/__init__.py +0 -0
  116. {thinkless-0.5.0 → thinkless-0.6.0}/tests/local/test_local_models.py +0 -0
  117. {thinkless-0.5.0 → thinkless-0.6.0}/tests/network/__init__.py +0 -0
  118. {thinkless-0.5.0 → thinkless-0.6.0}/tests/network/test_openrouter_live.py +0 -0
  119. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/__init__.py +0 -0
  120. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_bench.py +0 -0
  121. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_confidence.py +0 -0
  122. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_decision_benchmark.py +0 -0
  123. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_engine.py +0 -0
  124. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_hf_classifier.py +0 -0
  125. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_limits.py +0 -0
  126. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_llm_decider.py +0 -0
  127. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_pricing_and_llm.py +0 -0
  128. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_questions.py +0 -0
  129. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_rules.py +0 -0
  130. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_server.py +0 -0
  131. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_shadow.py +0 -0
  132. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_support_demo.py +0 -0
  133. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_systemone.py +0 -0
  134. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_systemone_sdk_compat.py +0 -0
  135. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_trace_export.py +0 -0
  136. {thinkless-0.5.0 → thinkless-0.6.0}/tests/unit/test_tracing.py +0 -0
@@ -4,7 +4,100 @@ All notable changes are recorded here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
5
  [semantic versioning](https://semver.org/).
6
6
 
7
- ## Unreleased
7
+ ## 0.6.0 - 2026-11-22
8
+
9
+ A review of the whole package. Habits gets fixes for streams cut short,
10
+ several processes sharing one directory, and the Responses API's stored
11
+ state; typed decisions get fixes for rules that never fired, spend caps,
12
+ cost reporting and the System One wire. A demo anyone can run right after
13
+ `pip install thinkless`, and CI that holds every lower bound to its promise.
14
+
15
+ ### Added
16
+
17
+ - `thinkless habits demo`: a support agent's routing decision goes from
18
+ recording to probation to being answered locally, offline, with a stand-in
19
+ LLM, in about a second. It needs nothing beyond `pip install thinkless`,
20
+ and the README now starts with it.
21
+ - A Responses API call that continues a locally answered response
22
+ (`previous_response_id` naming a `resp_thinkless_` id) is sent on with the
23
+ earlier input and answer written out, since the provider never stored the
24
+ local answer. The process keeps the last 2,048 local answers for this.
25
+ - A logo, an architecture diagram of Habits and typed decisions (in the
26
+ README, the docs home page and the four planes page), and a social preview
27
+ image. The docs site uses the logo and gives every page a link preview.
28
+
29
+ ### Fixed
30
+
31
+ - A rule registered for a question never fired when the question had no
32
+ `name` and was asked through `decide_many({"intent": Choice(...)})`: rules
33
+ and Hugging Face classifiers looked it up by a name derived from its
34
+ instructions, so it went on to the next provider, often the paid LLM. An
35
+ unnamed question now takes the name it is given in the mapping, which
36
+ thresholds and traces already used. A LangGraph `router` also finds a
37
+ decision a `decision_node` stored under that name instead of asking again.
38
+ - A nested `engine.run()` without `max_cost_usd` lifted the spend cap of the
39
+ run around it. Every open run's cap now applies. `run(max_cost_usd=-1)`
40
+ also left a trace sink behind.
41
+ - `/v1/decide` and `/v1/systemone` counted a batched call's cost and tokens
42
+ once per question it answered, and left out paid attempts that were not
43
+ accepted. Both now report the run's total.
44
+ - `/v1/systemone` sent uncertain answers from providers without
45
+ probabilities at probability 1, so a ThinkLess client accepted answers the
46
+ server was not sure of. They are left out, like abstentions.
47
+ - Shadow mode counted only the cost of the accepted attempt, which
48
+ overstated savings and let spending pass `max_cost_usd`.
49
+ - One malformed entry in a System One reply, a `NaN` score from an LLM, or a
50
+ negative `Retry-After` header failed the whole call; each now spoils only
51
+ its own answer, or falls back to the normal backoff.
52
+ - `thinkless shadow report --min-calls 0` divided by zero when nothing had
53
+ been compared.
54
+ - Habits recorded a streamed answer the caller stopped reading, or that
55
+ broke off, as the LLM's complete answer. Truncated answers became training
56
+ data and, in an audit, counted as disagreement. A Chat Completions stream
57
+ now counts only with a finish reason or `[DONE]`, and a Messages stream
58
+ only with `message_stop`.
59
+ - A site suspended by one process could be switched back on by a learning
60
+ run in another process that had read the plan before the suspension. The
61
+ run now keeps a suspension written while it was busy. A process also stops
62
+ holding a suspension once another process has retrained the site and the
63
+ new student passed its own checks.
64
+ - Two writers saving the plan at once could leave a half-written
65
+ `plan.json`. Each write now uses its own temporary file, and the replace
66
+ is retried while a reader on Windows holds the file.
67
+ - The gate could stop one step short of testing every held-out answer, so a
68
+ student good enough to answer all of them kept up to about 9% of them
69
+ going to the LLM.
70
+ - Responses API calls in a stored `conversation` were treated as
71
+ answerable, although part of their context is on the provider's side.
72
+ - A tool-calling answer with malformed arguments raised inside Habits and
73
+ the call was not recorded.
74
+ - A forked worker kept writing into its parent's call log; each process now
75
+ writes its own file, as documented.
76
+ - `habits status` and `scan` counted audit and shadow agreement with a
77
+ slightly different rule from the one that drives suspension; all three now
78
+ share one.
79
+ - `Habits(target=1.0)` and other impossible settings were accepted and
80
+ failed later in every learning run; they are now rejected up front.
81
+ - The CLI failed to start with typer 0.12, which the requirements allowed
82
+ (it cannot read `str | None` options on Python 3.10). ThinkLess now needs
83
+ typer 0.13, and a new CI job runs the tests with every direct dependency
84
+ at its lowest allowed version.
85
+ - Older pydantic versions warned on import about the `model_input_tokens`
86
+ field of `TraceSummary`.
87
+ - Tests that need an optional extra (the OpenAI SDK, OpenTelemetry) now skip
88
+ when it is missing instead of failing.
89
+ - A Habits background learning test depended on thread timing and failed on
90
+ Windows; a mypy error in `llm/factory.py` under older mypy versions.
91
+ - A Habits student test compared a tuple holding a dict with
92
+ `pytest.approx`, which pytest 9.2 rejects; CI failed on every new run.
93
+
94
+ ### Changed
95
+
96
+ - The `laya` extra needs Laya 0.4.17 or newer (below 0.5). Laya releases
97
+ after 0.4.22 need transformers 5, which GLiNER2 does not support yet, so a
98
+ shared environment resolves to Laya 0.4.22.
99
+ - Dependabot opens a pull request only when a release falls outside the
100
+ supported range, instead of raising lower bounds, and CI runs weekly.
8
101
 
9
102
  ## 0.5.0 - 2026-10-17
10
103
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: thinkless
3
- Version: 0.5.0
4
- Summary: The decision plane for AI agents. Rules and small calibrated models make the routine decisions, the LLM is reserved for the steps that need thought, and every step is traced.
3
+ Version: 0.6.0
4
+ Summary: Stop using an LLM for every decision. Rules and small local models answer an AI agent's routine decisions, including ones learned from its own LLM once proven; the LLM keeps the steps that need it, and every step is traced.
5
5
  Project-URL: Homepage, https://github.com/inboxpraveen/ThinkLess
6
6
  Project-URL: Documentation, https://inboxpraveen.github.io/ThinkLess/
7
7
  Project-URL: Repository, https://github.com/inboxpraveen/ThinkLess
@@ -14,7 +14,7 @@ Project-URL: Funding, https://github.com/sponsors/inboxpraveen
14
14
  Author: Praveen Kumar
15
15
  License-Expression: Apache-2.0
16
16
  License-File: LICENSE
17
- Keywords: agents,ai-agents,benchmark,calibration,classification,decision-models,gliner,guardrails,jev,langgraph,laya,llm,llm-routing,mcp,observability,openai-agents,system-one,tracing
17
+ Keywords: agents,ai-agents,anthropic,benchmark,calibration,classification,cost-optimization,decision-models,gliner,guardrails,jev,knowledge-distillation,langchain,langgraph,laya,llm,llm-cost,llm-routing,mcp,observability,openai,openai-agents,system-one,tracing
18
18
  Classifier: Development Status :: 4 - Beta
19
19
  Classifier: Framework :: Pydantic :: 2
20
20
  Classifier: Intended Audience :: Developers
@@ -36,7 +36,7 @@ Requires-Dist: numpy>=1.24
36
36
  Requires-Dist: pydantic<3,>=2.6
37
37
  Requires-Dist: rich>=13.7
38
38
  Requires-Dist: tomli>=2.0; python_version < '3.11'
39
- Requires-Dist: typer>=0.12
39
+ Requires-Dist: typer>=0.13
40
40
  Provides-Extra: all
41
41
  Requires-Dist: accelerate>=1.0; extra == 'all'
42
42
  Requires-Dist: anthropic>=1.0; extra == 'all'
@@ -44,7 +44,7 @@ Requires-Dist: datasets>=3.0; extra == 'all'
44
44
  Requires-Dist: fastapi>=0.115; extra == 'all'
45
45
  Requires-Dist: gliner2[local]<3,>=2.0; extra == 'all'
46
46
  Requires-Dist: langgraph>=1.0; extra == 'all'
47
- Requires-Dist: laya<0.4,>=0.3.20; extra == 'all'
47
+ Requires-Dist: laya<0.5,>=0.4.17; extra == 'all'
48
48
  Requires-Dist: mcp>=1.10; extra == 'all'
49
49
  Requires-Dist: openai-agents>=0.22; extra == 'all'
50
50
  Requires-Dist: openai>=2.0; extra == 'all'
@@ -82,12 +82,12 @@ Requires-Dist: transformers<5,>=4.48; extra == 'gliner'
82
82
  Provides-Extra: langgraph
83
83
  Requires-Dist: langgraph>=1.0; extra == 'langgraph'
84
84
  Provides-Extra: laya
85
- Requires-Dist: laya<0.4,>=0.3.20; extra == 'laya'
85
+ Requires-Dist: laya<0.5,>=0.4.17; extra == 'laya'
86
86
  Requires-Dist: transformers<5,>=4.48; extra == 'laya'
87
87
  Provides-Extra: local
88
88
  Requires-Dist: accelerate>=1.0; extra == 'local'
89
89
  Requires-Dist: gliner2[local]<3,>=2.0; extra == 'local'
90
- Requires-Dist: laya<0.4,>=0.3.20; extra == 'local'
90
+ Requires-Dist: laya<0.5,>=0.4.17; extra == 'local'
91
91
  Requires-Dist: protobuf>=4.25; extra == 'local'
92
92
  Requires-Dist: sentencepiece>=0.2; extra == 'local'
93
93
  Requires-Dist: torch>=2.1; extra == 'local'
@@ -111,6 +111,10 @@ Requires-Dist: fastapi>=0.115; extra == 'server'
111
111
  Requires-Dist: uvicorn>=0.30; extra == 'server'
112
112
  Description-Content-Type: text/markdown
113
113
 
114
+ <p align="center">
115
+ <img src="https://raw.githubusercontent.com/inboxpraveen/ThinkLess/main/docs/assets/logo.svg" alt="ThinkLess logo" width="96" height="96">
116
+ </p>
117
+
114
118
  <h1 align="center">ThinkLess</h1>
115
119
 
116
120
  <p align="center"><b>Stop using an LLM for every decision.</b></p>
@@ -141,6 +145,33 @@ you already use, with one line, and the decisions your agent keeps making
141
145
  become local habits once they are proven. With **typed decisions**, you
142
146
  declare the questions and choose the models that answer them.
143
147
 
148
+ See it work first. This runs in about a second, offline, with no API key,
149
+ GPU or model download:
150
+
151
+ ```bash
152
+ pip install thinkless
153
+ thinkless habits demo
154
+ ```
155
+
156
+ The output, shortened (timings depend on the machine):
157
+
158
+ ```text
159
+ 1. Recording. 300 messages went to the LLM and were recorded.
160
+ 2. Probation. 450 more messages, 450 sent to the LLM: the student answered each in shadow only.
161
+ 3. Live. 300 messages: 281 answered locally (median 0.4 ms for the whole HTTP call);
162
+ the other 19 went to the LLM as random audits, so agreement keeps being measured.
163
+ Local answers that match what the LLM would have said: 281 of 281.
164
+ ```
165
+
166
+ The demo's LLM is a stand-in that always answers the same way, so agreement
167
+ is perfect. On real traffic it is lower, and the
168
+ [measured results](https://inboxpraveen.github.io/ThinkLess/habits/#results)
169
+ say by how much.
170
+
171
+ <p align="center">
172
+ <img src="https://raw.githubusercontent.com/inboxpraveen/ThinkLess/main/docs/assets/architecture.svg" alt="How ThinkLess works. Habits: habits.wrap(client) answers a call locally in about 4 ms when its call site is a proven habit, and otherwise sends it to your LLM unchanged and records it; in the background ThinkLess finds decision sites, trains a student per site on the LLM's answers, and makes it a habit only after 97% agreement on past calls and again on new calls, with 5% audits after. Typed decisions: a question goes through rules, GLiNER 2.5, Laya, System One models and an LLM decider, cheapest first, and comes back as a typed decision. Everything is traced to JSONL, OpenTelemetry and an HTML viewer." width="100%">
173
+ </p>
174
+
144
175
  ## Habits: one line under the agent you already have
145
176
 
146
177
  ```python
@@ -269,10 +300,15 @@ billed ([full results](https://inboxpraveen.github.io/ThinkLess/benchmarks/)):
269
300
  ## Quick start
270
301
 
271
302
  ```bash
272
- pip install "thinkless[local]" # GLiNER, Laya and a local LLM
303
+ pip install thinkless # rules, Habits, tracing; no model downloads
304
+ pip install "thinkless[local]" # adds GLiNER, Laya and a local LLM (PyTorch)
273
305
  thinkless doctor # check the environment
274
306
  ```
275
307
 
308
+ The example below uses the local models. Without them, start from
309
+ [`examples/01_rules_only.py`](https://github.com/inboxpraveen/ThinkLess/blob/main/examples/01_rules_only.py),
310
+ which shows the same API, cascade and traces with rules alone.
311
+
276
312
  ```python
277
313
  from thinkless import Choice, Engine, Extract, JSONLSink, Tracer, YesNo
278
314
  from thinkless.llm import TransformersLLM
@@ -322,9 +358,8 @@ Then open the trace:
322
358
  thinkless trace view
323
359
  ```
324
360
 
325
- No GPU? `pip install thinkless` and run
326
- [`examples/01_rules_only.py`](https://github.com/inboxpraveen/ThinkLess/blob/main/examples/01_rules_only.py): the API, the cascade
327
- and the traces with no model downloads.
361
+ No GPU? The local models also run on a CPU, more slowly (see the provider
362
+ table below), and a hosted LLM through OpenRouter works as the fallback.
328
363
 
329
364
  ## Use it in your agent
330
365
 
@@ -348,7 +383,8 @@ builder.add_conditional_edges(START, intent, intent.destinations)
348
383
  - [OpenAI Agents SDK](https://inboxpraveen.github.io/ThinkLess/integrations/openai-agents/):
349
384
  input guardrails, tool guardrails and routing to a specialist agent.
350
385
  - [Any framework](https://inboxpraveen.github.io/ThinkLess/integrations/any-framework/):
351
- `route` and `gate` for Pydantic AI, a hand-written loop, or anything else.
386
+ `route` and `gate` for CrewAI, LlamaIndex, Pydantic AI, a hand-written
387
+ loop, or anything else.
352
388
 
353
389
  Before switching anything, measure it. Shadow mode runs ThinkLess next to your
354
390
  current code on live traffic and reports, per decision, the agreement with a
@@ -444,7 +480,8 @@ Writing your own provider is one class. [Providers](https://inboxpraveen.github.
444
480
  ## Documentation
445
481
 
446
482
  - [Getting started](https://inboxpraveen.github.io/ThinkLess/getting-started/),
447
- [installation](https://inboxpraveen.github.io/ThinkLess/guides/installation/)
483
+ [installation](https://inboxpraveen.github.io/ThinkLess/guides/installation/),
484
+ [Habits](https://inboxpraveen.github.io/ThinkLess/habits/)
448
485
  - Use it in your agent: [overview](https://inboxpraveen.github.io/ThinkLess/integrations/),
449
486
  [LangGraph](https://inboxpraveen.github.io/ThinkLess/integrations/langgraph/),
450
487
  [OpenAI Agents SDK](https://inboxpraveen.github.io/ThinkLess/integrations/openai-agents/),
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/inboxpraveen/ThinkLess/main/docs/assets/logo.svg" alt="ThinkLess logo" width="96" height="96">
3
+ </p>
4
+
1
5
  <h1 align="center">ThinkLess</h1>
2
6
 
3
7
  <p align="center"><b>Stop using an LLM for every decision.</b></p>
@@ -28,6 +32,33 @@ you already use, with one line, and the decisions your agent keeps making
28
32
  become local habits once they are proven. With **typed decisions**, you
29
33
  declare the questions and choose the models that answer them.
30
34
 
35
+ See it work first. This runs in about a second, offline, with no API key,
36
+ GPU or model download:
37
+
38
+ ```bash
39
+ pip install thinkless
40
+ thinkless habits demo
41
+ ```
42
+
43
+ The output, shortened (timings depend on the machine):
44
+
45
+ ```text
46
+ 1. Recording. 300 messages went to the LLM and were recorded.
47
+ 2. Probation. 450 more messages, 450 sent to the LLM: the student answered each in shadow only.
48
+ 3. Live. 300 messages: 281 answered locally (median 0.4 ms for the whole HTTP call);
49
+ the other 19 went to the LLM as random audits, so agreement keeps being measured.
50
+ Local answers that match what the LLM would have said: 281 of 281.
51
+ ```
52
+
53
+ The demo's LLM is a stand-in that always answers the same way, so agreement
54
+ is perfect. On real traffic it is lower, and the
55
+ [measured results](https://inboxpraveen.github.io/ThinkLess/habits/#results)
56
+ say by how much.
57
+
58
+ <p align="center">
59
+ <img src="https://raw.githubusercontent.com/inboxpraveen/ThinkLess/main/docs/assets/architecture.svg" alt="How ThinkLess works. Habits: habits.wrap(client) answers a call locally in about 4 ms when its call site is a proven habit, and otherwise sends it to your LLM unchanged and records it; in the background ThinkLess finds decision sites, trains a student per site on the LLM's answers, and makes it a habit only after 97% agreement on past calls and again on new calls, with 5% audits after. Typed decisions: a question goes through rules, GLiNER 2.5, Laya, System One models and an LLM decider, cheapest first, and comes back as a typed decision. Everything is traced to JSONL, OpenTelemetry and an HTML viewer." width="100%">
60
+ </p>
61
+
31
62
  ## Habits: one line under the agent you already have
32
63
 
33
64
  ```python
@@ -156,10 +187,15 @@ billed ([full results](https://inboxpraveen.github.io/ThinkLess/benchmarks/)):
156
187
  ## Quick start
157
188
 
158
189
  ```bash
159
- pip install "thinkless[local]" # GLiNER, Laya and a local LLM
190
+ pip install thinkless # rules, Habits, tracing; no model downloads
191
+ pip install "thinkless[local]" # adds GLiNER, Laya and a local LLM (PyTorch)
160
192
  thinkless doctor # check the environment
161
193
  ```
162
194
 
195
+ The example below uses the local models. Without them, start from
196
+ [`examples/01_rules_only.py`](https://github.com/inboxpraveen/ThinkLess/blob/main/examples/01_rules_only.py),
197
+ which shows the same API, cascade and traces with rules alone.
198
+
163
199
  ```python
164
200
  from thinkless import Choice, Engine, Extract, JSONLSink, Tracer, YesNo
165
201
  from thinkless.llm import TransformersLLM
@@ -209,9 +245,8 @@ Then open the trace:
209
245
  thinkless trace view
210
246
  ```
211
247
 
212
- No GPU? `pip install thinkless` and run
213
- [`examples/01_rules_only.py`](https://github.com/inboxpraveen/ThinkLess/blob/main/examples/01_rules_only.py): the API, the cascade
214
- and the traces with no model downloads.
248
+ No GPU? The local models also run on a CPU, more slowly (see the provider
249
+ table below), and a hosted LLM through OpenRouter works as the fallback.
215
250
 
216
251
  ## Use it in your agent
217
252
 
@@ -235,7 +270,8 @@ builder.add_conditional_edges(START, intent, intent.destinations)
235
270
  - [OpenAI Agents SDK](https://inboxpraveen.github.io/ThinkLess/integrations/openai-agents/):
236
271
  input guardrails, tool guardrails and routing to a specialist agent.
237
272
  - [Any framework](https://inboxpraveen.github.io/ThinkLess/integrations/any-framework/):
238
- `route` and `gate` for Pydantic AI, a hand-written loop, or anything else.
273
+ `route` and `gate` for CrewAI, LlamaIndex, Pydantic AI, a hand-written
274
+ loop, or anything else.
239
275
 
240
276
  Before switching anything, measure it. Shadow mode runs ThinkLess next to your
241
277
  current code on live traffic and reports, per decision, the agreement with a
@@ -331,7 +367,8 @@ Writing your own provider is one class. [Providers](https://inboxpraveen.github.
331
367
  ## Documentation
332
368
 
333
369
  - [Getting started](https://inboxpraveen.github.io/ThinkLess/getting-started/),
334
- [installation](https://inboxpraveen.github.io/ThinkLess/guides/installation/)
370
+ [installation](https://inboxpraveen.github.io/ThinkLess/guides/installation/),
371
+ [Habits](https://inboxpraveen.github.io/ThinkLess/habits/)
335
372
  - Use it in your agent: [overview](https://inboxpraveen.github.io/ThinkLess/integrations/),
336
373
  [LangGraph](https://inboxpraveen.github.io/ThinkLess/integrations/langgraph/),
337
374
  [OpenAI Agents SDK](https://inboxpraveen.github.io/ThinkLess/integrations/openai-agents/),
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "thinkless"
7
7
  dynamic = ["version"]
8
- description = "The decision plane for AI agents. Rules and small calibrated models make the routine decisions, the LLM is reserved for the steps that need thought, and every step is traced."
8
+ description = "Stop using an LLM for every decision. Rules and small local models answer an AI agent's routine decisions, including ones learned from its own LLM once proven; the LLM keeps the steps that need it, and every step is traced."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
11
  license = "Apache-2.0"
@@ -16,6 +16,12 @@ keywords = [
16
16
  "ai-agents",
17
17
  "llm",
18
18
  "llm-routing",
19
+ "llm-cost",
20
+ "cost-optimization",
21
+ "knowledge-distillation",
22
+ "openai",
23
+ "anthropic",
24
+ "langchain",
19
25
  "decision-models",
20
26
  "guardrails",
21
27
  "langgraph",
@@ -53,7 +59,8 @@ dependencies = [
53
59
  "httpx>=0.27,<1",
54
60
  "numpy>=1.24",
55
61
  "rich>=13.7",
56
- "typer>=0.12",
62
+ # 0.13 is the first typer that reads `str | None` options on Python 3.10.
63
+ "typer>=0.13",
57
64
  "tomli>=2.0; python_version < '3.11'",
58
65
  ]
59
66
 
@@ -66,7 +73,9 @@ gliner = [
66
73
  "protobuf>=4.25",
67
74
  "sentencepiece>=0.2",
68
75
  ]
69
- laya = ["laya>=0.3.20,<0.4", "transformers>=4.48,<5"]
76
+ # Laya releases after 0.4.22 need transformers 5 (through vegaml), so with the
77
+ # shared bound pip resolves to 0.4.22 until GLiNER2 supports transformers 5.
78
+ laya = ["laya>=0.4.17,<0.5", "transformers>=4.48,<5"]
70
79
  local-llm = ["transformers>=4.48,<5", "accelerate>=1.0", "torch>=2.1"]
71
80
  local = ["thinkless[gliner,laya,local-llm]"]
72
81
  # Hosted reasoning backends.
@@ -0,0 +1 @@
1
+ __version__ = "0.6.0"
@@ -135,6 +135,19 @@ def _print_report(report, *, with_plan: bool) -> None: # type: ignore[no-untype
135
135
  console.print(table)
136
136
 
137
137
 
138
+ @habits_app.command("demo")
139
+ def demo(
140
+ directory: Annotated[
141
+ Path | None,
142
+ typer.Option("--dir", help="Keep the demo's calls and plan here to inspect them."),
143
+ ] = None,
144
+ ) -> None:
145
+ """Watch ThinkLess learn a decision and take it over, offline, in a few seconds."""
146
+ from ..habits.demo import run_demo
147
+
148
+ run_demo(console, directory=directory)
149
+
150
+
138
151
  @habits_app.command("scan")
139
152
  def scan(
140
153
  paths: Annotated[
@@ -190,9 +190,12 @@ class Engine:
190
190
  ``spend_limit``.
191
191
  attributes: Recorded on the root span.
192
192
  """
193
+ # A nested run keeps the limits of the runs around it, and adds its own.
194
+ outer = _run_limit.get()
195
+ limits = (*outer, SpendLimit(max_cost_usd)) if max_cost_usd is not None else outer
193
196
  collector = _RunCollector()
194
197
  self.tracer.add_sink(collector)
195
- token = _run_limit.set(SpendLimit(max_cost_usd) if max_cost_usd is not None else None)
198
+ token = _run_limit.set(limits)
196
199
  try:
197
200
  with self.tracer.span("run", name, **attributes) as span:
198
201
  collector.trace_id = span.trace_id
@@ -420,7 +423,12 @@ class Engine:
420
423
  @staticmethod
421
424
  def _as_mapping(questions: Mapping[str, Question] | Sequence[Question]) -> dict[str, Question]:
422
425
  if isinstance(questions, Mapping):
423
- batch = dict(questions)
426
+ # An unnamed question takes the name it was given here, so rules,
427
+ # classifiers, thresholds and traces all know it by that name.
428
+ batch = {
429
+ key: q if q.name is not None or q.key == key else q.model_copy(update={"name": key})
430
+ for key, q in questions.items()
431
+ }
424
432
  else:
425
433
  batch = {}
426
434
  for question in questions:
@@ -445,8 +453,8 @@ class Engine:
445
453
  return cost, "price_table" if known else "unknown"
446
454
 
447
455
  def _limits(self) -> list[SpendLimit]:
448
- run_limit = _run_limit.get()
449
- return [lim for lim in (self.spend_limit, run_limit) if lim is not None]
456
+ engine_limit = [self.spend_limit] if self.spend_limit is not None else []
457
+ return [*engine_limit, *_run_limit.get()]
450
458
 
451
459
  def _exhausted_limit(self) -> SpendLimit | None:
452
460
  return next((lim for lim in self._limits() if lim.exhausted), None)
@@ -163,6 +163,8 @@ class ResponsesApi:
163
163
  extra = ""
164
164
  if body.get("previous_response_id"):
165
165
  extra = "the conversation continues a stored response ThinkLess cannot see"
166
+ elif body.get("conversation"):
167
+ extra = "the call belongs to a stored conversation ThinkLess cannot see"
166
168
  reason = _reason(has_media, contract, extra) or ("no input" if not messages else "")
167
169
  return Call(
168
170
  model=str(body.get("model") or ""),
@@ -458,9 +460,12 @@ class MessagesApi:
458
460
  message: dict[str, Any] | None = None
459
461
  blocks: dict[int, dict[str, Any]] = {}
460
462
  partial: dict[int, list[str]] = {}
463
+ stopped = False
461
464
  for event in _events(chunks):
462
465
  kind = event.get("type")
463
- if kind == "message_start" and isinstance(event.get("message"), dict):
466
+ if kind == "message_stop":
467
+ stopped = True
468
+ elif kind == "message_start" and isinstance(event.get("message"), dict):
464
469
  message = dict(event["message"])
465
470
  message["content"] = []
466
471
  elif kind == "content_block_start":
@@ -482,7 +487,8 @@ class MessagesApi:
482
487
  usage = event.get("usage")
483
488
  if isinstance(usage, Mapping):
484
489
  message.setdefault("usage", {}).update(usage)
485
- if message is None:
490
+ # A stream the caller stopped reading, or that broke off, is not an answer.
491
+ if message is None or not stopped:
486
492
  return None
487
493
  for index in sorted(blocks):
488
494
  block = blocks[index]
@@ -81,16 +81,20 @@ class CallLog:
81
81
  self._lock = threading.Lock()
82
82
  self._handle: Any = None
83
83
  self._day: str | None = None
84
+ self._pid: int | None = None
84
85
 
85
86
  def _file(self) -> Any:
86
87
  day = datetime.now(timezone.utc).strftime("%Y-%m-%d")
87
- if self._handle is None or day != self._day:
88
+ pid = os.getpid()
89
+ # A forked worker gets a file of its own, not the parent's.
90
+ if self._handle is None or day != self._day or pid != self._pid:
88
91
  if self._handle is not None:
89
92
  self._handle.close()
90
93
  self.directory.mkdir(parents=True, exist_ok=True)
91
- path = self.directory / f"{day}-{os.getpid()}.jsonl"
94
+ path = self.directory / f"{day}-{pid}.jsonl"
92
95
  self._handle = path.open("a", encoding="utf-8")
93
96
  self._day = day
97
+ self._pid = pid
94
98
  return self._handle
95
99
 
96
100
  def write(