Skip to content
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

f/task tests #458

Merged
merged 7 commits into from
Aug 16, 2024
Merged

f/task tests #458

merged 7 commits into from
Aug 16, 2024

Conversation

creatorrr
Copy link
Contributor

@creatorrr creatorrr commented Aug 16, 2024

  • fix(agents-api): Minor fixes
  • wip

🚀 This description was created by Ellipsis for commit be7471b

Summary:

Refactors task execution and transition handling, updates models and SDKs, enhances test coverage, modifies environment configurations, and refactors temporal.py for improved testing setup.

Key points:

  • Refactor Imports: Updated imports in agents-api/agents_api/activities/embed_docs.py and agents-api/agents_api/activities/task_steps/__init__.py.
  • Update Models: Modified Transition and TransitionTarget models in agents-api/agents_api/autogen/Executions.py and agents-api/agents_api/autogen/openapi_model.py.
  • Enhance Task Steps: Refactored prompt_step, evaluate_step, tool_call_step, and transition_step into separate files in agents-api/agents_api/activities/task_steps/.
  • Modify Transition Logic: Added validate_transition_targets function in agents-api/agents_api/models/execution/create_execution_transition.py.
  • Update SDKs: Adjusted TypeScript and Python SDKs to include new Executions_Transition and Executions_TransitionTarget types.
  • Test Enhancements: Updated test fixtures and test cases in agents-api/tests/fixtures.py and agents-api/tests/test_activities.py.
  • Environment Configuration: Added testing flag in agents-api/agents_api/env.py.
  • Remove Test File: Deleted agents-api/tests/test_task_routes.py.
  • Refactor temporal.py: Use temporal_task_queue from env in run_task_execution_workflow.
  • Update pyproject.toml: Add testing environment variable for tests, configure ward as test command.
  • Enhance Testing: Set AGENTS_API_TESTING to true for test environment.

Generated with ❤️ by ellipsis.dev

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 b50be03 in 55 seconds

More details
  • Looked at 1930 lines of code in 49 files
  • Skipped 2 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_acOnCp4UHmxiuAKC


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.

"cancelled": "cancelled",
}

def validate_transition_targets(data: CreateTransitionRequest) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

The validation logic for transition targets is duplicated in the validate_transition_targets function and the create_execution_transition function. Consider consolidating this logic to ensure consistency and reduce maintenance overhead.

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.

👍 Looks good to me! Incremental review on 083b089 in 39 seconds

More details
  • Looked at 924 lines of code in 17 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. agents-api/agents_api/activities/task_steps/transition_step.py:18
  • Draft comment:
    The function signature for transition_step incorrectly uses StepContext[None]. This should be replaced with a more specific step context type to ensure proper handling of step-related data.
async def transition_step(
    context: StepContext[CreateTransitionRequest],
    transition_info: CreateTransitionRequest,
) -> None:
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is suggesting a code change to improve type specificity, which is a valid concern for code quality. Using StepContext[None] might be too generic and could lead to issues if specific step-related data is expected. The comment is actionable and clear, suggesting a specific improvement to the code.
    The comment assumes that StepContext[None] is incorrect without knowing the context of its use. It might be intentional to use a generic type if no specific data is needed. The comment could be speculative if the current type is indeed appropriate for the function's purpose.
    Even if StepContext[None] is intentional, the comment highlights a potential area for improvement in type specificity, which is generally beneficial for code quality. It's worth considering if a more specific type could enhance the code.
    The comment should be kept as it suggests a specific improvement to the code's type specificity, which is a valid concern for code quality.

Workflow ID: wflow_X2PtQ5CJZYFl55TA


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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.

👍 Looks good to me! Incremental review on 86e51a7 in 43 seconds

More details
  • Looked at 465 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. agents-api/agents_api/activities/task_steps/transition_step.py:36
  • Draft comment:
    The transition_step function should explicitly return a value, even if it's just None, to ensure clarity in the workflow execution.
    return None
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The function is an asynchronous function with a return type of None, which means it is not expected to return any value. In Python, if a function does not explicitly return a value, it implicitly returns None. Adding return None is not necessary for the function to work correctly, and it does not improve code quality significantly. The suggestion does not address a code change that is required, as the function is already correctly defined to return None implicitly.
    The suggestion might be seen as a minor improvement for code clarity, but it does not address a necessary change. The function's behavior is already clear from its type hint, and the implicit return of None is a common Python practice.
    While adding return None could be seen as a minor improvement for explicitness, it is not a necessary change and does not align with the rules for commenting on code changes.
    The comment suggesting an explicit return statement is not necessary and does not align with the rules for commenting on code changes. It should be removed.

Workflow ID: wflow_5fEwEOFD5cCzUJXK


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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. Incremental review on f00b6b1 in 1 minute and 33 seconds

