Skip to content

Conversation

creatorrr
Copy link
Contributor

@creatorrr creatorrr commented Jun 24, 2025

User description

Signed-off-by: Diwank Singh Tomer diwank.singh@gmail.com


PR Type

Enhancement, Other


Description

Major refactoring: Added new SQLBuilder class for safe dynamic SQL query construction with parameter placeholders and SQL injection prevention
Database query improvements: Refactored agent and user patching queries to use new SQL builder utilities, replacing complex CASE/WHEN patterns
Query optimization: Enhanced agent listing and execution transitions queries with dynamic filtering capabilities
Code formatting: Applied comprehensive formatting improvements across the entire codebase including:

  • Multi-line formatting for long function signatures and parameter lists
  • Consistent formatting for decorators, imports, and method calls
  • Improved readability of test assertions and data structures
  • Better line breaking for complex expressions and constructor calls
    Performance improvements: Test runtime measurements show significant performance gains across the test suite
    Maintainability: Improved separation of concerns and type safety in database operations

Changes walkthrough 📝

Relevant files
Enhancement
5 files
sql_builder.py
Add SQL builder utilities for dynamic query construction 

agents-api/agents_api/queries/sql_builder.py

• Added a new SQLBuilder class for safe dynamic SQL query construction

• Implemented methods for building UPDATE, WHERE, ORDER BY, and LIMIT
clauses
• Added utility functions for building patch queries and JSONB
updates
• Includes parameter placeholders and SQL injection prevention

+342/-0 
patch_agent.py
Refactor agent patching to use SQL builder utilities         

agents-api/agents_api/queries/agents/patch_agent.py

• Refactored to use the new build_patch_query utility from sql_builder

• Replaced complex CASE/WHEN SQL patterns with dynamic query building

• Simplified parameter handling and improved type safety
• Added
special handling for metadata JSONB merge operations

+70/-61 
patch_user.py
Refactor user patching to use SQL builder utilities           

agents-api/agents_api/queries/users/patch_user.py

• Refactored to use the new build_patch_query utility from sql_builder

• Replaced complex CASE/WHEN SQL patterns with dynamic query building

• Simplified parameter handling and improved maintainability
• Added
special handling for metadata JSONB merge operations

+65/-43 
list_agents.py
Refactor agent listing to use metadata filter utilities   

agents-api/agents_api/queries/agents/list_agents.py

• Refactored to use build_metadata_filter_conditions utility function

• Simplified SQL query construction and parameter handling
• Improved
separation of concerns between base query and dynamic filters

+31/-23 
list_execution_transitions.py
Refactor execution transitions query with dynamic filtering

agents-api/agents_api/queries/executions/list_execution_transitions.py

• Refactored SQL query construction to use dynamic string formatting

Improved separation of base query and conditional filters
• Applied
consistent formatting to decorator and function definitions

+26/-19 
Formatting
77 files
task_validation.py
Code formatting improvements for task validation utilities

agents-api/agents_api/common/utils/task_validation.py

• Reformatted import statements to use multi-line format
• Applied
consistent code formatting to list comprehensions and dictionary
structures
• Improved readability of nested conditional statements and
function calls

+72/-46 
test_docs_routes.py
Code formatting improvements for document route tests       

agents-api/tests/test_docs_routes.py

• Applied consistent formatting to function calls and method
invocations
• Reformatted long parameter lists to use multi-line
format
• Improved readability of test assertions and data structures

+53/-17 
test_task_execution_workflow.py
Code formatting improvements for task execution workflow tests

agents-api/tests/test_task_execution_workflow.py

• Reformatted long function calls and parameter lists for better
readability
• Applied consistent multi-line formatting to patch
decorators and assertions
• Improved code structure in test method
definitions

+65/-31 
test_mmr.py
Code formatting improvements for MMR algorithm tests         

agents-api/tests/test_mmr.py

• Reformatted test data creation and function calls for better
readability
• Applied consistent multi-line formatting to list
comprehensions and assertions
• Improved structure of test method
parameters and return values

+42/-14 
test_chat_streaming.py
Code formatting improvements for chat streaming tests       

agents-api/tests/test_chat_streaming.py

• Applied consistent formatting to patch decorators and function calls

• Reformatted long parameter lists and assertions for better
readability
• Improved code structure in streaming chat test methods

+44/-14 
env.py
Code formatting improvements for environment configuration

agents-api/agents_api/env.py

• Applied consistent multi-line formatting to environment variable
definitions
• Reformatted long parameter lists and function calls for
better readability

+21/-7   
db_exceptions.py
Code formatting improvements for database exception handling

agents-api/agents_api/common/utils/db_exceptions.py

• Applied consistent multi-line formatting to exception mapping
dictionaries
• Reformatted long parameter lists and function calls for
better readability
• Improved code structure in error handling
utilities

+36/-22 
__init__.py
Code formatting improvements for task execution workflows

agents-api/agents_api/workflows/task_execution/init.py

• Applied consistent formatting to conditional statements and function
calls
• Reformatted long parameter lists and timeout configurations

Improved readability of workflow step handling methods

+33/-11 
test_task_validation.py
Code formatting improvements for task validation tests     

agents-api/tests/test_task_validation.py

• Applied consistent multi-line formatting to import statements and
test data
• Reformatted test method definitions and assertions for
better readability
• Improved structure of test case parameters and
expected results

+38/-11 
test_task_routes.py
Code formatting improvements for task route tests               

agents-api/tests/test_task_routes.py

• Applied consistent formatting to function calls and method
invocations
• Reformatted long parameter lists and test assertions

Improved readability of route testing methods

+25/-8   
test_secrets_usage.py
Code formatting improvements for secrets usage tests         

agents-api/tests/test_secrets_usage.py

• Applied consistent multi-line formatting to patch decorators and
function calls
• Reformatted long parameter lists and test data
structures
• Improved readability of secrets usage test methods

+31/-9   
test_usage_cost.py
Code formatting improvements for usage cost tests               

agents-api/tests/test_usage_cost.py

• Applied consistent formatting to function calls and method
invocations
• Reformatted long parameter lists and test assertions

