Keep the Cursor stream open across tool round trips - #1
Open
Yuki13929 wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Test <kazumi200367@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent loops (Claude Code) used to stall because every
tool_resultrequest opened a new Cursor turn and pasted the whole conversation back as flattenedHuman:/Assistant:text. Cursor's harness reads that as a forged transcript, so the model re-verified earlier steps, sometimes refused, and each round trip re-paid the ~25k token system prompt.Now a
tool_usekeeps its upstream stream alive and the next request answers on it:_livemapstool_use.id -> (session, exec_id), is reaped afterCURSOR2API_RESUME_TTL(900s), and only resumes when all returned ids belong to the same stream — otherwise it falls back to replay. The replay path now labels the history as relayed context (TRANSCRIPT_HEADER) instead of a raw chat log.Also here:
response_format(json_object/json_schema) emulated with an instruction plus incremental code-fence stripping (Unfence, streaming-safe), comma-separated localAPI_KEYs,.env, Docker files, andtests/test_units.py(19 cases, no network).Measured with real Claude Code 2.1.197: a fix-bug + run-command task finishes in ~27s (previously hit the 200s timeout), and a 379-line file write completes in ~67s with no mid-task disconnect.
tests/test_api.pyandtests/test_openai.pyboth exit 0.