Add support for text_editor_code_execution and pause_turn stop reason#7
Merged
PederHP merged 2 commits intoOct 17, 2025
Merged
Conversation
Co-authored-by: PederHP <127606677+PederHP@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for text editor code execution tools
Add support for text_editor_code_execution and pause_turn stop reason
Oct 17, 2025
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.
Overview
This PR adds support for Anthropic's
text_editor_code_executionserver tool and thepause_turnstop reason. These new API features allow Claude to perform file operations (view, create, edit) and signal when it needs to pause during long-running turns.Changes
New Content Types
Added three new content types to the
ContentTypeenum:text_editor_code_execution_tool_result- Top-level container for tool resultstext_editor_code_execution_result- Successful operation resultstext_editor_code_execution_tool_result_error- Error responsesContent Classes
TextEditorCodeExecutionResultContent supports multiple operation types:
is_file_update(boolean indicating if file already existed)file_type,content,numLines,startLine,totalLinesoldStart,oldLines,newStart,newLines, andlinesarrayExample edit operation response:
{ "type": "text_editor_code_execution_tool_result", "tool_use_id": "srvtoolu_01E6F7G8H9I0J1K2L3M4N5O6", "content": { "type": "text_editor_code_execution_result", "oldStart": 3, "oldLines": 1, "newStart": 3, "newLines": 1, "lines": ["- \"debug\": true", "+ \"debug\": false"] } }ServerToolInput Enhancement
Extended
ServerToolInputto support text editor parameters:command- Operation type (str_replace, create, view)path- File pathold_str,new_str- For string replacementfile_text- For file creationStop Reason Support
The existing
StopReasonproperty (a string) already supports the newpause_turnvalue without requiring code changes. When Claude pauses a long-running turn, applications can provide the response back as-is in a subsequent request to let Claude continue.Deserialization
Updated
ContentConverterto handle all three new content types, following the same pattern as the existingbash_code_executiontypes.Testing
Added comprehensive test suite in
TextEditorCodeExecutionTests.cs:All 10 tests pass successfully on both net8.0 and net9.0 target frameworks.
Design Decisions
The implementation follows the established pattern of the existing
bash_code_executionsupport, usingContentBasefor polymorphic content to maintain consistency with the codebase architecture. This approach allows the JSON deserializer to handle multiple result types (success or error) in the samecontentfield.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.