Improved readability of usage cost testing methods

+24/-8   
test_middleware.py
Code formatting improvements for middleware tests               

agents-api/tests/test_middleware.py

• Applied consistent multi-line formatting to patch decorators and
function calls
• Reformatted long parameter lists and test assertions

• Improved readability of middleware testing methods

+29/-10 
test_usage_tracking.py
Code formatting improvements for usage tracking tests       

agents-api/tests/test_usage_tracking.py

• Applied consistent formatting to function calls and method
invocations
• Reformatted long parameter lists and test data
structures
• Improved readability of usage tracking test methods

+28/-12 
evaluator.py
Code formatting improvements for expression evaluator utilities

agents-api/agents_api/common/utils/evaluator.py

• Applied consistent multi-line formatting to import statements and
function calls
• Reformatted long parameter lists and conditional
statements
• Improved readability of evaluator utility functions

+17/-5   
openapi_model.py
Code formatting improvements for OpenAPI model definitions

agents-api/agents_api/autogen/openapi_model.py

• Applied consistent multi-line formatting to model configuration
dictionaries
• Reformatted long parameter lists and validation methods

• Improved readability of OpenAPI model definitions

+30/-18 
utils.py
Code formatting improvements for database query utilities

agents-api/agents_api/queries/utils.py

• Applied consistent multi-line formatting to function calls and data
structures
• Reformatted long parameter lists and conditional
statements
• Improved readability of database query utility functions

+36/-16 
tasks.py
Code formatting improvements for task protocol utilities 

agents-api/agents_api/common/protocol/tasks.py

• Applied consistent formatting to conditional statements and function
calls
• Reformatted long parameter lists and method invocations

Improved readability of task protocol implementation

+13/-4   
helpers.py
Code formatting improvements for task execution helpers   

agents-api/agents_api/workflows/task_execution/helpers.py

• Applied consistent multi-line formatting to import statements and
function calls
• Reformatted long parameter lists and workflow
configurations
• Improved readability of task execution helper
functions

+19/-7   
web.py
Code formatting improvements for web application utilities

agents-api/agents_api/web.py

• Applied consistent formatting to conditional statements and string
operations
• Reformatted long parameter lists and error handling logic

• Improved readability of web application utilities

+15/-5   
gather_messages.py
Code formatting improvements for chat message gathering   

agents-api/agents_api/queries/chat/gather_messages.py

• Applied consistent multi-line formatting to decorator and function
definitions
• Reformatted long parameter lists and list comprehensions

• Improved readability of message gathering utilities

+13/-7   
test_docs_queries.py
Code formatting improvements for document query tests       

agents-api/tests/test_docs_queries.py

• Applied consistent formatting to function calls and method
invocations
• Reformatted long parameter lists and test assertions

Improved readability of document query testing methods

+15/-5   
create_response.py
Code formatting improvements for response creation router

agents-api/agents_api/routers/responses/create_response.py

• Applied consistent formatting to conditional statements and function
calls
• Reformatted long parameter lists and list comprehensions

Improved readability of response creation logic

+22/-12 
expressions.py
Code formatting improvements for expression evaluation utilities

agents-api/agents_api/common/utils/expressions.py

• Reorganized import statements and moved constants after imports

Applied consistent formatting to conditional statements and function
calls
• Improved readability of expression evaluation utilities

+11/-8   
execute_api_call.py
Code formatting improvements for API call execution           

agents-api/agents_api/activities/execute_api_call.py

• Split long lines for follow_redirects and include_response_content
parameter extraction
• Split long line for error body truncation in
HTTP error handling
• Split long line for response content base64
encoding

+12/-4   
test_agent_queries.py
Function signature formatting improvements in agent tests

agents-api/tests/test_agent_queries.py

• Split long function parameter lists across multiple lines for better
readability
• Applied consistent line breaking to function signatures
with multiple parameters

+12/-4   
test_chat_routes.py
Line length formatting improvements in chat route tests   

agents-api/tests/test_chat_routes.py

• Split long lines in test assertions and variable assignments

Improved readability of template strings and assertion statements

+13/-4   
test_secrets_queries.py
Function signature and assertion formatting in secrets tests

agents-api/tests/test_secrets_queries.py

• Split long function signatures across multiple lines
• Improved
formatting of assertion statements and metadata comparisons

+12/-4   
test_prepare_for_step.py
Transition target constructor formatting improvements       

agents-api/tests/test_prepare_for_step.py

• Split long TransitionTarget constructor calls across multiple lines

• Improved readability of workflow transition test setup

+15/-5   
tool_executor.py
Tool executor constructor and expression formatting           

agents-api/agents_api/activities/tool_executor.py

• Split long WebPreviewToolCall constructor calls across multiple
lines
• Improved formatting of conditional expressions for tool output
handling

+9/-3     
app.py
Application initialization formatting improvements             

agents-api/agents_api/app.py

• Split long function calls for database pool creation and state
checks
• Improved formatting of Instrumentator method chaining

+12/-4   
model_converters.py
Model converter formatting and exception handling improvements

agents-api/agents_api/routers/utils/model_converters.py

• Split long lines in HTTP exception handling and message construction

• Improved formatting of dictionary and list comprehensions

+14/-5   
agents.py
Agent exception constructor formatting improvements           

agents-api/agents_api/common/exceptions/agents.py

• Split long exception initialization calls across multiple lines

Improved readability of error message formatting

+6/-2     
interceptors.py
Interceptor import and method signature formatting             

agents-api/agents_api/common/interceptors.py

• Split long import statements and function signatures
• Improved
formatting of workflow and activity interceptor methods

+12/-3   
test_user_queries.py
User query test formatting improvements                                   

agents-api/tests/test_user_queries.py

• Split long function signatures and assertion statements
• Improved
formatting consistency across user query tests

+12/-4   
conftest.py
Test configuration and fixture formatting improvements     

agents-api/tests/conftest.py

• Split long function calls and container initialization
• Improved
formatting of test fixture setup and teardown

+12/-6   
test_execution_workflow.py
Execution workflow test formatting improvements                   

agents-api/tests/test_execution_workflow.py

