-
Notifications
You must be signed in to change notification settings - Fork 0
Revert "Revert "Adding Schema for Tool Outputs"" (#894) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Revert "Adding Schema for Tool Outputs"" (#894) #1
Conversation
Reverts codegen-sh#892 --------- Co-authored-by: Rushil Patel <[email protected]> Co-authored-by: rushilpatel0 <[email protected]>
Reviewer's Guide by SourceryThis pull request reverts the changes introduced in PR codegen-sh#892, which added schema for tool outputs. The changes modify the tool classes to return a Sequence diagram for ViewFileTool executionsequenceDiagram
participant User
participant ViewFileTool
participant view_file
participant ViewFileObservation
User->>ViewFileTool: _run(filepath, start_line, end_line, max_lines, line_numbers, tool_call_id)
ViewFileTool->>view_file: view_file(codebase, filepath, start_line, end_line, max_lines)
activate view_file
view_file->>ViewFileObservation: Create ViewFileObservation
activate ViewFileObservation
ViewFileObservation-->>view_file: ViewFileObservation
deactivate ViewFileObservation
view_file-->>ViewFileTool: ViewFileObservation
deactivate view_file
ViewFileTool->>ViewFileObservation: render(tool_call_id)
activate ViewFileObservation
ViewFileObservation-->>ViewFileTool: ToolMessage
deactivate ViewFileObservation
ViewFileTool-->>User: ToolMessage
Sequence diagram for ListDirectoryTool executionsequenceDiagram
participant User
participant ListDirectoryTool
participant list_directory
participant ListDirectoryObservation
User->>ListDirectoryTool: _run(tool_call_id, dirpath, depth)
ListDirectoryTool->>list_directory: list_directory(codebase, dirpath, depth)
activate list_directory
list_directory->>ListDirectoryObservation: Create ListDirectoryObservation
activate ListDirectoryObservation
ListDirectoryObservation-->>list_directory: ListDirectoryObservation
deactivate ListDirectoryObservation
list_directory-->>ListDirectoryTool: ListDirectoryObservation
deactivate list_directory
ListDirectoryTool->>ListDirectoryObservation: render(tool_call_id)
activate ListDirectoryObservation
ListDirectoryObservation-->>ListDirectoryTool: ToolMessage
deactivate ListDirectoryObservation
ListDirectoryTool-->>User: ToolMessage
Sequence diagram for SearchTool executionsequenceDiagram
participant User
participant SearchTool
participant search
participant SearchObservation
User->>SearchTool: _run(tool_call_id, query, file_extensions, page, files_per_page, use_regex)
SearchTool->>search: search(codebase, query, file_extensions, page, files_per_page, use_regex)
activate search
search->>SearchObservation: Create SearchObservation
activate SearchObservation
SearchObservation-->>search: SearchObservation
deactivate SearchObservation
search-->>SearchTool: SearchObservation
deactivate search
SearchTool->>SearchObservation: render(tool_call_id)
activate SearchObservation
SearchObservation-->>SearchTool: ToolMessage
deactivate SearchObservation
SearchTool-->>User: ToolMessage
Sequence diagram for EditFileTool executionsequenceDiagram
participant User
participant EditFileTool
participant edit_file
participant EditFileObservation
User->>EditFileTool: _run(filepath, content, tool_call_id)
EditFileTool->>edit_file: edit_file(codebase, filepath, content)
activate edit_file
edit_file->>EditFileObservation: Create EditFileObservation
activate EditFileObservation
EditFileObservation-->>edit_file: EditFileObservation
deactivate EditFileObservation
edit_file-->>EditFileTool: EditFileObservation
deactivate edit_file
EditFileTool->>EditFileObservation: render(tool_call_id)
activate EditFileObservation
EditFileObservation-->>EditFileTool: ToolMessage
deactivate EditFileObservation
EditFileTool-->>User: ToolMessage
Sequence diagram for SemanticEditTool executionsequenceDiagram
participant User
participant SemanticEditTool
participant semantic_edit
participant SemanticEditObservation
User->>SemanticEditTool: _run(filepath, tool_call_id, edit_content, start, end)
SemanticEditTool->>semantic_edit: semantic_edit(codebase, filepath, edit_content, start, end)
activate semantic_edit
semantic_edit->>SemanticEditObservation: Create SemanticEditObservation
activate SemanticEditObservation
SemanticEditObservation-->>semantic_edit: SemanticEditObservation
deactivate SemanticEditObservation
semantic_edit-->>SemanticEditTool: SemanticEditObservation
deactivate semantic_edit
SemanticEditTool->>SemanticEditObservation: render(tool_call_id)
activate SemanticEditObservation
SemanticEditObservation-->>SemanticEditTool: ToolMessage
deactivate SemanticEditObservation
SemanticEditTool-->>User: ToolMessage
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Reviewer Guide 🔍(Review updated until commit 046b238)Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Zeeeepa - I've reviewed your changes - here's some feedback:
Overall Comments:
- It looks like the
render
methods are being replaced withrender_as_string
and a newrender
method that returns aToolMessage
- can we rename the oldrender
methods toto_string
to be more clear about their purpose? - It looks like all the tools are now taking a
tool_call_id
as input - can we use a dependency injection framework to avoid having to pass this in manually?
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
if self.status == "error": | ||
return ToolMessage( | ||
content=content, | ||
status=self.status, | ||
tool_call_id=tool_call_id, | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): We've found these issues:
- Lift code into else after jump in control flow (
reintroduce-else
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
if self.status == "error": | |
return ToolMessage( | |
content=content, | |
status=self.status, | |
tool_call_id=tool_call_id, | |
) |
for match in self.matches: | ||
lines.append(match.render()) | ||
lines.append(match.render_as_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Replace a for append loop with list extend (for-append-to-extend
)
for match in self.matches: | |
lines.append(match.render()) | |
lines.append(match.render_as_string()) | |
lines.extend(match.render_as_string() for match in self.matches) |
lines.append(result.render_as_string()) | ||
lines.append("") # Add blank line between files | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Merge consecutive list appends into a single extend (merge-list-appends-into-extend
)
lines.append(result.render_as_string()) | |
lines.append("") # Add blank line between files | |
lines.extend((result.render_as_string(), "")) |
PR Code Suggestions ✨Explore these optional code suggestions:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Status |
---|---|---|
Typo in Replace Artifacts Class Name ▹ view | ||
Inefficient Path String Construction ▹ view |
Files scanned
File Path | Reviewed |
---|---|
src/codegen/agents/data.py | ✅ |
src/codegen/extensions/tools/edit_file.py | ✅ |
src/codegen/extensions/tools/observation.py | ✅ |
src/codegen/agents/tracer.py | ✅ |
src/codegen/extensions/tools/relace_edit.py | ✅ |
src/codegen/extensions/tools/tool_output_types.py | ✅ |
src/codegen/extensions/tools/view_file.py | ✅ |
src/codegen/extensions/tools/semantic_edit.py | ✅ |
src/codegen/extensions/tools/list_directory.py | ✅ |
src/codegen/extensions/tools/search.py | ✅ |
src/codegen/extensions/langchain/graph.py | ✅ |
src/codegen/extensions/langchain/tools.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
error: Optional[str] # Error message (only present on error) | ||
|
||
|
||
class RelaceEditArtifacts(TypedDict, total=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in Replace Artifacts Class Name 
Tell me more
What is the issue?
There is a typo in the class name 'RelaceEditArtifacts' which should be 'ReplaceEditArtifacts'.
Why this matters
This typo could cause confusion in the codebase and make it difficult for other developers to find and use the correct class name. It could also lead to bugs if code tries to reference the correct spelling.
Suggested change ∙ Feature Preview
Rename the class to fix the typo:
class ReplaceEditArtifacts(TypedDict, total=False):
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
|
||
if self.files is not None: | ||
artifacts["files"] = self.files | ||
artifacts["file_paths"] = [f"{self.path}/{f}" for f in self.files] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inefficient Path String Construction 
Tell me more
What is the issue?
String concatenation in a list comprehension for file paths could be inefficient for large directories.
Why this matters
For directories with many files, creating new strings through concatenation in a loop can lead to excessive memory allocations.
Suggested change ∙ Feature Preview
Use os.path.join or pathlib for more efficient path construction:
from pathlib import Path
artifacts["file_paths"] = [str(Path(self.path) / f) for f in self.files]
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
Reverts codegen-sh#892
Motivation
Content
Testing
Please check the following before marking your PR as ready for review
Summary by Sourcery
Revert a previous reversion and add schema definitions for tool outputs, introducing structured artifacts for various tool operations
New Features:
Enhancements:
Chores: