Models often close a fenced block on the same line as the last content.
Require only an optional newline before the closing fence so mermaid and
chart payloads are extracted instead of returned still-fenced.
Configurable chat attachment limits, PageIndex retrieval by reasoning
over your documents, broader Anthropic/OpenAI model support, and a
sweep of Book / Knowledge Base / chat-UI reliability fixes. Drop-in —
no migrations.
- attachments: size caps + extraction budgets editable in Settings →
Chat → Attachments (admin), stored in system.json with CHAT_ATTACHMENT_*
env overrides; the WebSocket frame ceiling is now derived from the
total cap, fixing large uploads silently dropping the connection.
- pageindex: chat retrieves via an internal MCP server (agentic tool
calls over the document tree); search() returns the outline; ingestion
accepts PDF/Office/Markdown/text/CSV.
- llm: newer Anthropic/OpenAI models via official SDKs incl. Codex native
tools; effort-based Claude → adaptive thinking; corrected temperature-
rejection set; streamed usage counted once per completion.
- book/knowledge: rescue stuck GENERATING/PLANNING pages + reset on
failure; KB status updates on upload/sync; atomic manager writes.
- web/channels: full-width chat + single scrollbar, aligned composer,
Enter sends edited message, malformed-markdown crash fix; WeCom aligned
with SDK 1.0.8; Mastery recency weighting restored (#618).
- release notes ver1-5-2.md (v1.5.0/v1.5.1 archived to past_releases/),
__version__ bump to 1.5.2, README Releases row + one-week fold.
- README Settings/config prose + all 10 translations synced; docs
settings/knowledge/chat pages updated separately in site/.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #615/#608/#634: the isComposingRef + composition-handler
trio duplicated across five textareas (ComposerInput,
SimpleComposerInput, ChatMessages edit, BookChatPanel, PartnerComposer)
becomes one useImeComposing() hook; the citation-anchor fallback chain
+ <details> auto-open duplicated in both markdown renderers moves to
lib/markdown-anchors.ts; and the chat scrollport reserves the
scrollbar gutter on both edges so the message column centers on the
same axis as header and composer on classic-scrollbar platforms.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #631/#628: wecom's _chat_frames now uses the same
LRU-bounded OrderedDict idiom as the dedup cache (cap 1000) so
long-running bots can't grow it unboundedly, frame-body extraction is
deduped into one helper, and the dead _loop attribute is gone.
_absolutize_img_paths now skips non-string entries and refuses to
anchor traversal paths ('..' components) with a warning, so a crafted
content_list cannot point the vision stage outside the cache dir.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #626/#625: _build_native_provider_adapter becomes a
_NATIVE_ADAPTER_BUILDERS dispatch table with the invariant documented
(every backend in _NATIVE_TOOL_BACKENDS must have an adapter branch)
and pinned by a test; ws_require_auth reads the dt_token cookie via
_COOKIE_NAME instead of a string literal.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extends the #619 follow-up to the remaining plain truncate-writes of
metadata.json (add_documents, initializer, reindex task) and replaces
progress_tracker's hand-rolled fixed-name temp+replace with the shared
atomic_write_json. _mark_kb_queued_for_processing gains a status kwarg
so the reindex endpoint's pre-dispatch write uses the same seam as
upload/sync instead of an 11-line inline block.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #636: _mark_page_error now also resets pages stranded at
PLANNING (plan_blocks_async can throw after the status is persisted),
and the background worker's log-append and finalize check are wrapped
so a storage hiccup can neither skip the page reset nor kill the
worker task.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #617, which fixed the N× inflation at three call sites and
left the pattern triplicated. record_streamed_usage() +
message_content_chars() in core/agentic/usage.py now serve
run_labeled_step, chat's _call_llm, and the question summarizer; the
redundant _UsageShim (UsageTracker already unwraps .usage), the dead
before_usage_calls guard, and both private _message_content_chars
copies are gone, along with an unreachable try/except around a dict
assignment. Accounting failures are now swallowed and debug-logged at
every site — usage bookkeeping can never break a completed stream.
Adds contract tests for the shared recorder.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #642: _build_kwargs still emitted thinking={enabled,
budget_tokens} for any configured reasoning_effort, which the same
families that reject temperature (Opus 4.7/4.8, Sonnet 5, Fable 5)
reject with a 400 — so the exact setups #642 enabled failed on every
request once an effort level was set. Real effort levels now map to
adaptive thinking there (no budget headroom inflation), thinking-off
sentinels (none/minimal/minimum) omit the param entirely (explicit
disabled is itself rejected on Fable 5), and Opus 4.6/Sonnet 4.6 keep
the enabled+budget_tokens path unchanged. The constant is renamed to
_EFFORT_BASED_FAMILIES since it now gates both removed params.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The full-width refactor removed the parent px-6 inset the composer used
to sit inside, leaving the composer card 48px wider than the message
column. The composer root now carries its own px-6 (with the empty-state
cap bumped 720->768 so content width is unchanged in both states), and
the session-loading wrapper passes full height through so
SessionLoadingView's absolutely-positioned cancel button stays at the
chat-area corner instead of collapsing next to the spinner.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rebased onto dev (the original base, multi-user, is a stale v1.3.8
ancestor). The two duplicated inline update_kb_status blocks become one
_mark_kb_queued_for_processing helper, and the progress stage changes
from 'processing' (not a member of the frontend's LIVE_PROGRESS_STAGES
set, so the UI would not render live progress) to 'starting', matching
the reindex endpoint's pre-dispatch convention. Adds a router regression
test pinning status/stage/task_id before background dispatch.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Opus 4.6 and Sonnet 4.6 still accept `temperature` — omitting it there
silently dropped the user's configured setting; and `opus-5`/`haiku-5`
matched no real model id. The set is now a documented module constant
covering exactly the effort-based families that 400 on temperature
(opus-4-7/4-8, sonnet-5, fable-5, mythos-5), with regression coverage
both ways. The new test file also gains pytest.importorskip('anthropic')
so it skips cleanly in environments without the optional [cli] SDK
(e.g. the CI python-tests job) instead of erroring on construction.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The except handler referenced `page`, which is bound only after the
loaders succeed: a loader failure on the first queue item raised
UnboundLocalError inside the handler and killed the worker task, and on
later iterations the handler could flip the previous iteration's stale
page to ERROR. `page` is now re-bound to None every iteration, both
reset paths share one _mark_page_error helper, and the save is
best-effort so a failing save cannot mask the original error or kill
the worker either. Adds regression tests for the helper's contract.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #626/#631: the anthropic/openai_codex backend allowlist in
can_use_native_tool_calling becomes a documented module constant
mirroring _NATIVE_TOOL_BLOCKED_BINDINGS, and the WeCom regression test
moves to tests/services/partners/ where every other channel test lives.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #625: login's two set_cookie calls and logout's
delete_cookie now share one _cookie_attrs() helper, so the
create/delete attribute sets can never drift apart again (the drift
that caused #623). Reads module globals at call time to keep the
regression tests' monkeypatching working.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to #619: every kb_config.json / metadata.json write in
KnowledgeBaseManager now goes through atomic_write_json (temp file +
fsync + os.replace) instead of the truncate-then-lock pattern, so a
crash mid-write can no longer leave a truncated config and concurrent
readers always see a complete previous or new file. The JSON variant
in services.file_io gains the same tolerant fsync as its text sibling,
the now-redundant private helper and dead file_lock_exclusive are
removed, and the atomicity-contract test moves next to the shared
writer in tests/services/test_file_io.py.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The engine-prerequisite line rendered via t() ends at "…Markdown
formats.", but the en/zh locale keys carried an extra "Chat retrieval
only." clause. The lookup missed, so both locales fell back to the
English source and the zh translation never rendered.
Drop the trailing clause from the locale keys (and the matching zh
value) rather than adding it to the source: search() still returns
document outlines to programmatic callers, so retrieval is not
chat-only.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Three issues prevented configuring an Anthropic profile (e.g. Claude
Opus 4.8) through the official `anthropic` SDK path:
1. base_url doubling: the SDK always appends its own `/v1/...`, so a
base_url ending in `/v1` (as shown in Anthropic's REST docs and
commonly entered by users) produced `/v1/v1/messages` -> 404
not_found_error. Strip a trailing `/v1` before handing it to the SDK.
2. temperature: effort-based models (Opus 4.6/4.7/4.8, Sonnet 4.6/5,
etc.) reject `temperature`, but only `opus-4-7` was exempted, so
Opus 4.8 failed with `invalid_request_error: temperature is
deprecated for this model`. Extend the omit list.
3. cache_control limit: system + message + per-tool markers could
exceed Anthropic's hard cap of 4 cache_control breakpoints once
~11+ tools were registered -> `A maximum of 4 blocks with
cache_control may be provided`. Budget markers across all sections.
Adds tests/services/llm/test_anthropic_provider_fixes.py covering all
three.
The compile_page method (user-triggered via HTTP/WebSocket) calls
self.compiler.compile_page() without try/except. If the compiler throws,
the page status is left in GENERATING permanently — same bug as _worker_loop.
Added exception handling that resets page status to ERROR on failure, then
re-raises so the caller still sees the error.
The sync_folder endpoint calls run_upload_processing_task without updating
KB status first, same race condition as upload_files. Added the same
status update before background task dispatch.
When a Book page fails to compile in the background worker (e.g. LLM timeout,
network error), the page status is left stuck in GENERATING permanently. The user
sees the page spinning forever with no way to retry.
Added a status reset in the exception handler: when compilation fails, the page
status is set to ERROR with the error message. This allows the user to see the
failure reason and the page becomes eligible for retry on the next resume_book
call.
When files are uploaded to an existing knowledge base via POST /{kb_name}/upload,
the KB status remains ready until the background indexing task starts. This creates
a window where the user sees the KB as ready but newly uploaded files are not yet
searchable.
Added a manager.update_kb_status() call before the background task is dispatched,
matching the behavior of create_knowledge_base which already sets status=initializing.
- Remove max-width constraint on chat scroll container to make it fill full width
- Keep message content and input box original centered 960px width for readability
- Scrollbar now appears at the far right of the page, works on entire area