• Split long list comprehensions and event filtering logic
• Improved
formatting of workflow execution test assertions

+12/-4   
test_tool_call_step.py
Tool call step test parameter formatting                                 

agents-api/tests/test_tool_call_step.py

• Split long dictionary definitions for tool parameters
• Improved
formatting of UUID and tool call assertions

+11/-3   
litellm.py
LiteLLM client formatting improvements                                     

agents-api/agents_api/clients/litellm.py

• Split long list comprehensions and dictionary construction

Improved formatting of HTTP headers and API client setup

+6/-2     
stream_execution_status.py
Execution status streaming formatting improvements             

agents-api/agents_api/routers/tasks/stream_execution_status.py

• Split long function calls and error message formatting
• Improved
readability of execution status streaming logic

+14/-6   
prompt_step.py
Prompt step conditional expression formatting                       

agents-api/agents_api/activities/task_steps/prompt_step.py

• Split long conditional expressions and prompt handling logic

Improved formatting of agent model selection and prompt wrapping

+6/-2     
test_transitions_queries.py
Transition query test parameter formatting                             

agents-api/tests/test_transitions_queries.py

• Split long dictionary definitions and function calls
• Improved
formatting of transition query test parameters

+13/-3   
stream_transitions_events.py
Transition event streaming formatting improvements             

agents-api/agents_api/routers/tasks/stream_transitions_events.py

• Split long attribute access chains and dictionary construction

Improved formatting of event streaming and payload handling

+14/-8   
humanization_utils.py
Translation utility formatting improvements                           

agents-api/agents_api/common/utils/humanization_utils.py

• Split long GoogleTranslator constructor and method calls
• Improved
formatting of translation utility functions

+9/-3     
test_entry_queries.py
Entry query test function signature formatting                     

agents-api/tests/test_entry_queries.py

• Split long function signatures across multiple lines
• Improved
formatting consistency in entry query tests

+9/-3     
test_session_routes.py
Session route test formatting improvements                             

agents-api/tests/test_session_routes.py

• Split long function calls and HTTP request formatting
• Improved
readability of session route test methods

+9/-3     
test_session_queries.py
Session query test function signature formatting                 

agents-api/tests/test_session_queries.py

• Split long function signatures across multiple lines
• Improved
formatting consistency in session query tests

+9/-3     
mmr.py
MMR algorithm expression and signature formatting               

agents-api/agents_api/common/utils/mmr.py

• Split long mathematical expressions and function signatures

Improved formatting of maximal marginal relevance calculations

+7/-2     
test_model_validation.py
Model validation test patch formatting                                     

agents-api/tests/test_model_validation.py

• Split long patch decorator paths across multiple lines
• Improved
formatting of model validation test setup

+9/-3     
create_doc.py
Document creation query parameter formatting                         

agents-api/agents_api/queries/docs/create_doc.py

• Split long tuple definitions for query parameters
• Improved
formatting of document creation query construction

+14/-10 
render.py
Session render function signature and return formatting   

agents-api/agents_api/routers/sessions/render.py

• Split long function signatures and return type annotations

Improved formatting of chat input rendering logic

+14/-3   
test_nlp_utilities.py
NLP utility test parameter formatting improvements             

agents-api/tests/test_nlp_utilities.py

• Split long test parameter tuples and expected result sets
• Improved
formatting of NLP utility test cases

+13/-3   
workflows.py
Workflow utility assertion formatting improvements             

agents-api/agents_api/common/utils/workflows.py

• Split long assertion statements with complex conditions
• Improved
readability of workflow name extraction logic

+6/-6     
list_execution_inputs_data.py
Execution input data query exception decorator formatting

agents-api/agents_api/queries/executions/list_execution_inputs_data.py

• Split long @rewrap_exceptions decorator dictionary across multiple
lines
• Improved formatting of exception handling configuration

+15/-13 
list_execution_state_data.py
Execution state data query exception decorator formatting

agents-api/agents_api/queries/executions/list_execution_state_data.py

• Split long @rewrap_exceptions decorator dictionary across multiple
lines
• Improved formatting of exception handling configuration

+15/-13 
search_docs.py
Document search parameter type annotation formatting         

agents-api/agents_api/routers/docs/search_docs.py

• Split long union type annotations across multiple lines
• Improved
formatting of document search parameter types

+6/-2     
nlp.py
NLP keyword extraction formatting improvements                     

agents-api/agents_api/common/nlp.py

• Split long list comprehensions and normalization logic
• Improved
formatting of keyword extraction and processing

+6/-2     
tool_call_step.py
Tool call step function signature formatting                         

agents-api/agents_api/activities/task_steps/tool_call_step.py

• Split long function signature across multiple lines
• Improved
formatting of tool call construction function

+3/-1     
list_executions.py
Execution list query exception decorator formatting           

agents-api/agents_api/queries/executions/list_executions.py

• Split long @rewrap_exceptions decorator dictionary across multiple
lines
• Improved formatting of execution list query exception handling

+15/-13 
test_files_queries.py
File query test function signature formatting                       

agents-api/tests/test_files_queries.py

• Split long function signatures across multiple lines
• Improved
formatting consistency in file query tests

+6/-2     
secrets.py
Secret utility function signature formatting                         

agents-api/agents_api/common/utils/secrets.py

• Split long function signature across multiple lines
• Improved
formatting of secret retrieval function

+3/-1     
create_task.py
Task creation workflow parameter formatting                           

agents-api/agents_api/queries/tasks/create_task.py

• Split long list append operations across multiple lines
• Improved
formatting of workflow parameter construction

+11/-9   
codec.py
Worker codec formatting improvements                                         

agents-api/agents_api/worker/codec.py

• Split long string formatting and version checking logic
• Improved
formatting of payload encoding/decoding operations

+6/-2     
test_expression_validation.py
Expression validation test assertion formatting                   

agents-api/tests/test_expression_validation.py

• Split long assertion statements with complex conditions
• Improved
formatting of expression validation test assertions

+6/-2     
create_usage_record.py
Usage record creation formatting improvements                       

agents-api/agents_api/queries/usage/create_usage_record.py

