Skip to content

Commit 068f6f3

Browse files
committed
v0.8.6: default to GPT-6 Luna with tool compatibility
1 parent 3b69b8b commit 068f6f3

11 files changed

Lines changed: 211 additions & 35 deletions

‎.catgitinclude‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ src/reminder_poller.py
1212
src/reminder_handler.py
1313
VERSION
1414
src/app_version.py
15+
src/openai_reasoning_compat.py

‎README.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ If you run into any issues, consult the logs or reach out on the repository's [I
287287

288288
> The current application version is stored in the repository-root `VERSION` file and loaded by the runtime from there. Update `VERSION` once for a release instead of duplicating the current version in source files.
289289
290+
- v0.8.6 - GPT-6 Luna default and model-specific tool/reasoning compatibility
291+
- Changed the default ChatKeke model and auto-switch premium model to `gpt-6-luna`.
292+
- Kept ChatKeke on the existing Chat Completions transport and preserved all existing custom tool definitions and dispatch logic unchanged.
293+
- Kept `ReasoningEffort = none` as the shipped default so GPT-6 Luna custom function tools work through `/v1/chat/completions`.
294+
- Added the documented GPT-6 Chat Completions exception: GPT-6 Luna and GPT-6 Sol are forced to `reasoning_effort = none` whenever function tools are attached, preventing invalid tool requests even if a local config selects a higher effort.
295+
- Removed the old GPT-5.6-Luna-specific forced-none rule. GPT-5.6 now honors the configured reasoning effort when tools are attached; it is only `none` when the configuration explicitly requests `none`.
296+
- Left the Elasticsearch RAG/action-token insertion path unchanged: retrieved Elasticsearch context still feeds `chat_history_with_es_context`, which is passed to the same tool-enabled Chat Completions payload builder.
297+
- Bumped the repository-root `VERSION` to `0.8.6`.
298+
290299
- v0.8.5 - OpenAI project-key migration and explicit credential handling
291300
- Removed the mutable process-global `openai.api_key` and passed one resolved credential object explicitly into raw HTTP requests and the OpenAI SDK client.
292301
- Added optional `OPENAI_ORG_ID` and `OPENAI_PROJECT_ID` routing overrides without requiring them for normal project keys.
@@ -314,7 +323,7 @@ If you run into any issues, consult the logs or reach out on the repository's [I
314323
- Added a conservative model/value compatibility layer so unsupported older models never receive `reasoning_effort`.
315324
- Explicitly supports the documented effort ranges for GPT-5.1, GPT-5.2, GPT-5.4, GPT-5.5 and GPT-5.6; original GPT-5 keeps its older `minimal` vocabulary.
316325
- GPT-5.6 supports `none`, `low`, `medium`, `high`, `xhigh`, and `max` where the selected endpoint/tool combination permits them.
317-
- GPT-5.6 Luna has a special Chat Completions compatibility rule: when function tools are attached, Keke explicitly uses `reasoning_effort = none`. The `/v1/chat/completions` endpoint rejects Luna function-tool requests with its default/higher reasoning effort; higher reasoning plus tools requires the Responses API.
326+
- The original v0.8.3 compatibility layer included a GPT-5.6-Luna forced-`none` tool rule; v0.8.6 narrows that exception to the GPT-6 Luna/Sol models for which current Chat Completions documentation requires it.
318327
- Invalid model/effort combinations are logged and omitted instead of producing a malformed API request.
319328
- Model auto-switching remains safe when premium/fallback models have different reasoning capabilities.
320329
- Applied the same guarded setting to the optional DuckDuckGo sub-agent and Perplexity OpenAI language detector.

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.5
1+
0.8.6

‎config/config.ini‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ AskForTokenIfNotFound = True
1616
# Model to use via OpenAI API
1717
# NOTE: SEE ALSO THE NEW AUTO-SWITCHING FEATURE UNDER: [ModelAutoSwitch]
1818
# Model = gpt-5.4-mini
19-
Model = gpt-5.6-luna
19+
Model = gpt-6-luna
2020