More details
  • Looked at 378 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. agents-api/agents_api/routers/docs/create_doc.py:45
  • Draft comment:
    The run_embed_docs_task function is missing the developer_id parameter in the call to EmbedDocsWorkflow.run. Ensure that all required parameters are correctly passed to maintain functionality.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is incorrect because the developer_id is indeed being passed as part of the embed_payload. The code change correctly includes the developer_id in the EmbedDocsPayload, which is then passed to the workflow. Therefore, the comment does not reflect the actual state of the code.
    I might be overlooking some implicit requirement for the developer_id to be passed differently, but the code seems to handle it correctly through the embed_payload.
    The embed_payload is a common pattern for passing multiple parameters, and the code change aligns with this pattern. The comment does not account for this.
    The comment should be deleted because it incorrectly states that the developer_id is missing, while it is actually included in the embed_payload.
2. agents-api/agents_api/workflows/embed_docs.py:15
  • Draft comment:
    Ensure that the method signature in EmbedDocsWorkflow.run matches the expected parameters of the embed_docs activity it calls to avoid runtime errors.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is asking for a verification, which is not allowed according to the rules. The code change seems to be correctly implemented, as the method signature now matches the expected input type (EmbedDocsPayload). The comment does not point out a definite issue but rather suggests a check, which is not actionable or necessary.
    I might be overlooking a potential mismatch between the EmbedDocsPayload structure and what embed_docs expects. However, the comment does not provide specific evidence of such a mismatch.
    The code change appears to be consistent with the import and usage of EmbedDocsPayload, and the comment does not provide specific evidence of an issue.
    Remove the comment as it is asking for verification rather than pointing out a definite issue.
3. agents-api/agents_api/workflows/task_execution.py:162
  • Draft comment:
    Consider simplifying the control flow in TaskExecutionWorkflow.run to enhance readability and maintainability. Additionally, evaluate if the use of continue_as_new is necessary, as it might complicate the workflow's lifecycle management.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is focused on code quality and suggests a refactor to improve readability and maintainability, which is a valid concern. The method is indeed complex, and simplifying it could be beneficial. The comment does not violate any rules as it is not speculative, it is actionable, and it pertains to the code in the diff.
    The comment could be seen as too vague, as it does not provide specific suggestions for how to simplify the control flow. It also questions the use of continue_as_new without providing a clear reason why it might be unnecessary.
    While the comment could be more specific, it still highlights a potential area for improvement in the code's readability and maintainability, which is valuable feedback.
    Keep the comment as it provides actionable feedback on code quality, suggesting a refactor for better readability and maintainability.

Workflow ID: wflow_mgEQkFAfRJjp2fDl


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.

content: list[str]
embed_instruction: str | None
title: str | None = None
include_title: bool = False # Need to be a separate parameter for the activity
Copy link
Contributor

Choose a reason for hiding this comment

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

The include_title field in EmbedDocsPayload is defined but not used in the embed_docs function. If this field is not required, consider removing it to clean up the code.

all_workflows = context.execution_input.task.workflows
workflow = context.current_step.workflow