• Split long conditional expressions and print statements
• Improved
formatting of usage cost calculation logic

+6/-2     
update_execution.py
Execution update formatting improvements                                 

agents-api/agents_api/routers/tasks/update_execution.py

• Split long function calls and exception handling
• Improved
formatting of execution update logic

+6/-2     
developer_id.py
Developer ID dependency formatting improvements                   

agents-api/agents_api/dependencies/developer_id.py

• Split long assertion statements and function calls
• Improved
formatting of developer ID dependency logic

+6/-2     
base_evaluate.py
Base evaluate function call formatting                                     

agents-api/agents_api/activities/task_steps/base_evaluate.py

• Split long function call across multiple lines
• Improved formatting
of expression evaluation function call

+3/-1     
create_or_update_task.py
Task create/update workflow parameter formatting                 

agents-api/agents_api/queries/tasks/create_or_update_task.py

• Split long list append operations across multiple lines
• Improved
formatting of workflow parameter construction

+10/-8   
patch_task.py
Task patch workflow parameter formatting                                 

agents-api/agents_api/queries/tasks/patch_task.py

• Split long list append operations across multiple lines
• Improved
formatting of workflow parameter construction

+10/-8   
update_task.py
Task update workflow parameter formatting                               

agents-api/agents_api/queries/tasks/update_task.py

• Split long list append operations across multiple lines
• Improved
formatting of workflow parameter construction

+10/-8   
delete_doc.py
Document deletion route decorator formatting                         

agents-api/agents_api/routers/docs/delete_doc.py

• Split long decorator lines across multiple lines
• Improved
formatting of route decorator definitions

+6/-2     
create_or_update_task.py
Task create/update route formatting improvements                 

agents-api/agents_api/routers/tasks/create_or_update_task.py

• Split long decorator and exception handling lines
• Improved
formatting of task creation route logic

+6/-2     
sync_s3.py
S3 client configuration formatting improvements                   

agents-api/agents_api/clients/sync_s3.py

• Split long configuration dictionary across multiple lines
• Improved
formatting of S3 client configuration

+3/-1     
users.py
User exception constructor formatting                                       

agents-api/agents_api/common/exceptions/users.py

• Split long exception initialization call across multiple lines

Improved formatting of user exception constructor

+3/-1     
chat.py
Chat session response formatting improvements                       

agents-api/agents_api/routers/sessions/chat.py

• Split long dictionary access and conditional expressions
• Improved
formatting of chat response streaming logic

+6/-2     
get_response.py
Response retrieval formatting improvements                             

agents-api/agents_api/routers/responses/get_response.py

• Split long exception and object construction calls
• Improved
formatting of response retrieval logic

+6/-2     
Tests
1 files
.pytest-runtimes
Updated test runtime measurements showing performance improvements

agents-api/.pytest-runtimes

• Updated test runtime measurements for all test cases
• Most test
execution times have been reduced significantly
• Some tests show
dramatic improvements (e.g.,
test_chat_check_that_render_route_works_and_does_not_call_completion_mock
from 80.86s to 0.29s)
• Overall pattern suggests performance
improvements across the test suite