2121
# Model temperature; OpenAI's default is 0.7
2222
# Higher temperature equals more creative (= less factual) output. much over 1.0 not recommended.
@@ -28,14 +28,15 @@ Temperature = 0.9
2828
# ModelAutoSwitch changes to an older/non-reasoning model.
2929
#
3030
# Current supported values used by the compatibility layer:
31+
# GPT-6 Luna / GPT-6 Sol: none, low, medium, high, xhigh, max
3132
# GPT-5.6: none, low, medium, high, xhigh, max
3233
# GPT-5.5 / GPT-5.4 / GPT-5.2: none, low, medium, high, xhigh
3334
# GPT-5.1: none, low, medium, high
3435
# GPT-5 (original): minimal, low, medium, high
3536
# Unsupported model/value combinations are omitted instead of being sent.
36-
# NOTE: GPT-5.6 Luna with function tools on /v1/chat/completions
37-
# requires ReasoningEffort = none.
38-
# Higher reasoning levels with function tools require the Responses API.
37+
# NOTE: GPT-6 Luna / GPT-6 Sol with function tools on /v1/chat/completions
38+
# require ReasoningEffort = none. This compatibility exception does NOT apply
39+
# to GPT-5.6 models. GPT-6 Astra / GPT-6.1 Sol tool calling requires Responses.
3940
ReasoningEffort = none
4041

4142
# Timeout on OpenAI API requests
@@ -151,7 +152,7 @@ Enabled = False
151152
# The preferred, more capable model to use by default (e.g., gpt-4o, gpt-4.5-preview).
152153
# This model will be used until its daily token limit (PremiumTokenLimit) is reached.
153154
# PremiumModel = gpt-4o
154-
PremiumModel = gpt-5.6-luna
155+
PremiumModel = gpt-6-luna
155156

156157
# The cheaper model to switch to when the PremiumTokenLimit is reached (e.g., gpt-4o-mini).
157158
# This model has its own daily token limit (MiniTokenLimit).

‎src/api_get_duckduckgo_search.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
config = configparser.ConfigParser()
5858
config.read(CONFIG_PATH)
5959

60-
DEFAULT_MODEL = "gpt-5.4-mini"
60+
DEFAULT_MODEL = "gpt-6-luna"
6161
DEFAULT_TEMPERATURE = 0.7
6262
DEFAULT_TIMEOUT = 60
6363
DEFAULT_MAX_TOKENS = 2048

‎src/main.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def load_config(self):
208208
self.config = self._parser['DEFAULT']
209209

210210
# Basic defaults
211-
self.model = self.config.get('Model', 'gpt-4o-mini')
211+
self.model = self.config.get('Model', 'gpt-6-luna')
212212
self.temperature = self.config.getfloat('Temperature', 0.7)
213213
# Optional OpenAI reasoning level. 'default'/'auto' omits the field so
214214
# each selected model uses its own API default and older models remain compatible.

