Commit Graph

6 Commits

Author SHA1 Message Date
DaiChaoXiong fc6b15a407 fix(providers): capture reasoning from multiple field names and echo both
The replay error ('reasoning_text in thinking mode must be passed back')
persisted because the endpoint emits reasoning under a name other than
reasoning_content — e.g. reasoning_text — which we never captured, so the
thinking never reached the transcript.

- capture reasoning from reasoning_content / reasoning_text / reasoning /
  thinking (first non-empty wins)
- echo the captured reasoning back as BOTH reasoning_content and
  reasoning_text on assistant messages
- FOCUS_DEBUG_FILE=<path> appends every raw network chunk to a file for
  diagnosing provider-protocol mismatches (both providers)
- regression tests: reasoning_text capture, dual-field replay
2026-08-09 21:54:07 +08:00
DaiChaoXiong 107f1f9f42 fix(providers): echo reasoning_content back for thinking-mode APIs
DeepSeek's thinking mode rejects a replayed assistant message that omits its
reasoning ('the reasoning_text must be passed back to the API', HTTP 400).
The Chat Completions serializer now includes thinking blocks as
reasoning_content on assistant messages; OpenAI official never produces
thinking blocks, so the field is only sent when present — safe for both.
Regression test: a replayed assistant carries reasoning_content.
2026-08-09 21:48:29 +08:00
DaiChaoXiong f695acc845 refactor(test): move all unit tests from src/ into tests/<module>_tests.rs
Per AGENTS.md §5.1 every test must live under crates/<name>/tests/, so the
inline #[cfg(test)] modules in harness/tools/providers/transport are gone:

- harness: session_tests / compaction_tests / prompt_tests (days_to_ymd made pub)
- tools: read / write / edit / shell tests (Tool trait imported explicitly)
- providers: config_tests; request-body and stop-reason coverage folded into
  integration tests via mock-recorded requests and SSE events (private builders
  no longer tested directly)
- transport: ChunkedDecoder made pub (with Default), decoder tests moved into
  transport_tests.rs

The only #[cfg(test)] left in src/ is the test-only TLS infra in tls.rs.
2026-08-09 21:09:01 +08:00
DaiChaoXiong 8ed56c3952 feat(providers): rewrite Anthropic and OpenAI providers
- Anthropic Messages API (2023-06-01) SSE streaming: text/thinking/tool_use
  blocks, cache usage, stop-reason mapping, errors encoded as events
- OpenAI Responses API + Chat Completions (switchable), tool_calls delta
  accumulation, include_usage, reasoning_content -> thinking
- ProviderConfig with base_url/api_key/context_window/timeout; known-model
  context-window table with three-layer resolution
- background current-thread runtime bridges sync agent loop to async I/O
- mock-transport replay tests (chunks straddle SSE boundaries) + full agent
  integration test
2026-08-09 20:59:49 +08:00
DaiChaoXiong 32b630e440 chore: remove focus-cli and obsolete provider sources
focus-cli is deleted entirely (the TUI will be a new crate later); the old
Anthropic/OpenAI/Zai provider sources and the core mock module are removed as
part of the rewrite.
2026-08-09 20:59:29 +08:00
DaiChaoXiong a7ddba035a INIT 2026-07-16 17:59:16 +08:00