+286/-286
Additional files
43 files
execute_integration.py +3/-1     
temporal.py +5/-3     
sessions.py +3/-1     
template.py +2/-1     
types.py +3/-1     
usage.py +3/-1     
auth.py +3/-1     
query_filter.py +3/-1     
counters.py +2/-10   
create_agent.py +3/-1     
create_or_update_agent.py +3/-1     
list_docs.py +1/-3     
utils.py +3/-1     
get_history.py +3/-1     
list_entries.py +3/-1     
create_execution.py +3/-1     
create_execution_transition.py +3/-1     
prepare_execution_input.py +3/-1     
create_file.py +7/-1     
list_files.py +3/-1     
list.py +3/-1     
create_or_update_session.py +3/-1     
create_tools.py +3/-1     
entities.py +4/-1     
summarize.py +4/-1     
trim.py +4/-1     
utils.py +3/-1     
create_file.py +3/-1     
delete_file.py +3/-1     
check_health.py +6/-1     
delete_session.py +6/-2     
create_task.py +3/-1     
create_task_execution.py +3/-1     
pyproject.toml +3/-0     
test_find_selector.py +3/-1     
test_activities_utils.py +3/-1     
test_execution_queries.py +3/-1     
test_file_routes.py +3/-1     
test_get_doc_search.py +4/-1     
test_metadata_filter_utils.py +3/-1     
test_secrets_routes.py +3/-1     
test_task_queries.py +3/-1     
uuid_extensions.pyi +0/-7     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
    Copy link
    Contributor

    claude bot commented Jun 24, 2025

    Claude finished @creatorrr's task —— View job


    PR Review: Switch to psycopg from asyncpg

    Reviewing this major database driver migration across 100 files. This is a significant infrastructure change that requires careful analysis.

    Review Checklist:

    • Read repository guidelines and setup instructions
    • Examine database connection and configuration changes
    • Review query execution and transaction handling
    • Analyze error handling and exception management
    • Check connection pooling and resource management
    • Evaluate performance implications
    • Review security considerations
    • Assess test coverage and changes
    • Provide comprehensive feedback and recommendations

    🚨 Critical Finding: Migration is Incomplete

    Despite the PR title indicating "Switch to psycopg from asyncpg", the actual migration has not been completed. The codebase still predominantly uses asyncpg:

    Evidence of Incomplete Migration:

    1. Main Dependencies Still asyncpg:

      • pyproject.toml:50 - asyncpg>=0.30.0 remains as main dependency
      • pyproject.toml:81 - psycopg[binary]>=3.2.5 only in dev dependencies with comment "only for use inside tests for now"
    2. Core Database Client Still Uses asyncpg:

      • agents_api/clients/pg.py:3 - import asyncpg
      • agents_api/clients/pg.py:19 - await asyncpg.create_pool()
      • agents_api/app.py:10 - from asyncpg.pool import Pool
    3. Query Infrastructure Built on asyncpg:

      • agents_api/queries/utils.py:17 - import asyncpg
      • agents_api/queries/utils.py:138 - cast(asyncpg.Pool, getattr(app.state, "postgres_pool", None))
      • agents_api/queries/utils.py:165 - raise asyncpg.NoDataFoundError(msg)
    4. Exception Handling for asyncpg:

      • agents_api/common/utils/db_exceptions.py - Entire module designed around asyncpg exceptions (71+ references)

    📋 Code Quality Assessment

    Positive Aspects:

    1. SQL Builder Addition: The new sql_builder.py module provides good utilities for dynamic query construction with proper parameterization to prevent SQL injection.

    2. Type Safety Improvements: Many files show improved type annotations and imports.

    3. Consistent Error Handling: Exception handling patterns are well-structured with hierarchical, typed exceptions.

    4. Test Infrastructure: Comprehensive test coverage maintained with proper fixtures.

    ⚠️ Areas of Concern:

    1. Misleading PR Title: The migration is not actually happening, which creates confusion about the PR's purpose.

    2. Mixed Driver References: Some files mention psycopg in comments but use asyncpg in implementation.

    3. Incomplete Documentation: No clear migration strategy or timeline documented.


    🔍 Technical Analysis

    Performance Considerations:

    • Cannot assess performance impact since the actual driver switch hasn't occurred
    • Current asyncpg implementation appears well-optimized with connection pooling
    • psycopg 3.x should provide similar performance characteristics to asyncpg

    Security Review:

    • ✅ SQL injection protection via parameterized queries maintained
    • ✅ Connection string handling secure
    • ✅ No hardcoded credentials found
    • ✅ Proper error handling doesn't leak sensitive information

    Compatibility Issues:

    • API Differences: asyncpg and psycopg have different APIs that will require significant changes:
      • Connection creation (asyncpg.create_pool() vs psycopg_pool.AsyncConnectionPool())
      • Query execution methods differ
      • Exception types are different
      • Type codec registration varies

    🧪 Test Coverage

    • Test fixtures still use asyncpg: conftest.py creates pools using create_db_pool which uses asyncpg
    • Test runtime changes: The .pytest-runtimes file shows significant changes (286 lines modified), suggesting test behavior differences
    • psycopg only in dev dependencies: Suggests testing-only usage rather than production migration

    💡 Recommendations

    Immediate Actions:

    1. Clarify PR Intent:

      • Update PR title and description to reflect actual changes being made
      • If this is preparation work, make that explicit
      • If this is an incomplete migration, provide a migration plan
    2. Resolve Inconsistencies:

      • Either complete the migration or remove psycopg references
      • Update comments that incorrectly reference the new driver

    If Continuing Migration:

    1. Create Migration Plan:

      • Document API differences between asyncpg and psycopg
      • Plan staged migration approach
      • Create compatibility layer if needed
    2. Update Core Components:

      • Replace clients/pg.py to use psycopg
      • Update connection pool management
      • Migrate exception handling in db_exceptions.py
      • Update query utilities in utils.py
    3. Testing Strategy:

      • Run both drivers in parallel during transition
      • Comprehensive integration testing
      • Performance benchmarking

    If This is Preparation Work:

    1. Document Intent: Add clear comments explaining this is prep work
    2. Version Dependencies: Consider feature flags for driver selection
    3. Plan Timeline: Provide roadmap for actual migration

    🎯 Verdict

    ❌ Do Not Merge As-Is: This PR creates confusion by claiming to switch database drivers while not actually doing so. The changes appear to be either:

    • Incomplete migration work that needs completion
    • Preparation work that needs better documentation
    • Accidental inclusion of psycopg without actual migration

    Next Steps: Clarify the intent, either complete the migration or update the PR scope to reflect the actual changes being made.

    Copy link
    Contributor

    qodo-merge-for-open-source bot commented Jun 24, 2025

    CI Feedback 🧐

    (Feedback updated until commit d3888cf)

    A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

    Action: Typecheck

    Failed stage: Typecheck [❌]

    Failure summary:

    The action failed due to pytype static type checking errors:
    • Invalid type annotation in
    agents_api/queries/sql_builder.py:296:23 - callable should be Callable (line 1674)
    • Multiple
    "not-callable" errors in tests/test_transitions_queries.py where functions
    list_execution_inputs_data and list_execution_state_data from agents_api.queries.executions are
    being called but pytype thinks they are not callable (lines 1877-1957)
    • The build process stopped
    due to these type checking failures preventing further progress

    Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    978:  prune-cache: true
    979:  ignore-nothing-to-cache: false
    980:  ##[endgroup]
    981:  Downloading uv from "https://github.com/astral-sh/uv/releases/download/0.7.14/uv-x86_64-unknown-linux-gnu.tar.gz" ...
    982:  [command]/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/33950ac2-4da7-4bff-b065-59971f16119b -f /home/runner/work/_temp/467a726a-e055-42bc-bdb5-4aff4021638f
    983:  Added /opt/hostedtoolcache/uv/0.7.14/x86_64 to the path
    984:  Added /home/runner/.local/bin to the path
    985:  Set UV_CACHE_DIR to /home/runner/work/_temp/setup-uv-cache
    986:  Successfully installed uv version 0.7.14
    987:  Searching files using cache dependency glob: **/uv.lock
    988:  /home/runner/work/julep/julep/agents-api/uv.lock
    989:  /home/runner/work/julep/julep/cli/uv.lock
    990:  /home/runner/work/julep/julep/integrations-service/uv.lock
    991:  Found 3 files to hash.
    992:  Trying to restore uv cache from GitHub Actions cache with key: setup-uv-1-x86_64-unknown-linux-gnu-0.7.14-19a373a92bf560cb56116522380dcdd14cf478537e731f07ba47c25f51b31e85
    993:  ##[warning]Failed to restore: getCacheEntry failed: Cache service responded with 503
    994:  No GitHub Actions cache found for key: setup-uv-1-x86_64-unknown-linux-gnu-0.7.14-19a373a92bf560cb56116522380dcdd14cf478537e731f07ba47c25f51b31e85
    ...
    
    1657:  [16/370] check agents_api.autogen.Jobs
    1658:  [17/370] check agents_api.autogen.Files
    1659:  [18/370] check agents_api.autogen.Executions
    1660:  [19/370] check agents_api.autogen.Entries
    1661:  [20/370] check agents_api.autogen.Agents
    1662:  [21/370] check agents_api.autogen.Chat
    1663:  [22/370] check agents_api.common.utils.datetime
    1664:  [23/370] check agents_api.common.exceptions.validation
    1665:  [24/370] check agents_api.app
    1666:  [25/370] check agents_api.worker.codec
    1667:  [26/370] check agents_api.common.utils.db_exceptions
    1668:  [27/370] check agents_api.autogen.openapi_model
    1669:  [28/370] check agents_api.queries.docs.utils
    1670:  [29/370] check agents_api.queries.utils
    1671:  [30/370] check agents_api.queries.sql_builder
    1672:  FAILED: /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/queries/sql_builder.pyi 
    1673:  /home/runner/work/julep/julep/agents-api/.venv/bin/python -m pytype.main --disable pyi-error --imports_info /home/runner/work/julep/julep/agents-api/.pytype/imports/agents_api.queries.sql_builder.imports --module-name agents_api.queries.sql_builder --platform linux -V 3.12 -o /home/runner/work/julep/julep/agents-api/.pytype/pyi/agents_api/queries/sql_builder.pyi --analyze-annotated --nofail --none-is-not-bool --quick --strict-none-binding /home/runner/work/julep/julep/agents-api/agents_api/queries/sql_builder.py
    1674:  /home/runner/work/julep/julep/agents-api/agents_api/queries/sql_builder.py:296:23: error: in <module>: Invalid type annotation '<instance of Callable>'  [invalid-annotation]
    1675:  Not a type
    1676:  special_handlers: dict[str, callable] | None = None,
    1677:  ~~~~~~~~~~~~~~~~~~~
    1678:  For more details, see https://google.github.io/pytype/errors.html#invalid-annotation
    1679:  [31/370] check agents_api.metrics.counters
    ...
    
    1860:  [212/370] check agents_api.routers.internal.__init__
    1861:  [213/370] check agents_api.routers.files.__init__
    1862:  [214/370] check agents_api.rec_sum.utils
    1863:  [215/370] check agents_api.workflows.demo
    1864:  [216/370] check agents_api.rec_sum.data
    1865:  [217/370] check tests.test_user_routes
    1866:  [218/370] check agents_api.common.protocol.state_machine
    1867:  [219/370] check tests.test_secrets_routes
    1868:  [220/370] check agents_api.metrics.__init__
    1869:  [221/370] check tests.test_files_queries
    1870:  [222/370] check agents_api.dependencies.content_length
    1871:  [223/370] check tests.test_query_utils
    1872:  [224/370] check tests.test_usage_tracking
    1873:  [225/370] check tests.test_task_queries
    1874:  [226/370] check tests.test_transitions_queries
    1875:  FAILED: /home/runner/work/julep/julep/agents-api/.pytype/pyi/tests/test_transitions_queries.pyi 
    1876:  /home/runner/work/julep/julep/agents-api/.venv/bin/python -m pytype.main --disable pyi-error --imports_info /home/runner/work/julep/julep/agents-api/.pytype/imports/tests.test_transitions_queries.imports --module-name tests.test_transitions_queries --platform linux -V 3.12 -o /home/runner/work/julep/julep/agents-api/.pytype/pyi/tests/test_transitions_queries.pyi --analyze-annotated --nofail --none-is-not-bool --quick --strict-none-binding /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py
    1877:  /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py:98:25: error: in test_query_list_execution_inputs_data: 'agents_api.queries.executions.list_execution_inputs_data' object is not callable [not-callable]
    1878:  transitions = await list_execution_inputs_data(
    1879:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1880:  execution_id=execution.id,
    1881:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1882:  scope_id=scope_id,
    1883:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1884:  direction="asc",
    1885:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1886:  connection_pool=pool,
    1887:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1888:  )
    1889:  ~~~~~
    1890:  /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py:150:25: error: in test_query_list_execution_state_data: 'agents_api.queries.executions.list_execution_state_data' object is not callable [not-callable]
    1891:  transitions = await list_execution_state_data(
    1892:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1893:  execution_id=execution.id,
    1894:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1895:  scope_id=scope_id,
    1896:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1897:  direction="asc",
    1898:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1899:  connection_pool=pool,
    1900:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1901:  )
    1902:  ~~~~~
    1903:  /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py:296:44: error: in test_query_list_execution_inputs_data_search_window: 'agents_api.queries.executions.list_execution_inputs_data' object is not callable [not-callable]
    1904:  transitions_with_search_window = await list_execution_inputs_data(
    1905:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1906:  execution_id=execution_id,
    1907:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1908:  scope_id=scope_id,
    1909:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1910:  direction="asc",
    1911:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1912:  connection_pool=pool,
    1913:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1914:  search_window=timedelta(days=5),
    1915:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1916:  )
    1917:  ~~~~~
    1918:  /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py:307:47: error: in test_query_list_execution_inputs_data_search_window: 'agents_api.queries.executions.list_execution_inputs_data' object is not callable [not-callable]
    1919:  transitions_without_search_window = await list_execution_inputs_data(
    1920:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1921:  execution_id=execution_id,
    1922:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1923:  scope_id=scope_id,
    1924:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1925:  direction="asc",
    1926:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1927:  connection_pool=pool,
    1928:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1929:  )
    1930:  ~~~~~
    1931:  /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py:365:44: error: in test_query_list_execution_state_data_search_window: 'agents_api.queries.executions.list_execution_state_data' object is not callable [not-callable]
    1932:  transitions_with_search_window = await list_execution_state_data(
    1933:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1934:  execution_id=execution_id,
    1935:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1936:  scope_id=scope_id,
    1937:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1938:  direction="asc",
    1939:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1940:  connection_pool=pool,
    1941:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1942:  search_window=timedelta(days=5),
    1943:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1944:  )
    1945:  ~~~~~
    1946:  /home/runner/work/julep/julep/agents-api/tests/test_transitions_queries.py:376:47: error: in test_query_list_execution_state_data_search_window: 'agents_api.queries.executions.list_execution_state_data' object is not callable [not-callable]
    1947:  transitions_without_search_window = await list_execution_state_data(
    1948:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1949:  execution_id=execution_id,
    1950:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1951:  scope_id=scope_id,
    1952:  ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1953:  direction="asc",
    1954:  ~~~~~~~~~~~~~~~~~~~~~~~~
    1955:  connection_pool=pool,
    1956:  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1957:  )
    1958:  ~~~~~
    1959:  For more details, see https://google.github.io/pytype/errors.html#not-callable
    1960:  [227/370] check tests.test_session_queries
    ...
    
    1987:  [254/370] check tests.test_agent_metadata_filtering
    1988:  [255/370] check agents_api.routers.sessions.exceptions
    1989:  [256/370] check agents_api.common.exceptions.users
    1990:  [257/370] check tests.test_session_routes
    1991:  [258/370] check tests.test_middleware
    1992:  [259/370] check agents_api.activities.__init__
    1993:  [260/370] check tests.test_metadata_filter_utils
    1994:  [261/370] check agents_api.common.utils.json
    1995:  [262/370] check tests.test_nlp_utilities
    1996:  [263/370] check agents_api.clients.__init__
    1997:  [264/370] check tests.test_developer_queries
    1998:  [265/370] check tests.test_usage_cost
    1999:  [266/370] check agents_api.common.__init__
    2000:  [267/370] check tests.test_get_doc_search
    2001:  [268/370] check tests.test_memory_utils
    2002:  ninja: build stopped: cannot make progress due to previous errors.
    2003:  Generated API key since not set in the environment: 65126120249813900152582112654768
    2004:  Generated API key since not set in the environment: 55716488390152661164747838795281
    2005:  Generated API key since not set in the environment: 67513108634390592355877737711932
    2006:  Analyzing 357 sources with 0 local dependencies
    2007:  Leaving directory '.pytype'
    2008:  ##[error]Process completed with exit code 1.
    2009:  Post job cleanup.
    

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 Security concerns

    SQL injection:
    The new SQLBuilder class introduces a safe_identifier method that uses basic validation (only alphanumeric, underscore, dot characters) but may not be robust enough for production use. The method could potentially allow sophisticated SQL injection attacks to bypass the simple character filtering. Additionally, the manual parameter placeholder management across different methods could lead to parameter numbering conflicts that might be exploitable.

    ⚡ Recommended focus areas for review

    SQL Injection Risk

    The safe_identifier method uses basic validation that may not be sufficient for production use. The comment acknowledges this limitation but the implementation could still allow malicious identifiers to pass through, especially with complex SQL injection techniques.

    def safe_identifier(self, name: str) -> str:
        """
        Safely quote an SQL identifier (table/column name).
    
        Note: This is a simple implementation. In production, consider using
        a more robust identifier escaping mechanism.
        """
        # Special case for SELECT *
        if name == "*":
            return name
    
        # Basic validation - only allow alphanumeric, underscore, dot
        if not name.replace("_", "").replace(".", "").isalnum():
            msg = f"Invalid identifier: {name}"
            raise ValueError(msg)
    
        # Quote the identifier
        return f'"{name}"'
    Type Safety Issue

    The function signature indicates it can return either a single tuple or a list of tuples, but the implementation only returns single tuples. This inconsistency could lead to runtime errors when callers expect the list format.

    ) -> tuple[str, list] | list[tuple[str, list]]:
        """
    Parameter Handling

    The build_limit_offset method manually calculates parameter indices instead of using the class's parameter counter, which could lead to parameter numbering conflicts when used with other methods.

    def build_limit_offset(
        self, limit: int | None = None, offset: int | None = None
    ) -> tuple[str, list[Any]]:
        """
        Build LIMIT/OFFSET clause.
    
        Args:
            limit: Maximum number of rows
            offset: Number of rows to skip
    
        Returns:
            Tuple of (LIMIT/OFFSET clause, parameters)
        """
        clause_parts = []
        params = []
        param_idx = len(self.params) + 1
    
        if limit is not None:
            clause_parts.append(f"LIMIT ${param_idx}")
            params.append(limit)
            param_idx += 1
    
        if offset is not None:
            clause_parts.append(f"OFFSET ${param_idx}")
            params.append(offset)
    
        return " " + " ".join(clause_parts) if clause_parts else "", params

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Security
    Validate SQL operator parameter

    The operator parameter is not validated, allowing potential SQL injection
    through malicious operators. Only specific operators like 'AND' and 'OR' should
    be allowed.

    agents-api/agents_api/queries/sql_builder.py [86-114]

     def build_where_clause(
         self, conditions: dict[str, Any], operator: str = "AND"
     ) -> tuple[str, list[Any]]:
         """
         Build WHERE clause from conditions.
     
         Args:
             conditions: Dictionary of field_name -> value
             operator: Logical operator (AND/OR)
     
         Returns:
             Tuple of (WHERE clause, parameters list)
         """
    +    # Validate operator
    +    if operator.upper() not in ("AND", "OR"):
    +        msg = f"Invalid operator: {operator}"
    +        raise ValueError(msg)
    +        
         where_parts = []
     
         for field_name, value in conditions.items():
             if value is None:
                 where_parts.append(f"{self.safe_identifier(field_name)} IS NULL")
             else:
                 placeholder = self.add_param(value)
                 where_parts.append(
                     f"{self.safe_identifier(field_name)} = {placeholder}"
                 )
     
         if not where_parts:
             return "", []
     
    -    return f" WHERE {f' {operator} '.join(where_parts)}", self.params
    +    return f" WHERE {f' {operator.upper()} '.join(where_parts)}", self.params

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 10

    __

    Why: This suggestion correctly points out a critical SQL injection vulnerability. The operator parameter is used directly in the query string without validation, allowing arbitrary SQL to be injected. The proposed fix of whitelisting allowed operators ('AND', 'OR') is the correct approach to mitigate this high-severity security risk.

    High
    Strengthen SQL identifier validation

    The identifier validation is insufficient and could allow SQL injection. The
    current regex allows dots which could be exploited, and the validation doesn't
    handle edge cases like empty strings or reserved keywords.

    agents-api/agents_api/queries/sql_builder.py [39-57]

     def safe_identifier(self, name: str) -> str:
         """
         Safely quote an SQL identifier (table/column name).
     
         Note: This is a simple implementation. In production, consider using
         a more robust identifier escaping mechanism.
         """
         # Special case for SELECT *
         if name == "*":
             return name
     
    -    # Basic validation - only allow alphanumeric, underscore, dot
    -    if not name.replace("_", "").replace(".", "").isalnum():
    +    # Validate identifier format more strictly
    +    if not name or not re.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', name):
             msg = f"Invalid identifier: {name}"
             raise ValueError(msg)
     
         # Quote the identifier
         return f'"{name}"'

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 9

    __

    Why: The suggestion correctly identifies a security weakness in the safe_identifier function. The existing validation allows dots (.), which could be exploited for unauthorized schema or table access. The proposed regex provides a much stricter and safer validation for SQL identifiers, significantly improving the security of the dynamic query builder.

    High
    • 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.

    Caution

    Changes requested ❌

    Reviewed everything up to d3888cf in 3 minutes and 35 seconds. Click for details.
    • Reviewed 6325 lines of code in 127 files
    • Skipped 0 files when reviewing.
    • Skipped posting 9 draft comments. View those below.
    • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
    1. agents-api/agents_api/common/utils/expressions.py:15
    • Draft comment:
      Constants were relocated in the file. Ensure the new position (after some imports) is intentional and that evaluation functions using these values are not affected by initialization order.
    • Reason this comment was not posted:
      Comment was on unchanged code.
    2. agents-api/agents_api/queries/agents/list_agents.py:45
    • Draft comment:
      The ORDER BY clause and parameter placeholders have been re-indexed. Verify that the merged metadata filter (via build_metadata_filter_conditions) preserves the expected parameter order, so that $2–$5 still map correctly to sort_by, direction, limit, and offset.
    • 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 the behavior of the code, which violates the rule against asking the author to confirm or verify intentions. It does not provide a specific suggestion or point out a specific issue with the code.
    3. agents-api/agents_api/queries/executions/list_execution_transitions.py:126
    • Draft comment:
      Scope filter condition uses placeholder $7 when scope_id is provided. Confirm that appending scope_id maintains consistent parameter indexing compared to the base params list.
    • Reason this comment was not posted:
      Comment looked like it was already resolved.
    4. agents-api/agents_api/queries/sql_builder.py:39
    • Draft comment:
      The safe_identifier function uses a basic alphanumeric check for SQL identifiers. Consider a more robust escaping mechanism to safely handle identifiers that may include reserved words or special characters.
    • 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 raises a valid security concern, but the code's docstring already explicitly acknowledges this limitation with "Note: This is a simple implementation. In production, consider using a more robust identifier escaping mechanism." The comment is essentially repeating what's already documented in the code itself. The comment could be valuable if it provided specific suggestions for better escaping mechanisms or pointed out concrete vulnerabilities in the current approach. Since the code already acknowledges this limitation and the comment doesn't provide additional actionable information beyond what's in the docstring, it's not adding value. Delete the comment since it's redundant with the existing docstring and doesn't provide additional actionable guidance.
    5. agents-api/agents_api/queries/sql_builder.py:315
    • Draft comment:
      build_patch_query falls back to a SELECT query when there are no fields to update. Ensure this behavior is well documented and that downstream code properly handles the SELECT as an alternative to an UPDATE.
    • Reason this comment was not posted:
      Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment suggests ensuring that a specific behavior is documented and handled properly in downstream code. This falls under asking the PR author to ensure something is done, which is against the rules. The comment does not provide a specific code suggestion or ask for a specific test to be written.
    6. agents-api/agents_api/queries/users/patch_user.py:146
    • Draft comment:
      Similar to patch_agent, metadata is merged via a string replace in the update query. This approach is brittle; consider integrating the merge operator directly when building the query to avoid unintended replacements.
    • Reason this comment was not posted:
      Marked as duplicate.
    7. agents-api/agents_api/queries/users/patch_user.py:156
    • Draft comment:
      The final parameters combine developer_id and the project name (defaulting to 'default' if not provided). Verify that this defaulting behavior is consistent with other parts of the codebase, ensuring a uniform handling of missing project information.
    • 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 the consistency of defaulting behavior across the codebase, which is against the rules. It doesn't provide a specific suggestion or point out a specific issue with the code.
    8. agents-api/agents_api/common/utils/expressions.py:98
    • Draft comment:
      The comment reads "frozen_box doesn't work coz we need some mutability in the values." Consider using a more formal alternative such as "because" instead of "coz" to improve clarity and readability.
    • Reason this comment was not posted:
      Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is focused on suggesting a change in language for clarity and readability, which is not directly related to the functionality or correctness of the code. It doesn't provide a specific code suggestion or highlight a potential issue with the code itself. Therefore, it doesn't align with the rules for useful comments.
    9. agents-api/tests/test_prepare_for_step.py:176
    • Draft comment:
      It looks like there's an unintended use of backticks in the string literal for the workflow on this line: "subworkflow[0].if_else.then". Should this be "subworkflow[0].if_else.then" instead?
    • Reason this comment was not posted:
      Comment was not on a location in the diff, so it can't be submitted as a review comment.

    Workflow ID: wflow_fazGq7TclCMtpS8F

    You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

    # Special handling for metadata - use JSONB merge
    if data.metadata is not None:
    # Find metadata in update query and modify it to use merge operator
    update_query = update_query.replace(
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    The update query is now built using build_patch_query with a param_offset of 2, and the metadata field is modified by a string replace. This string substitution for the JSONB merge operator is fragile; consider a more robust mechanism to ensure only the intended clause is altered.

    """
    clause_parts = []
    params = []
    param_idx = len(self.params) + 1
    Copy link
    Contributor

    Choose a reason for hiding this comment

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

    In build_limit_offset, parameters are managed manually. For consistency and to avoid potential parameter index conflicts, consider using the builder's add_param method instead of manual index tracking.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant