Skip to content

Improve Cursor-visible thinking display, large-payload stability, and optional Docker#35

Open
optommt-sudo wants to merge 3 commits intoyxlao:mainfrom
optommt-sudo:feat/cursor-thinking-blockquote-and-docker
Open

Improve Cursor-visible thinking display, large-payload stability, and optional Docker#35
optommt-sudo wants to merge 3 commits intoyxlao:mainfrom
optommt-sudo:feat/cursor-thinking-blockquote-and-docker

Conversation

@optommt-sudo
Copy link
Copy Markdown

Summary
This PR improves how streamed reasoning_content is shown in Cursor (and similar clients), makes long-running / large requests more reliable, and adds an optional Docker deployment path.

  1. Thinking display (streaming + non-streaming)
    Problem: Cursor often does not render

    Details HTML well; reasoning showed up as raw tags or awkward fragments.
    Change: Mirror streaming reasoning_content into content as Markdown blockquotes: first chunk uses > 💭 , continuations use > , then \n\n before normal answer / tool-call phase. Non-streaming responses use the same blockquote shape; multi-line reasoning uses > on continuation lines.
    Upstream hygiene: strip_cursor_thinking_blocks() now also removes a leading run of >... lines so mirrored thinking is not replayed to the API as user-visible fluff.
    Files: streaming.py, transform.py, tests in test_streaming.py, test_protocol.py, test_trace.py, test_transform.py.

  2. Large context / long requests
    Default request_timeout raised 300s → 600s and max_request_body_bytes 20 MiB → 40 MiB (helps ~960k-token style payloads and slow thinking responses).
    Files: config.py.

  3. Upstream retries
    Retry urlopen on URLError and on HTTPError with 5xx only (not 4xx), up to 3 attempts with 2s / 4s backoff; fresh Request per attempt.
    Files: server.py.

  4. Docker (optional)
    Dockerfile, docker-compose.yml, .dockerignore, example repo-root config.yaml (e.g. host: 0.0.0.0, timeouts/body limits aligned with above).
    Testing
    uv run python -m unittest discover -s tests
    Docker (optional): docker compose build && docker compose up -d.

Breaking / behavior notes
Client-visible assistant content during streaming is now blockquote Markdown instead of

Details...
. Clients that depended on the old HTML shape may need to adjust; stripping logic was updated accordingly.

optommt-sudo and others added 3 commits May 1, 2026 23:09
…twork errors

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@yxlao
Copy link
Copy Markdown
Owner

yxlao commented May 2, 2026

Thanks for the pr @optommt-sudo

  1. When you refer to:

Thinking display (streaming + non-streaming)
Problem: Cursor often does not render

Do you mean that Cursor is not rendering it at all sometimes? Or is it that you have to click the triangle to trigger the display of detail? Currently we support setting collasible_reasoning: false to disable the folding of details, such that all thinking tokens are displayed as plain text. In fact, we have an issue #20 that requests the feature to hide the thinking details. We have this as an option to hide/unide the thinking details.

  1. The request timeout and retry idea sounds good to me. I would prefer to have that as a separate PR (ideally each PR shall only contain one new feature)

  2. We need to run the pre-commit hooks and fix the tests to pass CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants