122 Commits

Author SHA1 Message Date
Shaikh Fardin
8a8cdf785f fix(llm): force temperature 1.0 for gpt-6 and drop reasoning_effort before tools (#2446)
* fix(llm): force temperature 1.0 for gpt-6 and treat reasoning_effort+tools rejection as tool-schema unsupported

* fix(llm): drop reasoning_effort instead of tools when combined request is rejected

---------

Co-authored-by: Shaikh Fardin <152140625+Fardin7798@users.noreply.github.com>
Co-authored-by: OrdoAbChao7 <2369980241@qq.com>
2026-12-01 19:27:05 +08:00
zszz3
9af0606316 test: give the call_tool dispatch stub the reasoning_declared field from #3069 2026-12-01 00:02:45 +08:00
zszz3
aa72ec6bb9 fix: say why call_tool refused, and keep an opened setup mode's tools native
CallToolTool answered every unforwarded call with "load it first". That
was wrong for a tool already in tools[] (an MCP tool, a built-in) and for
malformed arguments, and for the former it sent the model round in a
loop. DeferredToolLoader.proxy_refusal now names the reason (missing
name, call_tool itself, already in the tool list, proxy off, unknown,
not loaded) and proxy_arguments checks the arguments: an object, or a
string holding valid JSON for one; anything else is refused. The
pipeline's _resolve_proxied_tool_calls and CallToolTool both go through
proxy_call_refusal, so the message matches the decision.

Setup tools loaded through load_tools are proxied. Opening setup mode
later left them proxied: not in tools[], no rules (already loaded), and
a note that never mentioned call_tool. An opened mode's tools are now
made native, like mastery's outline tools; a setup turn whose tools are
still proxied gets a hint to reach them through call_tool.

Also: call_tool is mounted only when the loader has built-in/capability
tools to proxy; its manifest order no longer duplicates load_tools'; a
forwarded call without an id is not marked for renaming.

Refs #2972
2026-11-30 23:35:59 +08:00
zszz3
12e9809a6e fix: reach loaded tools through call_tool instead of growing tools[] mid-turn
load_tools appended the loaded schema to the end of tools[]. tools[] is the
first thing in the provider's prompt-cache key, so the next request of the
same turn re-processed the system prompt and the whole history.

When the turn mounts the new call_tool builtin, load_tools now returns the
loaded tools' definitions in its result and leaves tools[] alone; the loop
forwards each call_tool call to the named tool before dispatch, so the tool
runs with its own argument checks, injected kwargs and trace, while the
history keeps the model's own call. Tools loaded this way stay proxied for
the session (loaded_tools.json gains proxied_tools). Runtime loads that must
land in tools[] pass native=True; the TypeScript engine keeps the old
behaviour.
2026-11-30 23:35:59 +08:00
zszz3
0670c14fcd fix: repeat the setup rules once the tools are loaded, skip them for partners
The setup protocol (confirm with ask_user before apply_setting, never
handle secrets, ...) reached the model only in the load_tools result or
the turn that opened setup mode. Once history snipping or summarisation
dropped that message, the setup tools stayed in tools[] without their
rules. A setup turn (explicit mode or an intent message) whose capability
already has tools loaded now gets the protocol repeated in its turn note,
and the intent wording says the tools are already loaded.

A partner turn refuses every setup write (setup/access.py can_write), so
the setup tools are no longer listed under Extended Tools or pointed at
by the turn note there. Non-admin users keep them: personal preferences
are still theirs to change.

Also correct the comment about when set_deferral_available runs:
is_active is already asked by the exclusive-capability checks before it.

Refs #2972
2026-11-30 23:35:08 +08:00
zszz3
034b2b747b fix: leave the research module alone when it is not installed
The deferred-tool notes imported deeptutor.tools.research_tools on every
turn that had local deferred tools, so a minimal install (setup tools
deferred, no research module) failed the chat turn with
ModuleNotFoundError. Import it only when the research module is enabled,
as the rest of the pipeline already does.

Refs #2972
2026-11-30 23:35:08 +08:00
zszz3
8f6875225b refactor: move setup turn notes into prompt files
SetupCapability.turn_note and the legacy setup system block now read the
header, gap-list heading, intro section and explicit/intent/intro leads from
capabilities/setup/prompts/{en,zh}/notes.yaml (overridable under
setup.notes.<key>); the intro section gains a Chinese version. The Extended
Tools manifest header no longer says every entry is supplied by an external
service, since built-in setup and research tools are listed there too.
2026-11-30 23:35:08 +08:00
zszz3
d5ac66781f fix: keep chat tools[] and system prompt stable within a session 2026-11-30 23:35:08 +08:00
wojiecihuo
fed428e46a Merge pull request #3079 from zszz3/fix/chat-runtime-snapshots
fix: keep turn data out of the chat system prompt and drop the duplicate tool manifest
2026-11-30 23:21:32 +08:00
zszz3
0fa26b83ed fix: retract a replayed tool list as replaced by native schemas
When a tools snapshot goes away (a session stored before native requests
dropped the text manifest, or the turn after a schema-rejection fallback),
the generic retraction said the section is now empty, which reads as "no
tools" while the request carries native schemas. The tools snapshot now
gets its own retraction text, in the Python loop and the TypeScript engine.

Refs #2973
2026-11-30 13:58:21 +08:00
zszz3
cc1da61b90 fix: keep a declared empty reasoning_content on loop tool rounds
The provider-side fill only adds "" once another round in the request
already carries reasoning. A thinking model that calls a tool with no
reasoning on the very first round of a turn (or on every round so far)
still got the field dropped, and DeepSeek rejected the next request.

The stream says whether the model is thinking: DeepSeek in thinking
mode sends reasoning_content (as "" when it has nothing), and never
sends the key with thinking disabled. Record that on LLMCallResult and
send the tool round back with "" when the field was declared. Providers
that never send the field get nothing added.

Refs #2976
2026-11-30 13:55:25 +08:00
zszz3
3e0486cd21 fix: restore the text tool manifest when a provider rejects tool schemas 2026-11-29 16:32:47 +08:00
zszz3
bf77791ee9 test: pin a byte-stable system prompt while turn data changes 2026-11-29 16:32:47 +08:00
zszz3
d9a06eafd7 fix: drop the text tool manifest when native tool schemas are sent 2026-11-29 16:32:47 +08:00
crimson-gzx
b0e78d083d fix(loop): surface provider errors when forced-finish salvage fails (#2825)
Co-authored-by: Josh Guo <crimsongzx@gmail.com>
2026-11-28 18:24:39 +08:00
Bingxi Zhao (Frank)
4c1e000d85 release: v1.7.3
Prepare v1.7.3 notes for reading and book editing, expanded provider and
agent connections, learning records, model streams, and desktop upgrades.

Sync README prose and 11 translations, archive older release notes, and
update the package version. Resolve release lint/type blockers with explicit
parser and capability contracts, compatible Book call forwarding, accurate
auth task types, and quoted SQLite schema identifiers. Cover positional Book
calls and quoted legacy columns; align KB seed tests with visible retrieval
failure reporting. Keep HTTP fixtures independent of host proxies and translate
new Portuguese UI copy.

Release notes: assets/releases/ver1-7-3.md
2026-11-16 02:17:36 +08:00
Bingxi Zhao (Frank)
18e491d346 fix(rag): surface IMA content restrictions and seed retrieval failures 2026-11-15 01:04:25 +08:00
Bingxi Zhao (Frank)
b266d1a14d fix(chat): preserve sent history snapshots for prompt cache reuse 2026-11-15 01:00:14 +08:00
Bingxi Zhao (Frank)
e0872716f0 fix(runtime): announce input waits and reject oversized history plans
Local dev repairs for #2387, #2433, #2496. Regression checks cover reported symptoms and compatibility boundaries.
2026-11-15 00:44:09 +08:00
Bingxi Zhao (Frank)
6c1e3b6e60 Merge PR #2549: fix(llm): map Anthropic context-window, refusal and stop_sequence stop reasons
Move the context-full finish reason into the shared LLM protocol and add English and Chinese notices; test both localized warnings and provider mappings (186 passed).
2026-11-14 23:09:35 +08:00
Bingxi Zhao (Frank)
68106fb79a Merge PR #2670: fix(loop): keep the workspace system note byte-stable across turns (#2621)
Sort the regression-test imports and apply targeted formatting; integrated workspace-note suite passed.
2026-11-14 23:04:53 +08:00
Bingxi Zhao (Frank)
47e4c33c90 Merge PR #2493: fix(runtime): separate indexless streamed tool calls 2026-11-14 23:00:46 +08:00
wmym
d4a9f88292 fix(loop): keep the workspace system note byte-stable across turns (#2621)
The chat loop replays the workspace note as the "workspace" runtime
snapshot, which lives inside the cached prompt prefix. The note embedded
workspace.logical_output_dir — outputs/chat/<session>/<turn>/ — so its
bytes changed on every turn: the snapshot-replace logic cut the old copy
out of the middle of the rebuilt history and appended a fresh one,
invalidating the provider prompt cache on every multi-turn request
(cached-token hit rate <1%; single-turn tool loops were unaffected).

- workspace_system_note(state_turn_path=False) keeps the replayed chat
  snapshot byte-identical for the whole session and points at the current
  user message for the exact path instead.
- new workspace_turn_note() delivers the per-turn output folder in the
  trailing user message — fresh bytes each turn, so cache-safe by
  construction.
- phase-built prompts (question/research pipelines) keep embedding the
  exact path via the default state_turn_path=True; their behavior is
  unchanged.
- model-history reconstruction keeps an exact prefix once snapshots are
  stable; new multi-turn replay tests assert byte-level prefix extension
  across three consecutive turns, plus the second factor named in the
  issue turns out to be a consequence of the turn-scoped snapshot and
  needs no separate change.

Verified: tests/agents/chat 273 passed; tests/capabilities 739 passed;
tests/services/workspace+session 709 passed (8 failures pre-exist on the
clean tree and are unrelated); remaining tests/agents failures pre-exist.
2026-11-14 00:48:42 +08:00
Alex Castillo
f4566a3769 fix(llm): keep a full input context out of the output-truncation recovery
model_context_window_exceeded mapped to "length", which the agent loop
treats as an output cap and answers with continue_truncated, resending the
same full history. Report it as context_length_exceeded instead, and have
the loop end the round with a notice.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 11:52:13 -04:00
evan188199-tech
3b1730d758 feat(chat): per-conversation reasoning-effort selector in the composer (#641)
Carry the #958 service-layer reasoning_effort override through the whole
turn contract: the core TurnRequest LLMSelection accepts the field
(validated against VALID_REASONING_EFFORTS, old two-ID payloads unchanged),
the generated web contracts are regenerated, and ChatStateAdapter's
asLLMSelection restores a legal override instead of dropping it.

The composer gains a selector beside the model picker, offering only the
levels the selected model supports (live supported_reasoning_efforts or
the provider/model tables) narrowed to the wire vocabulary, hidden when
the model has none. The choice persists on the conversation's
llm_selection, so the next send uses it without a backend restart and
other conversations are unaffected; switching models resets the override.
Precedence stays conversation override -> profile/model default ->
provider default, and the context-budget readout reports the effective
effort beside the model when one was used.
2026-11-09 20:47:08 +08:00
KaiChan
fefa6c0437 fix(runtime): isolate indexless streamed tool calls 2026-11-06 19:16:02 +08:00
stefanielizeth73-art
3f943e14c8 feat(agent-loop): configure bounded reasoning-budget recovery 2026-11-03 00:12:00 +08:00
Bingxi Zhao (Frank)
1abffcf0e7 Merge remote-tracking branch 'origin/dev' into HEAD 2026-10-27 21:43:24 +08:00
Cursor Agent
3650647a86 style: ruff-format cache_control assertions in test_agent_loop
Collapse the multi-line any/all comprehensions so ruff format --check
matches CI (ruff 0.16.0).

Co-authored-by: Nandana Dileep <nandanadileep@users.noreply.github.com>
2026-10-27 11:59:43 +00:00
Bingxi Zhao (Frank)
e347c0c2e0 fix: preserve tutoring replies and stabilize preview runtime
Keep learner-facing explanations visible across finish checks, persistence, and replay. Remove mastery prose heuristics and prioritize learner objections.

Coordinate service shutdown and descendant cleanup, and preserve video lesson identity and playable results across chat completion and reload.
2026-10-27 17:58:46 +08:00
nandanadileep
6299f773c2 fix: apply prompt caching in agent loop _call_llm 2026-10-27 00:49:02 +00:00
Bingxi Zhao (Frank)
9d822fcdf0 fix(ci): align preview fixtures and formatting with current contracts 2026-10-27 01:44:57 +08:00
Bingxi Zhao (Frank)
6bbcc00c55 Merge dev into preview, preserving preview features
Integrate dev fixes with preview's Python/TypeScript schedulers, chat queue, learning navigation, and live turn persistence.
2026-10-27 01:16:58 +08:00
Bingxi Zhao (Frank)
28c11e2ae8 feat: update notes, chat interactions and workspace UI on preview
Remove course pages, APIs and the course_study capability. Add anchored note
threads and reviewed learning-block generation, queued and withdrawable chat
messages, quote attachments, side chats, and the calendar/favorites/navigation
updates.

Keep preview's existing backend architecture. Wire the new features through
its Python application and existing chat engine, retain legacy selected-text
requests, persist mid-turn messages in replay, and restore note context when
regenerating. Leave stored user data intact.

Validate frontend contracts, dependency boundaries, types, 1290 node tests,
840 rendered tests, lint, localization and the production build. Exercise
session/notes/API regressions, 53 chat-engine tests and 20 Python/native
integration tests with isolated runtime data.
2026-10-26 22:13:34 +08:00
Bingxi Zhao (Frank)
1497994c9f Merge PR #1938: bound tutoring history and retain exact recall when condensation fails 2026-10-19 00:57:48 +08:00
Bingxi Zhao (Frank)
9aae961412 Merge PR #1957: separate private source evidence from explicit public presentation 2026-10-19 00:53:44 +08:00
Bingxi Zhao (Frank)
3196b6d792 Merge PR #1954: prepare source evidence through a generic capability prerequisite contract 2026-10-19 00:48:43 +08:00
Bingxi Zhao (Frank)
e8c0b1eed5 Merge PR #1962: count complete projected requests in context guard 2026-10-19 00:31:25 +08:00
wangkai
a40c6469fb fix(solve): keep the remaining plan in view after each step fold
solve_finish_step folds the finished step's tool chatter, and the same cut
dropped the solve_plan result and the step's own `next` pointer, leaving the
model only "[S1] ... — done.". Pass SolveSession.progress_text() as the
checkpoint state so every fold keeps the current plan (done / next / todo) in
view, including after a replan, and the persisted model turn carries it into
follow-up turns.

Closes #1968
2026-10-15 13:00:06 +08:00
wangkai
87a0317255 feat(agent-loop): let a context checkpoint carry replaceable state
A checkpoint may now carry an optional `state` next to `summary`. The fold
keeps appending summaries before the boundary as before and places `state`
in one system message after it, so the next fold replaces the state instead
of stacking stale copies. Checkpoints without `state` behave exactly as before.
2026-10-15 13:00:03 +08:00
Bingxi Zhao
0e784d5080 Merge pull request #1910 from YizukiAme/codex/fix-1909-image-compaction
fix(session): budget projected image replay before compaction
2026-10-15 03:23:49 +08:00
Bingxi Zhao
d348b42336 Merge branch 'dev' into codex/fix-1909-image-compaction 2026-10-15 02:04:18 +08:00
Bingxi Zhao
8b2e62accd Merge branch 'dev' into fix/agent-loop-preserve-multimodal-instruction 2026-10-15 02:04:12 +08:00
Bingxi Zhao (Frank)
e841f36c60 test: stabilize shared transport and browser audit contracts 2026-10-15 01:27:46 +08:00
cgycorey
8df56e7dfe fix(agents): count the full request in the context-window guard
The guard sized the request from message content alone. It ignored
assistant tool_calls arguments and the tool schemas sent with the call,
so a request over the window could go out untrimmed.

- Count each message with the counter history planning uses, leaving out
  the _context_snapshot key that _call_llm strips before sending.
- Pass the call's tool_schemas into the guard. The forced-finish round
  sends none, so it passes none.
- Keep a running total while tool results are snipped instead of
  re-estimating the whole request after every snip.
- Log a warning when nothing is left to trim and the request still does
  not fit, rather than passing it silently.

With the call's tool schemas, the 8k reproduction from #1961 now trims all
three tool results, taking the request from 10435 to 6514 tokens against a
7372-token budget.

Refs #1961
2026-10-14 10:18:59 +01:00
yepyhun
755686264d fix(mastery): separate source inspection from assessment delivery 2026-10-13 13:49:35 +02:00
yepyhun
3175b812e2 fix(mastery): make source delivery demand-driven and preserve partial teaching 2026-10-13 12:33:44 +02:00
Bingxi Zhao (Frank)
3cbecb2479 feat(workspaces): add scoped instructions and refine learning UI 2026-10-12 19:29:47 +08:00
yepyhun
499e6bc75f feat(mastery): bound tutoring memory with exact branch recall 2026-10-12 11:16:34 +02:00
Fancie-Personal
4826ae980a fix(agent-loop): keep content parts when appending a loop directive
`_append_loop_instruction` appended a recovery directive by rebuilding the
trailing user message as a string. A user message can carry content parts —
chat PDF attachments add image blocks beside the text — and `str()` on that
list folds every `data:...;base64,` URL into prompt text, so the next round
sends image bytes to the provider as language tokens instead of images.

A scanned 7-page PDF (whole-page JPEGs harvested as embedded figures) turned
into a ~5.9 MB prompt string: the image-aware context counter reported
4,014,309 tokens for the round against a 1M window, the provider answered
400 InvalidParameter, and the turn ended on the empty-response fallback.

The directive now extends the message's own text part, or appends a text part
when the message holds only images. Image parts, their order and the durable
model turn are unchanged; only the text grows.

Reached whenever a round ends with nothing to replay: an empty finish, or one
whose stream carried no text, reasoning or tool call.
2026-10-11 20:12:57 +08:00