Skip to content

add tool result call #2118

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dheerajiiitv
Copy link

@dheerajiiitv dheerajiiitv commented Apr 6, 2025

Important

Sequentially execute tool calls and emit tool result events in sse_generator of base.py, with added error handling.

  • Behavior:
    • Modify sse_generator in base.py to execute tool calls sequentially instead of in parallel.
    • Add handling for tool result events by emitting them as SSE events.
    • Implement error handling for tool execution, logging errors, and emitting error events.
  • Misc:
    • Add comments to clarify the new behavior in sse_generator.

This description was created by Ellipsis for e1e2a6b. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to e1e2a6b in 2 minutes and 0 seconds

More details
  • Looked at 80 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 drafted comments based on config settings.
1. py/core/agent/base.py:560
  • Draft comment:
    Switching from parallel execution (using asyncio.gather) to sequential loop may delay response if tool calls are independent. Consider if concurrency is desired.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    The comment raises a valid performance consideration - parallel execution could be faster if tool calls are independent. However, the new code adds important functionality like error handling and SSE event emission for each tool call. The sequential execution may be intentional to ensure proper ordering of events. Without understanding the full requirements and tradeoffs that led to this change, suggesting to revert to parallel execution could be misguided.
    I may be overvaluing the potential benefits of parallel execution. The sequential approach could be safer and more maintainable, especially with the new error handling and event emission requirements.
    While parallel execution could improve performance in some cases, the sequential approach better supports the new functionality and may be the intended design. The comment speculates about performance without strong evidence that it's an issue.
    Delete the comment. While it raises a valid technical consideration, it's speculative and doesn't account for the new functionality that may require sequential execution.
2. py/core/agent/base.py:572
  • Draft comment:
    Extracting tool result IDs via self.BRACKET_PATTERN assumes all IDs are in a bracket-delimited format. Verify that tool results always follow this format.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking the PR author to verify that a certain assumption about the code is correct. This violates the rule against asking the author to confirm their intention or to double-check things. The comment does not provide a specific code suggestion or ask for a specific test to be written, which would have been acceptable.
3. py/core/agent/base.py:586
  • Draft comment:
    The tool result content is transformed to JSON with raw results. Verify that the objects returned by search_results_collector.find_by_short_id are serializable, or use convert_nonserializable_objects if needed.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50%
    The comment points out a potential issue with JSON serialization of raw results. The code does directly pass raw_results to json.dumps() without any safety checks. However, looking at the error handling, any JSON serialization errors would be caught by the try/except block and handled appropriately. Additionally, convert_nonserializable_objects is already imported and used elsewhere in the error handling path.
    The comment identifies a real potential issue, but the code already has error handling in place. The suggestion to use convert_nonserializable_objects is redundant since it's already imported and used in the error path.
    While the concern about serialization is valid, the code is already resilient to serialization failures through its error handling. The suggestion would not meaningfully improve the code.
    Delete the comment since the code already handles serialization failures appropriately through error handling, and the suggested solution is already present in the codebase.
4. py/core/agent/base.py:560
  • Draft comment:
    Sequential tool call execution may reduce concurrency. Confirm if this is intended for preserving SSE ordering versus parallel performance using asyncio.gather.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50%
    The change from parallel to sequential execution appears intentional and necessary for the new SSE functionality. The code needs to emit events in order for each tool call result. Parallel execution would make the order of events unpredictable. The comment is asking for confirmation of something that seems clearly intentional based on the new SSE code structure.
    I could be wrong about the necessity of sequential execution for SSE - maybe there's a way to maintain order while still executing in parallel. But the comment doesn't propose a solution.
    Even if parallel execution is possible, the comment is still not actionable - it just asks for confirmation rather than suggesting a specific improvement. The sequential execution appears to be a deliberate design choice for the SSE feature.
    Delete the comment. It asks for confirmation of what appears to be an intentional design choice for SSE ordering, without proposing any specific improvements.
5. py/core/agent/base.py:572
  • Draft comment:
    Avoid using the built-in name 'id' as a loop variable; consider renaming it (e.g., raw_id) to prevent shadowing.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
    While technically correct that using 'id' shadows the built-in function, this is a very minor issue. The code is clearly using 'id' to represent an identifier string, and the built-in id() function is not used anywhere nearby. The code works perfectly fine as is. This feels like an overly pedantic suggestion that doesn't meaningfully improve code quality.
    The comment is technically accurate - it is generally good practice to avoid shadowing built-ins. The code could be marginally more maintainable with a more specific variable name.
    While technically correct, this is an extremely minor issue that doesn't impact functionality or readability. The scope of the shadowing is very limited (just the for loop) and the meaning is clear from context.
    Delete this comment. While technically correct, it's too minor of an issue to warrant a code change. The current code is clear and functional.
6. py/core/agent/base.py:571
  • Draft comment:
    The comment 'Extract the ids from the tool tool_result.content' contains a redundant word. Consider revising it to 'Extract the IDs from tool_result.content' for clarity.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
    While the comment does point out a real issue (the duplicate word "tool"), this is an extremely minor issue that doesn't affect code functionality. The capitalization of "IDs" is also a very minor style preference. Comments like this create noise without adding significant value.
    The comment is technically correct - there is a duplicated word and IDs is commonly capitalized. Maybe maintaining high quality even in comments is important for code readability?
    While code quality is important, this level of nitpicking on comments creates unnecessary noise in code reviews. The meaning is clear even with the minor typo.
    Delete this comment as it focuses on an extremely minor issue with comment text that doesn't impact code functionality or understanding.
7. py/core/agent/base.py:572
  • Draft comment:
    The comment 'Get the raw result from source_collector' does not match the actual variable name 'search_results_collector'. Please update the comment to reflect the correct name for consistency.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50%
    While the comment is technically correct that there's a mismatch between the comment and variable name, this is a very minor documentation issue. The code is still perfectly functional and the meaning is clear. This kind of nitpicky comment about documentation doesn't meet the bar for requiring a code change.
    The comment is factually accurate - there is indeed a mismatch between the comment and the code. And consistency in documentation is generally good practice.
    However, per the rules, we should not make purely informative comments or comments about obvious/unimportant issues. This documentation mismatch is minor and doesn't impact functionality.
    Delete this comment as it is too minor and doesn't meet the bar for requiring a code change. Documentation consistency is good but not critical enough to warrant a PR comment.

Workflow ID: wflow_xU7AGTaFjWpSMZwT


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

):
yield line
except Exception as e:
error_content = f"Error in tool '{c['name']}': {str(e)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the exception block, the error is both logged and added to conversation. Ensure that sensitive error details are not exposed to clients if that is a concern.

Suggested change
error_content = f"Error in tool '{c['name']}': {str(e)}"
error_content = f"Error in tool '{c['name']}': An unexpected error occurred."

for c in calls_list
]
)
result_content = tool_result.llm_formatted_result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable result_content is assigned but not used later. If unnecessary, consider removing it to clean up the code.

Suggested change
result_content = tool_result.llm_formatted_result

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.

1 participant