‎src/openai_reasoning_compat.py‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# Explicitly documented Chat Completions-compatible model families.
1919
# Keep this conservative. Unknown/future models simply use their API default.
2020
_REASONING_EFFORTS_BY_PREFIX = (
21+
("gpt-6-luna", ("none", "low", "medium", "high", "xhigh", "max")),
22+
("gpt-6-sol", ("none", "low", "medium", "high", "xhigh", "max")),
2123
("gpt-5.6", ("none", "low", "medium", "high", "xhigh", "max")),
2224
("gpt-5.5", ("none", "low", "medium", "high", "xhigh")),
2325
("gpt-5.4", ("none", "low", "medium", "high", "xhigh")),
@@ -31,6 +33,11 @@
3133

3234
_DEFAULT_SENTINELS = {"", "auto", "default", "model-default", "model_default"}
3335

36+
# OpenAI documents this restriction specifically for GPT-6 Luna and GPT-6 Sol
37+
# when custom function tools are sent through /v1/chat/completions. GPT-5.6
38+
# supports function calling without this forced-none compatibility exception.
39+
_CHAT_COMPLETIONS_TOOLS_REQUIRE_NONE_PREFIXES = ("gpt-6-luna", "gpt-6-sol")
40+
3441

3542
def supported_reasoning_efforts(model: str) -> Optional[tuple[str, ...]]:
3643
"""Return supported Chat Completions reasoning-effort values for *model*.
@@ -68,9 +75,9 @@ def resolve_reasoning_effort(
6875
"""Resolve a configured effort to a value safe to send to Chat Completions.
6976
7077
``default``/``auto``/blank normally means omit the parameter and let the
71-
selected model use its own default. GPT-5.6 Luna is the exception when
72-
function tools are attached to Chat Completions: its default/higher effort
73-
is rejected by that endpoint, so this helper explicitly returns ``none``.
78+
selected model use its own default. GPT-6 Luna and GPT-6 Sol are the
79+
exceptions when function tools are attached to Chat Completions: that
80+
endpoint supports their function calling only with ``reasoning_effort=none``.
7481
7582
Explicit values are otherwise sent only when the selected model is in the
7683
compatibility table *and* that exact value is supported. Unsupported values
@@ -79,24 +86,26 @@ def resolve_reasoning_effort(
7986
effort = (configured_effort or "default").strip().lower()
8087
name = (model or "").strip().lower()
8188

82-
# Live API behaviour observed for GPT-5.6 Luna on /v1/chat/completions:
83-
# function tools cannot be combined with Luna's default/higher reasoning
84-
# efforts. The endpoint explicitly requires reasoning_effort="none" (or
85-
# migration to /v1/responses). Force the safe Chat Completions value when
86-
# function tools are present so a config value cannot turn every tool-enabled
87-
# request into HTTP 400.
88-
if has_function_tools and name.startswith("gpt-5.6-luna"):
89+
# GPT-6 Luna / GPT-6 Sol function tools on /v1/chat/completions require
90+
# reasoning_effort="none". Keep this narrowly model-specific: GPT-5.6 must
91+
# continue to honor its configured/default reasoning effort rather than being
92+
# forced to none merely because tools are attached.
93+
if has_function_tools and any(
94+
name.startswith(prefix) for prefix in _CHAT_COMPLETIONS_TOOLS_REQUIRE_NONE_PREFIXES
95+
):
8996
if effort not in _DEFAULT_SENTINELS and effort != "none" and logger is not None:
9097
logger.warning(
91-
"GPT-5.6 Luna with function tools on Chat Completions requires "
98+
"%s with function tools on Chat Completions requires "
9299
"ReasoningEffort=none; forcing none instead of configured value %s. "
93100
"Use the Responses API for higher reasoning effort with tools.",
101+
model,
94102
effort,
95103
)
96104
elif effort in _DEFAULT_SENTINELS and logger is not None:
97105
logger.info(
98-
"GPT-5.6 Luna with function tools on Chat Completions cannot use "
99-
"its default reasoning effort; explicitly setting reasoning_effort=none."
106+
"%s with function tools on Chat Completions cannot use its "
107+
"default reasoning effort; explicitly setting reasoning_effort=none.",
108+
model,
100109
)
101110
return "none"
102111

‎src/text_message_handler.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ def build_chat_payload(bot, messages, *, include_functions=True, max_tokens=None
210210
payload["parallel_tool_calls"] = False
211211

212212
# Chat Completions uses the flat `reasoning_effort` field. Apply it only
213-
# after tool attachment so Luna can enforce its Chat Completions rule:
214-
# function tools require reasoning_effort="none". Older/unknown models
215-
# still receive no reasoning field at all.
213+
# after tool attachment so model-specific compatibility rules can see whether
214+
# tools are present. GPT-6 Luna/Sol require none with function tools here;
215+
# GPT-5.6 is not forced to none by tool presence.
216216
apply_reasoning_effort(
217217
payload,
218218
bot.model,

‎tests/test_chat_payload_compat.py‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from __future__ import annotations
2+
3+
import ast
4+
import logging
5+
import sys
6+
from pathlib import Path
7+
8+
ROOT_DIR = Path(__file__).resolve().parents[1]
9+
SRC_DIR = ROOT_DIR / "src"
10+
if str(SRC_DIR) not in sys.path:
11+
sys.path.insert(0, str(SRC_DIR))
12+
13+
from openai_reasoning_compat import apply_reasoning_effort # noqa: E402
14+
15+
16+
def _load_payload_builder(function_specs):
17+
"""Load only the pure payload-builder functions without bot runtime imports."""
18+
source_path = SRC_DIR / "text_message_handler.py"
19+
tree = ast.parse(source_path.read_text(encoding="utf-8"), filename=str(source_path))
20+
wanted = {"model_supports_temperature", "build_openai_tools", "build_chat_payload"}
21+
body = [node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name in wanted]
22+
module = ast.Module(body=body, type_ignores=[])
23+
ast.fix_missing_locations(module)
24+
25+
namespace = {
26+
"apply_reasoning_effort": apply_reasoning_effort,
27+
"custom_functions": function_specs,
28+
}
29+
exec(compile(module, str(source_path), "exec"), namespace)
30+
return namespace["build_chat_payload"]
31+
32+
33+
class _Bot:
34+
def __init__(self, model: str, reasoning_effort: str):
35+
self.model = model
36+
self.reasoning_effort = reasoning_effort
37+
self.temperature = 0.9
38+
self.logger = logging.getLogger("payload-test")
39+
40+
41+
def test_gpt6_luna_keeps_existing_custom_function_tools_and_forces_none() -> None:
42+
functions = [
43+
{
44+
"name": "existing_chatkeke_tool",
45+
"description": "existing tool",
46+
"parameters": {
47+
"type": "object",
48+
"properties": {"query": {"type": "string"}},
49+
"required": ["query"],
50+
},
51+
}
52+
]
53+
build_chat_payload = _load_payload_builder(functions)
54+
messages = [{"role": "user", "content": "hello"}]
55+
56+
payload = build_chat_payload(_Bot("gpt-6-luna", "medium"), messages)
57+
58+
assert payload["model"] == "gpt-6-luna"
59+
assert payload["messages"] == messages
60+
assert payload["tools"] == [{"type": "function", "function": functions[0]}]
61+
assert payload["tool_choice"] == "auto"
62+
assert payload["parallel_tool_calls"] is False
63+
assert payload["reasoning_effort"] == "none"
64+
assert "temperature" not in payload
65+
66+
67+
def test_gpt56_tool_payload_honors_configured_reasoning() -> None:
68+
functions = [
69+
{
70+
"name": "existing_chatkeke_tool",
71+
"description": "existing tool",
72+
"parameters": {"type": "object", "properties": {}},
73+
}
74+
]
75+
build_chat_payload = _load_payload_builder(functions)
76+
77+
payload = build_chat_payload(
78+
_Bot("gpt-5.6-luna", "medium"),
79+
[{"role": "user", "content": "hello"}],
80+
)
81+
82+
assert payload["tools"][0]["function"]["name"] == "existing_chatkeke_tool"
83+
assert payload["reasoning_effort"] == "medium"

‎tests/test_openai_reasoning_compat.py‎

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
def test_default_omits_parameter_for_every_model():
15-
for model in ("gpt-5.6-luna", "gpt-5.4-mini", "gpt-4o-mini", "gpt-3.5-turbo"):
15+
for model in ("gpt-6-luna", "gpt-5.6-luna", "gpt-5.4-mini", "gpt-4o-mini", "gpt-3.5-turbo"):
1616
payload = {"model": model}
1717
apply_reasoning_effort(payload, model, "default")
1818
assert "reasoning_effort" not in payload
@@ -26,23 +26,23 @@ def test_gpt56_accepts_max():
2626

2727

2828

29-
def test_luna_with_function_tools_forces_none_from_default():
30-
payload = {"model": "gpt-5.6-luna", "tools": [{"type": "function"}]}
29+
def test_gpt6_luna_with_function_tools_forces_none_from_default():
30+
payload = {"model": "gpt-6-luna", "tools": [{"type": "function"}]}
3131
apply_reasoning_effort(
3232
payload,
33-
"gpt-5.6-luna",
33+
"gpt-6-luna",
3434
"default",
3535
has_function_tools=True,
3636
)
3737
assert payload["reasoning_effort"] == "none"
3838

3939

40-
def test_luna_with_function_tools_forces_none_from_higher_effort(caplog):
41-
payload = {"model": "gpt-5.6-luna", "tools": [{"type": "function"}]}
40+
def test_gpt6_luna_with_function_tools_forces_none_from_higher_effort(caplog):
41+
payload = {"model": "gpt-6-luna", "tools": [{"type": "function"}]}
4242
with caplog.at_level(logging.WARNING):
4343
apply_reasoning_effort(
4444
payload,
45-
"gpt-5.6-luna",
45+
"gpt-6-luna",
4646
"medium",
4747
has_function_tools=True,
4848
logger=logging.getLogger("test"),
@@ -51,17 +51,60 @@ def test_luna_with_function_tools_forces_none_from_higher_effort(caplog):
5151
assert "requires ReasoningEffort=none" in caplog.text
5252

5353

54-
def test_luna_without_function_tools_can_use_higher_effort():
55-
payload = {"model": "gpt-5.6-luna"}
54+
def test_gpt6_sol_with_function_tools_forces_none():
55+
payload = {"model": "gpt-6-sol", "tools": [{"type": "function"}]}
5656
apply_reasoning_effort(
5757
payload,
58-
"gpt-5.6-luna",
58+
"gpt-6-sol",
59+
"high",
60+
has_function_tools=True,
61+
)
62+
assert payload["reasoning_effort"] == "none"
63+
64+
65+
def test_gpt6_luna_without_function_tools_can_use_higher_effort():
66+
payload = {"model": "gpt-6-luna"}
67+
apply_reasoning_effort(
68+
payload,
69+
"gpt-6-luna",
5970
"medium",
6071
has_function_tools=False,
6172
)
6273
assert payload["reasoning_effort"] == "medium"
6374

6475

76+
def test_gpt56_with_function_tools_is_not_forced_to_none():
77+
payload = {"model": "gpt-5.6-luna", "tools": [{"type": "function"}]}
78+
apply_reasoning_effort(
79+
payload,
80+
"gpt-5.6-luna",
81+
"medium",
82+
has_function_tools=True,
83+
)
84+
assert payload["reasoning_effort"] == "medium"
85+
86+
87+
def test_gpt56_with_function_tools_default_remains_model_default():
88+
payload = {"model": "gpt-5.6-luna", "tools": [{"type": "function"}]}
89+
apply_reasoning_effort(
90+
payload,
91+
"gpt-5.6-luna",
92+
"default",
93+
has_function_tools=True,
94+
)
95+
assert "reasoning_effort" not in payload
96+
97+
98+
def test_gpt56_with_function_tools_honors_explicit_none():
99+
payload = {"model": "gpt-5.6-luna", "tools": [{"type": "function"}]}
100+
apply_reasoning_effort(
101+
payload,
102+
"gpt-5.6-luna",
103+
"none",
104+
has_function_tools=True,
105+
)
106+
assert payload["reasoning_effort"] == "none"
107+
65108
def test_gpt54_rejects_max_without_malformed_payload(caplog):
66109
payload = {"model": "gpt-5.4-mini"}
67110
with caplog.at_level(logging.WARNING):

0 commit comments

Comments
 (0)