assert workflow in [
Copy link
Contributor

Choose a reason for hiding this comment

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

Using assertions in production code, as seen in yield_step, can be risky because assertions can be disabled in some Python environments. Consider replacing the assertion with an explicit exception handling mechanism to ensure robust error handling.

default_settings = active_agent.default_settings

default_settings: AgentDefaultSettings | None = active_agent.default_settings
default_settings: dict = (
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 default_settings is reassigned from AgentDefaultSettings | None to dict, which can be confusing. Consider using a different variable name for the dictionary representation to improve code clarity.

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.

👍 Looks good to me! Incremental review on ae6011a in 1 minute and 44 seconds

More details
  • Looked at 395 lines of code in 11 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. agents-api/agents_api/activities/embed_docs.py:23
  • Draft comment:
    The refactoring to use EmbedDocsPayload for the embed_docs activity function enhances readability and maintainability by encapsulating parameters in a structured model.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The embed_docs activity function has been refactored to use a Pydantic model EmbedDocsPayload for its parameters. This change simplifies the function signature and ensures type safety and validation of input data. The function now unpacks the payload and uses its attributes directly, which is a cleaner approach compared to the previous version where parameters were passed individually. The use of Pydantic also allows for easy extension and modification of the input data structure in the future.
2. agents-api/agents_api/activities/task_steps/transition_step.py:17
  • Draft comment:
    The update to handle 'wait' type transitions in transition_step function is crucial for supporting asynchronous operations in task executions, enhancing the system's capability to manage complex workflows.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The transition_step function in transition_step.py has been updated to handle transitions based on the type specified in the transition_info. If the transition type is 'wait', it retrieves the task token from the activity's context and assigns it to the transition_info. This is crucial for handling asynchronous operations where the system needs to pause and wait for an external event or condition before proceeding. The function then proceeds to create the transition in the database using the create_execution_transition_query function, which likely updates the execution state in the database to reflect the new transition state.
3. agents-api/agents_api/activities/task_steps/yield_step.py:20
  • Draft comment:
    The enhancements in yield_step function to validate the existence of the workflow and handle dynamic transitions based on task configuration improve the robustness and flexibility of task execution workflows.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The yield_step function has been updated to handle the transition to a specified workflow step based on the current task's configuration. It first checks if the specified workflow exists within the task's workflows, which is a necessary validation to prevent runtime errors. It then evaluates expressions provided in the step's arguments to compute the arguments for the next step. Finally, it creates a TransitionTarget to specify the next step to transition to, and returns a StepOutcome that includes the computed arguments and the transition target. This update is crucial for supporting dynamic workflow transitions based on the task configuration and runtime conditions.
4. agents-api/agents_api/autogen/openapi_model.py:2
  • Draft comment:
    The comprehensive model definitions in openapi_model.py enhance type safety and consistency across the API, contributing to the robustness and maintainability of the application.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The openapi_model.py file contains definitions for various models used across the API. It includes type aliases, custom types, and assertions to ensure that certain model fields match expected types. These definitions are crucial for ensuring consistency and correctness in data handling throughout the application. The use of Pydantic models and type annotations helps in maintaining type safety and makes the API more robust by catching errors at the development stage rather than at runtime.
5. agents-api/agents_api/workflows/embed_docs.py:12
  • Draft comment:
    The EmbedDocsWorkflow efficiently handles document embedding tasks asynchronously, enhancing the system's scalability and performance in processing large or numerous documents.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The EmbedDocsWorkflow in embed_docs.py defines a workflow for embedding documents. It uses the embed_docs activity to process the embedding of document content. The workflow is designed to handle the embedding task asynchronously, allowing for scalability and efficient processing of potentially large or numerous documents. This setup is crucial for enabling background processing of embeddings, which can be computationally intensive, without blocking the main application flow.

Workflow ID: wflow_kqB7CcH5DqqenWN7


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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. Incremental review on 0dc3c32 in 40 seconds

More details
  • Looked at 482 lines of code in 15 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_82mSzQjb9Obb1RS1


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.

content: list[str]
embed_instruction: str | None
title: str | None = None
include_title: bool = False # Need to be a separate parameter for the activity
Copy link
Contributor

Choose a reason for hiding this comment

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

The include_title field in EmbedDocsPayload is not used in the embed_docs activity and can be misleading. Consider removing it or implementing its functionality in the activity.

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. Incremental review on 150649b in 31 seconds

More details
  • Looked at 223 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_lKf52mgNJ3eHIoia


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.

async def truncation(session_id: str, token_count_threshold: int) -> None:
print(session_id, token_count_threshold)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using print for debugging is not recommended in production code. Consider replacing it with Python's logging library for more controlled logging:

Diwank Tomer added 6 commits August 16, 2024 23:17
Signed-off-by: Diwank Tomer <[email protected]>
Signed-off-by: Diwank Tomer <[email protected]>
Signed-off-by: Diwank Tomer <[email protected]>
Signed-off-by: Diwank Tomer <[email protected]>
Signed-off-by: Diwank Tomer <[email protected]>
Signed-off-by: Diwank Tomer <[email protected]>
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. Incremental review on a4e49a0 in 30 seconds

More details
  • Looked at 26 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_BH3PGeyflmJQG3Ld


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.

async def truncation(session_id: str, token_count_threshold: int) -> None:
print(session_id, token_count_threshold)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider replacing print statements with logging for better control over log levels and outputs. For example:

wip
Signed-off-by: Diwank Tomer <[email protected]>
@whiterabbit1983 whiterabbit1983 merged commit d13a46f into dev-tasks-disable-routes Aug 16, 2024
1 of 5 checks passed
@whiterabbit1983 whiterabbit1983 deleted the f/task-tests branch August 16, 2024 20:21
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.

👍 Looks good to me! Incremental review on be7471b in 47 seconds

More details
  • Looked at 43 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. agents-api/agents_api/clients/temporal.py:53
  • Draft comment:
    Ensure that temporal_task_queue is properly defined and initialized in the configuration files to avoid runtime errors.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is asking to ensure that 'temporal_task_queue' is properly defined, which is a speculative comment. The code change is straightforward, replacing a hardcoded string with a variable, and any issues with 'temporal_task_queue' would likely be caught during runtime or testing. The comment does not point out a definite issue with the code change itself.
    I might be underestimating the importance of ensuring configuration variables are set correctly, but this is generally outside the scope of a code review comment unless there's a clear issue in the code.
    While configuration is important, the comment does not address a specific code issue and is more of a general reminder, which is not necessary in this context.
    The comment should be removed as it is speculative and does not address a specific code issue.
2. agents-api/pyproject.toml:99
  • Draft comment:
    Ensure that the new testing configuration with AGENTS_API_TESTING set to true is properly handled in the application code to differentiate test executions from production.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is speculative and asks the author to ensure that the new configuration is handled properly, which is not actionable or clear. It does not point out a definite issue in the code. According to the rules, such comments should be removed.
    I might be missing the context of how the environment variable is used in the application, but the comment does not specify any definite issue with the current change.
    Even if the environment variable is not handled properly, the comment does not provide specific guidance or identify a clear issue, making it unhelpful.
    Remove the comment as it is speculative and not actionable, violating the rules for comments.

Workflow ID: wflow_nXYhuhbNYhYhK1sB


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@creatorrr creatorrr restored the f/task-tests branch August 16, 2024 20:22
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