mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 11:43:17 +08:00
fix(chat): harden session auto-title and keep a single no-tool LLM call
- Add session_auto_title prompts, finalize_auto_title (reject prose, truncate, fallback). - Third-round naming: one model.chat(system, user) with empty tools; reuse executor.model. - Extend worker title tests for garbage model output. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
16169b3de2
commit
9f4fa3d319
5 changed files with 153 additions and 28 deletions
27
tests/test_session_auto_title.py
Normal file
27
tests/test_session_auto_title.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.runtime.session_auto_title import AUTO_TITLE_CHAR_MAX, finalize_auto_title, should_reject_auto_title
|
||||
|
||||
|
||||
def test_should_reject_long_prose() -> None:
|
||||
blob = "您好!我是 Claude Code,一个软件工程助手。" + "x" * 80
|
||||
assert should_reject_auto_title(blob) is True
|
||||
|
||||
|
||||
def test_should_reject_claude_code_intro() -> None:
|
||||
assert should_reject_auto_title("Hello! I am Claude Code, a software engineering assistant.") is True
|
||||
|
||||
|
||||
def test_should_accept_short_title() -> None:
|
||||
assert should_reject_auto_title("告警查询配置") is False
|
||||
|
||||
|
||||
def test_finalize_truncates_fallback() -> None:
|
||||
long_fb = "一二三四五六七八九十11121314151617181920"
|
||||
out = finalize_auto_title(raw="x" * 100, fallback=long_fb)
|
||||
assert len(out) == AUTO_TITLE_CHAR_MAX
|
||||
assert out == long_fb[:AUTO_TITLE_CHAR_MAX]
|
||||
|
||||
|
||||
def test_finalize_uses_model_when_sane() -> None:
|
||||
assert finalize_auto_title(raw=" 网管同步 ", fallback="fallback") == "网管同步"
|
||||
Loading…
Add table
Add a link
Reference in a new issue