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

fix(agents-api): Fix sessions updated_at precision issue #1012

Merged
merged 3 commits into from
Jan 3, 2025

Conversation

HamadaSalhab
Copy link
Contributor

@HamadaSalhab HamadaSalhab commented Jan 3, 2025

PR Type

Bug fix


Description

  • Fix precision issue for updated_at field in session data.

  • Normalize updated_at field by dividing by 1,000,000.

  • Apply precision fix across multiple session-related models.

  • Ensure consistent handling of updated_at in transformations.


Changes walkthrough 📝

Relevant files
Bug fix
prepare_chat_context.py
Normalize `updated_at` field in chat context                         

agents-api/agents_api/models/chat/prepare_chat_context.py

  • Added normalization for updated_at field in session data.
  • Divides updated_at by 1,000,000 during transformation.
  • +1/-0     
    get_session.py
    Normalize `updated_at` field in get_session                           

    agents-api/agents_api/models/session/get_session.py

  • Added transformation to normalize updated_at field.
  • Divides updated_at by 1,000,000 during session retrieval.
  • +8/-1     
    prepare_session_data.py
    Normalize `updated_at` field in prepare_session_data         

    agents-api/agents_api/models/session/prepare_session_data.py

  • Added normalization for updated_at field in session data.
  • Divides updated_at by 1,000,000 during transformation.
  • +1/-0     
    update_session.py
    Normalize `updated_at` field in update_session                     

    agents-api/agents_api/models/session/update_session.py

  • Fixed precision for updated_at field in session updates.
  • Divides updated_at by 1,000,000 during transformation.
  • +1/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information


    Important

    Fix updated_at precision issue in session handling by dividing timestamp by 1,000,000 across multiple functions.

    • Behavior:
      • Fix updated_at precision by dividing by 1,000,000 in prepare_chat_context.py, get_session.py, prepare_session_data.py, and update_session.py.
    • Functions:
      • prepare_chat_context: Adjusts updated_at in make_session call.
      • get_session: Applies transformation to updated_at in wrap_in_class.
      • prepare_session_data: Modifies updated_at in make_session call.
      • update_session: Adjusts updated_at in transformation lambda.
    • Misc:
      • Minor refactoring in execute_system.py to handle session operations.

    This description was created by Ellipsis for de88a33. 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.

    👍 Looks good to me! Reviewed everything up to f8514a2 in 12 seconds

    More details
    • Looked at 60 lines of code in 4 files
    • Skipped 0 files when reviewing.
    • Skipped posting 1 drafted comments based on config settings.
    1. agents-api/agents_api/models/chat/prepare_chat_context.py:40
    • Draft comment:
      Consider encapsulating the updated_at division logic into a utility function to promote reusability and reduce redundancy across the codebase.
    • Reason this comment was not posted:
      Confidence changes required: 50%
      The PR addresses a precision issue with the updated_at field by dividing it by 1,000,000. This change is consistent across multiple files, ensuring uniformity. However, the division operation is repeated in several places, which could lead to maintenance challenges if the logic needs to change in the future. It would be better to encapsulate this logic in a utility function to promote reusability and reduce redundancy.

    Workflow ID: wflow_19pVALV7SyxTLG5m


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

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Data Loss

    The division by 1,000,000 could potentially cause loss of precision for very small timestamp values. Consider validating that all timestamp values are large enough to maintain required precision after division.

    "updated_at": d.pop("updated_at")[0] / (1000000.0),
    Error Handling

    Division operation could potentially raise ZeroDivisionError or TypeError if updated_at is None or 0. Consider adding validation or error handling.

    updated_at=d["session"].pop("updated_at") / (1000000.0),

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add type validation before performing numerical operations to prevent type errors

    Add validation to ensure updated_at exists and is a valid number before performing
    division.

    agents-api/agents_api/models/session/get_session.py [34]

    -"updated_at": d.pop("updated_at") / (1000000.0),
    +"updated_at": d.pop("updated_at") / (1000000.0) if isinstance(d.get("updated_at"), (int, float)) else None,
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion adds critical type validation before numerical operations, which can prevent runtime errors and ensure data integrity when processing the updated_at field.

    8
    Add null check before performing division operation to prevent potential runtime errors

    Add error handling to ensure updated_at is not None before division to prevent
    potential runtime errors.

    agents-api/agents_api/models/session/update_session.py [48]

    -"updated_at": d.pop("updated_at")[0] / (1000000.0),
    +"updated_at": d.pop("updated_at")[0] / (1000000.0) if d.get("updated_at") else None,
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The suggestion adds important error handling to prevent potential runtime errors when 'updated_at' is missing, which is a valid defensive programming practice for data processing.

    7
    Add defensive programming to handle missing dictionary keys safely

    Add error handling to ensure updated_at exists in the session data before attempting
    to pop and divide it.

    agents-api/agents_api/models/chat/prepare_chat_context.py [40]

    -updated_at=d["session"].pop("updated_at") / (1000000.0),
    +updated_at=d["session"].pop("updated_at", 0) / (1000000.0) if "updated_at" in d["session"] else None,
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: The suggestion adds robust error handling for missing dictionary keys, which is crucial for preventing KeyError exceptions when processing session data.

    7

    Copy link
    Contributor

    qodo-merge-pro-for-open-source bot commented Jan 3, 2025

    CI Failure Feedback 🧐

    (Checks updated until commit edfcdf2)

    Action: Test

    Failed stage: Run tests [❌]

    Failed test name: test_execution_workflow

    Failure summary:

    The action failed due to two workflow tests failing:

  • test_execution_workflow:24 workflow: evaluate step single
  • test_execution_workflow:63 workflow: evaluate step multiple

    Both tests failed with the same error: AttributeError: 'NoneType' object has no attribute 'encode'.
    This occurred in the transition_step activity when trying to normalize header values, indicating a
    null value was passed where a string was expected.

  • Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    1122:  PASS  test_agent_queries:51 model: create or update agent                    3%
    1123:  PASS  test_agent_queries:66 model: get agent not exists                      4%
    1124:  PASS  test_agent_queries:74 model: get agent exists                          5%
    1125:  PASS  test_agent_queries:82 model: delete agent                              5%
    1126:  PASS  test_agent_queries:103 model: update agent                             6%
    1127:  PASS  test_agent_queries:130 model: patch agent                              7%
    1128:  PASS  test_agent_queries:156 model: list agents                              7%
    1129:  INFO:httpx:HTTP Request: POST http://testserver/agents "HTTP/1.1 403 Forbidden"
    1130:  PASS  test_agent_routes:9 route: unauthorized should fail                    8%
    ...
    
    1185:  INFO:httpx:HTTP Request: GET http://testserver/agents/cb249cb8-d5f5-426a-9be9-7373b3a1a138/docs "HTTP/1.1 200 OK"
    1186:  PASS  test_docs_routes:123 route: list agent docs                           29%
    1187:  INFO:httpx:HTTP Request: GET http://testserver/users/f934de34-ff4e-4fc7-beea-020c420c1463/docs?metadata_filter=%7B%27test%27%3A%20%27test%27%7D "HTTP/1.1 200 OK"
    1188:  PASS  test_docs_routes:137 route: list user docs with metadata filter       30%
    1189:  INFO:httpx:HTTP Request: GET http://testserver/agents/cb249cb8-d5f5-426a-9be9-7373b3a1a138/docs?metadata_filter=%7B%27test%27%3A%20%27test%27%7D "HTTP/1.1 200 OK"
    1190:  PASS  test_docs_routes:154 route: list agent docs with metadata filter      30%
    1191:  INFO:httpx:HTTP Request: POST http://testserver/agents/cb249cb8-d5f5-426a-9be9-7373b3a1a138/search "HTTP/1.1 200 OK"
    1192:  PASS  test_docs_routes:172 route: search agent docs                         31%
    1193:  SKIP  test_docs_routes:195 route: search user docs    Fails randomly on CI  32%
    ...
    
    1203:  PASS  test_execution_queries:31 model: create execution                     37%
    1204:  PASS  test_execution_queries:53 model: get execution                        38%
    1205:  PASS  test_execution_queries:65 model: lookup temporal id                   39%
    1206:  PASS  test_execution_queries:77 model: list executions                      39%
    1207:  PASS  test_execution_queries:95 model: count executions                     40%
    1208:  PASS  test_execution_queries:112 model: create execution transition         41%
    1209:  PASS  test_execution_queries:131 model: create execution transition with    41%
    1210:  execution update                              
    1211:  ERROR:temporalio.workflow:Error in transition: Activity task failed ({'attempt': 1, 'namespace': 'default', 'run_id': '88711add-62cb-446b-844d-1eac5c3d4aa7', 'task_queue': 'julep-task-queue', 'workflow_id': 'ccc0941b-0444-4468-870d-3deff52d7c6e', 'workflow_type': 'TaskExecutionWorkflow'})
    1212:  FAIL  test_execution_workflow:24 workflow: evaluate step single             42%
    1213:  ERROR:temporalio.workflow:Error in transition: Activity task failed ({'attempt': 1, 'namespace': 'default', 'run_id': 'fc7198dc-f8e5-435a-a577-aa43e25a50ff', 'task_queue': 'julep-task-queue', 'workflow_id': '7866b4ac-dc48-41cb-a203-37472480b6b7', 'workflow_type': 'TaskExecutionWorkflow'})
    1214:  FAIL  test_execution_workflow:63 workflow: evaluate step multiple           43%
    1215:  ───────────────────── model: create entry, update session ──────────────────────
    1216:  Failed at tests/test_entry_queries.py:77                                      
    ...
    
    1253:  │                                                                            │
    1254:  ╰────────────────────────────────────────────────────────────────────────────╯
    1255:  ╭─ was not greater than the RHS (of type datetime) ──────────────────────────╮
    1256:  │                                                                            │
    1257:  │ datetime.datetime(2025, 1, 3, 11, 21, 8, tzinfo=TzInfo(UTC))               │
    1258:  │                                                                            │
    1259:  ╰────────────────────────────────────────────────────────────────────────────╯
    1260:  ──────────────────────── workflow: evaluate step single ────────────────────────
    1261:  Failed at tests/test_execution_workflow.py                                    
    1262:  ApplicationError: AttributeError: 'NoneType' object has no attribute          
    1263:  'encode'                                                                      
    1264:  The above exception was the direct cause of the following exception:          
    1265:  ApplicationError: AttributeError: 'NoneType' object has no attribute          
    1266:  'encode'                                                                      
    1267:  The above exception was the direct cause of the following exception:          
    1268:  ActivityError: Activity task failed                                           
    1269:  The above exception was the direct cause of the following exception:          
    1270:  ApplicationError: Error in transition: Activity task failed                   
    ...
    
    1290:  │                                                                          │  
    1291:  │ /opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/asyncio/runners.py │  
    1292:  │ :118 in run                                                              │  
    1293:  │                                                                          │  
    1294:  │   115 │   │                                                              │  
    1295:  │   116 │   │   self._interrupt_count = 0                                  │  
    1296:  │   117 │   │   try:                                                       │  
    1297:  │ ❱ 118 │   │   │   return self._loop.run_until_complete(task)             │  
    1298:  │   119 │   │   except exceptions.CancelledError:                          │  
    ...
    
    1303:  │ │        context = <_contextvars.Context object at 0x7f4e9fac4e80>     │ │  
    1304:  │ │           coro = <coroutine object _ at 0x7f4e9e73d0c0>              │ │  
    1305:  │ │           self = <asyncio.runners.Runner object at 0x7f4e9635a4e0>   │ │  
    1306:  │ │ sigint_handler = functools.partial(<bound method Runner._on_sigint   │ │  
    1307:  │ │                  of <asyncio.runners.Runner object at                │ │  
    1308:  │ │                  0x7f4e9635a4e0>>, main_task=<Task finished          │ │  
    1309:  │ │                  name='Task-267' coro=<_() done, defined at          │ │  
    1310:  │ │                  /home/runner/work/julep/julep/agents-api/tests/tes… │ │  
    1311:  │ │                  exception=WorkflowFailureError('Workflow execution  │ │  
    1312:  │ │                  failed')>)                                          │ │  
    1313:  │ │           task = <Task finished name='Task-267' coro=<_() done,      │ │  
    1314:  │ │                  defined at                                          │ │  
    1315:  │ │                  /home/runner/work/julep/julep/agents-api/tests/tes… │ │  
    1316:  │ │                  exception=WorkflowFailureError('Workflow execution  │ │  
    1317:  │ │                  failed')>                                           │ │  
    ...
    
    1351:  │ │                                   │   instructions=[],               │ │  
    1352:  │ │                                   │   default_settings=None          │ │  
    1353:  │ │                                   )                                  │ │  
    1354:  │ │                          client = <pycozo.client_patch.Client object │ │  
    1355:  │ │                                   at 0x7f4e9f44ee10>                 │ │  
    1356:  │ │                            data = CreateExecutionRequest(            │ │  
    1357:  │ │                                   │   input={'test': 'input'},       │ │  
    1358:  │ │                                   │   output=None,                   │ │  
    1359:  │ │                                   │   error=None,                    │ │  
    ...
    
    1361:  │ │                                   )                                  │ │  
    1362:  │ │                    developer_id = UUID('00000000-0000-0000-0000-000… │ │  
    1363:  │ │                       execution = Execution(                         │ │  
    1364:  │ │                                   │                                  │ │  
    1365:  │ │                                   task_id=UUID('8436e868-0873-4f83-… │ │  
    1366:  │ │                                   │   status='queued',               │ │  
    1367:  │ │                                   │   input={'test': 'input'},       │ │  
    1368:  │ │                                   │   output=None,                   │ │  
    1369:  │ │                                   │   error=None,                    │ │  
    ...
    
    1411:  │ │  rpc_timeout = None                                                  │ │  
    1412:  │ │         self = <temporalio.testing._workflow._TimeSkippingWorkflowH… │ │  
    1413:  │ │                object at 0x7f4e9e7091f0>                             │ │  
    1414:  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
    1415:  │                                                                          │  
    1416:  │ /home/runner/work/julep/julep/agents-api/.venv/lib/python3.12/site-packa │  
    1417:  │ ges/temporalio/client.py:1281 in result                                  │  
    1418:  │                                                                          │  
    1419:  │   1278 │   │   │   │   │   if follow_runs and fail_attr.new_execution_ru │  
    1420:  │   1279 │   │   │   │   │   │   hist_run_id = fail_attr.new_execution_run │  
    1421:  │   1280 │   │   │   │   │   │   break                                     │  
    1422:  │ ❱ 1281 │   │   │   │   │   raise WorkflowFailureError(                   │  
    1423:  │   1282 │   │   │   │   │   │   cause=await self._client.data_converter.d │  
    1424:  │   1283 │   │   │   │   │   │   │   fail_attr.failure                     │  
    1425:  │   1284 │   │   │   │   │   │   ),                                        │  
    1426:  │                                                                          │  
    1427:  │ ╭─────────────────────────────── locals ───────────────────────────────╮ │  
    1428:  │ │        event = event_id: 11                                          │ │  
    1429:  │ │                event_time {                                          │ │  
    1430:  │ │                  seconds: 1735903273                                 │ │  
    1431:  │ │                  nanos: 952000000                                    │ │  
    1432:  │ │                }                                                     │ │  
    1433:  │ │                event_type: EVENT_TYPE_WORKFLOW_EXECUTION_FAILED      │ │  
    1434:  │ │                workflow_execution_failed_event_attributes {          │ │  
    1435:  │ │                  failure {                                           │ │  
    1436:  │ │                │   message: "Error in transition: Activity task      │ │  
    1437:  │ │                failed"                                               │ │  
    ...
    
    1462:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1463:  │ │                line 2140, in execute_workflow\n    return await      │ │  
    1464:  │ │                input.run_fn(*args)\n                                 │ │  
    1465:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File                   │ │  
    1466:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1467:  │ │                line 154, in run\n    await transition(\n\n  File     │ │  
    1468:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1469:  │ │                line 60, in transition\n    raise                     │ │  
    1470:  │ │                ApplicationError(f\"Error in transition: {e}\") from  │ │  
    1471:  │ │                e\n"                                                  │ │  
    1472:  │ │                │   cause {                                           │ │  
    1473:  │ │                │     message: "Activity task failed"                 │ │  
    ...
    
    1476:  │ │                attribute \'encode\'"                                 │ │  
    1477:  │ │                │   │   stack_trace: "  File                          │ │  
    1478:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1479:  │ │                line 453, in _run_activity\n    result = await        │ │  
    1480:  │ │                impl.execute_activity(input)\n                        │ │  
    1481:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File          │ │  
    1482:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1483:  │ │                line 62, in execute_activity\n    raise               │ │  
    1484:  │ │                ApplicationError(\n"                                  │ │  
    ...
    
    1575:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1576:  │ │                line 78, in __init__\n    normalize_header_value(v,   │ │  
    1577:  │ │                encoding),\n                                          │ │  
    1578:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File         │ │  
    1579:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1580:  │ │                line 53, in normalize_header_value\n    return        │ │  
    1581:  │ │                value.encode(encoding or \"ascii\")\n                 │ │  
    1582:  │ │                ^^^^^^^^^^^^\n"                                       │ │  
    1583:  │ │                │   │     application_failure_info {                  │ │  
    1584:  │ │                │   │   │   type: "AttributeError"                    │ │  
    1585:  │ │                │   │     }                                           │ │  
    1586:  │ │                │   │   }                                             │ │  
    1587:  │ │                │   │   application_failure_info {                    │ │  
    1588:  │ │                │   │     type: "AttributeError"                      │ │  
    1589:  │ │                │   │     non_retryable: true                         │ │  
    1590:  │ │                │   │   }                                             │ │  
    1591:  │ │                │     }                                               │ │  
    1592:  │ │                │     activity_failure_info {                         │ │  
    1593:  │ │                │   │   scheduled_event_id: 5                         │ │  
    1594:  │ │                │   │   started_event_id: 6                           │ │  
    1595:  │ │                │   │   identity: "3972@fv-az1276-778"                │ │  
    1596:  │ │                │   │   activity_type {                               │ │  
    1597:  │ │                │   │     name: "transition_step"                     │ │  
    1598:  │ │                │   │   }                                             │ │  
    1599:  │ │                │   │   activity_id: "1"                              │ │  
    1600:  │ │                │   │   retry_state:                                  │ │  
    1601:  │ │                RETRY_STATE_NON_RETRYABLE_FAILURE                     │ │  
    1602:  │ │                │     }                                               │ │  
    1603:  │ │                │   }                                                 │ │  
    1604:  │ │                │   application_failure_info {                        │ │  
    1605:  │ │                │   }                                                 │ │  
    1606:  │ │                  }                                                   │ │  
    1607:  │ │                  workflow_task_completed_event_id: 9                 │ │  
    1608:  │ │                }                                                     │ │  
    1609:  │ │    fail_attr = failure {                                             │ │  
    1610:  │ │                  message: "Error in transition: Activity task        │ │  
    1611:  │ │                failed"                                               │ │  
    ...
    
    1636:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1637:  │ │                line 2140, in execute_workflow\n    return await      │ │  
    1638:  │ │                input.run_fn(*args)\n                                 │ │  
    1639:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File                   │ │  
    1640:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1641:  │ │                line 154, in run\n    await transition(\n\n  File     │ │  
    1642:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1643:  │ │                line 60, in transition\n    raise                     │ │  
    1644:  │ │                ApplicationError(f\"Error in transition: {e}\") from  │ │  
    1645:  │ │                e\n"                                                  │ │  
    1646:  │ │                  cause {                                             │ │  
    1647:  │ │                │   message: "Activity task failed"                   │ │  
    ...
    
    1650:  │ │                \'encode\'"                                           │ │  
    1651:  │ │                │     stack_trace: "  File                            │ │  
    1652:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1653:  │ │                line 453, in _run_activity\n    result = await        │ │  
    1654:  │ │                impl.execute_activity(input)\n                        │ │  
    1655:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File          │ │  
    1656:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1657:  │ │                line 62, in execute_activity\n    raise               │ │  
    1658:  │ │                ApplicationError(\n"                                  │ │  
    ...
    
    1749:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1750:  │ │                line 78, in __init__\n    normalize_header_value(v,   │ │  
    1751:  │ │                encoding),\n                                          │ │  
    1752:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File         │ │  
    1753:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1754:  │ │                line 53, in normalize_header_value\n    return        │ │  
    1755:  │ │                value.encode(encoding or \"ascii\")\n                 │ │  
    1756:  │ │                ^^^^^^^^^^^^\n"                                       │ │  
    1757:  │ │                │   │   application_failure_info {                    │ │  
    1758:  │ │                │   │     type: "AttributeError"                      │ │  
    1759:  │ │                │   │   }                                             │ │  
    1760:  │ │                │     }                                               │ │  
    1761:  │ │                │     application_failure_info {                      │ │  
    1762:  │ │                │   │   type: "AttributeError"                        │ │  
    1763:  │ │                │   │   non_retryable: true                           │ │  
    1764:  │ │                │     }                                               │ │  
    1765:  │ │                │   }                                                 │ │  
    1766:  │ │                │   activity_failure_info {                           │ │  
    1767:  │ │                │     scheduled_event_id: 5                           │ │  
    1768:  │ │                │     started_event_id: 6                             │ │  
    1769:  │ │                │     identity: "3972@fv-az1276-778"                  │ │  
    1770:  │ │                │     activity_type {                                 │ │  
    1771:  │ │                │   │   name: "transition_step"                       │ │  
    1772:  │ │                │     }                                               │ │  
    1773:  │ │                │     activity_id: "1"                                │ │  
    1774:  │ │                │     retry_state: RETRY_STATE_NON_RETRYABLE_FAILURE  │ │  
    1775:  │ │                │   }                                                 │ │  
    1776:  │ │                  }                                                   │ │  
    1777:  │ │                  application_failure_info {                          │ │  
    ...
    
    1781:  │ │  follow_runs = True                                                  │ │  
    1782:  │ │  hist_run_id = '88711add-62cb-446b-844d-1eac5c3d4aa7'                │ │  
    1783:  │ │ rpc_metadata = {}                                                    │ │  
    1784:  │ │  rpc_timeout = None                                                  │ │  
    1785:  │ │         self = <temporalio.testing._workflow._TimeSkippingWorkflowH… │ │  
    1786:  │ │                object at 0x7f4e9e7091f0>                             │ │  
    1787:  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
    1788:  ╰──────────────────────────────────────────────────────────────────────────╯  
    1789:  WorkflowFailureError: Workflow execution failed                               
    1790:  ─────────────────────── workflow: evaluate step multiple ───────────────────────
    1791:  Failed at tests/test_execution_workflow.py                                    
    1792:  ApplicationError: AttributeError: 'NoneType' object has no attribute          
    1793:  'encode'                                                                      
    1794:  The above exception was the direct cause of the following exception:          
    1795:  ApplicationError: AttributeError: 'NoneType' object has no attribute          
    1796:  'encode'                                                                      
    1797:  The above exception was the direct cause of the following exception:          
    1798:  ActivityError: Activity task failed                                           
    1799:  The above exception was the direct cause of the following exception:          
    1800:  ApplicationError: Error in transition: Activity task failed                   
    ...
    
    1820:  │                                                                          │  
    1821:  │ /opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/asyncio/runners.py │  
    1822:  │ :118 in run                                                              │  
    1823:  │                                                                          │  
    1824:  │   115 │   │                                                              │  
    1825:  │   116 │   │   self._interrupt_count = 0                                  │  
    1826:  │   117 │   │   try:                                                       │  
    1827:  │ ❱ 118 │   │   │   return self._loop.run_until_complete(task)             │  
    1828:  │   119 │   │   except exceptions.CancelledError:                          │  
    ...
    
    1833:  │ │        context = <_contextvars.Context object at 0x7f4e9e8facc0>     │ │  
    1834:  │ │           coro = <coroutine object _ at 0x7f4e9c5becd0>              │ │  
    1835:  │ │           self = <asyncio.runners.Runner object at 0x7f4e9e9e3710>   │ │  
    1836:  │ │ sigint_handler = functools.partial(<bound method Runner._on_sigint   │ │  
    1837:  │ │                  of <asyncio.runners.Runner object at                │ │  
    1838:  │ │                  0x7f4e9e9e3710>>, main_task=<Task finished          │ │  
    1839:  │ │                  name='Task-283' coro=<_() done, defined at          │ │  
    1840:  │ │                  /home/runner/work/julep/julep/agents-api/tests/tes… │ │  
    1841:  │ │                  exception=WorkflowFailureError('Workflow execution  │ │  
    1842:  │ │                  failed')>)                                          │ │  
    1843:  │ │           task = <Task finished name='Task-283' coro=<_() done,      │ │  
    1844:  │ │                  defined at                                          │ │  
    1845:  │ │                  /home/runner/work/julep/julep/agents-api/tests/tes… │ │  
    1846:  │ │                  exception=WorkflowFailureError('Workflow execution  │ │  
    1847:  │ │                  failed')>                                           │ │  
    ...
    
    1881:  │ │                                   │   instructions=[],               │ │  
    1882:  │ │                                   │   default_settings=None          │ │  
    1883:  │ │                                   )                                  │ │  
    1884:  │ │                          client = <pycozo.client_patch.Client object │ │  
    1885:  │ │                                   at 0x7f4e9f44ee10>                 │ │  
    1886:  │ │                            data = CreateExecutionRequest(            │ │  
    1887:  │ │                                   │   input={'test': 'input'},       │ │  
    1888:  │ │                                   │   output=None,                   │ │  
    1889:  │ │                                   │   error=None,                    │ │  
    ...
    
    1891:  │ │                                   )                                  │ │  
    1892:  │ │                    developer_id = UUID('00000000-0000-0000-0000-000… │ │  
    1893:  │ │                       execution = Execution(                         │ │  
    1894:  │ │                                   │                                  │ │  
    1895:  │ │                                   task_id=UUID('354ba7c2-9cb1-4638-… │ │  
    1896:  │ │                                   │   status='queued',               │ │  
    1897:  │ │                                   │   input={'test': 'input'},       │ │  
    1898:  │ │                                   │   output=None,                   │ │  
    1899:  │ │                                   │   error=None,                    │ │  
    ...
    
    1941:  │ │  rpc_timeout = None                                                  │ │  
    1942:  │ │         self = <temporalio.testing._workflow._TimeSkippingWorkflowH… │ │  
    1943:  │ │                object at 0x7f4e9634cda0>                             │ │  
    1944:  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
    1945:  │                                                                          │  
    1946:  │ /home/runner/work/julep/julep/agents-api/.venv/lib/python3.12/site-packa │  
    1947:  │ ges/temporalio/client.py:1281 in result                                  │  
    1948:  │                                                                          │  
    1949:  │   1278 │   │   │   │   │   if follow_runs and fail_attr.new_execution_ru │  
    1950:  │   1279 │   │   │   │   │   │   hist_run_id = fail_attr.new_execution_run │  
    1951:  │   1280 │   │   │   │   │   │   break                                     │  
    1952:  │ ❱ 1281 │   │   │   │   │   raise WorkflowFailureError(                   │  
    1953:  │   1282 │   │   │   │   │   │   cause=await self._client.data_converter.d │  
    1954:  │   1283 │   │   │   │   │   │   │   fail_attr.failure                     │  
    1955:  │   1284 │   │   │   │   │   │   ),                                        │  
    1956:  │                                                                          │  
    1957:  │ ╭─────────────────────────────── locals ───────────────────────────────╮ │  
    1958:  │ │        event = event_id: 11                                          │ │  
    1959:  │ │                event_time {                                          │ │  
    1960:  │ │                  seconds: 1735903274                                 │ │  
    1961:  │ │                  nanos: 140000000                                    │ │  
    1962:  │ │                }                                                     │ │  
    1963:  │ │                event_type: EVENT_TYPE_WORKFLOW_EXECUTION_FAILED      │ │  
    1964:  │ │                workflow_execution_failed_event_attributes {          │ │  
    1965:  │ │                  failure {                                           │ │  
    1966:  │ │                │   message: "Error in transition: Activity task      │ │  
    1967:  │ │                failed"                                               │ │  
    ...
    
    1992:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    1993:  │ │                line 2140, in execute_workflow\n    return await      │ │  
    1994:  │ │                input.run_fn(*args)\n                                 │ │  
    1995:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File                   │ │  
    1996:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1997:  │ │                line 154, in run\n    await transition(\n\n  File     │ │  
    1998:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    1999:  │ │                line 60, in transition\n    raise                     │ │  
    2000:  │ │                ApplicationError(f\"Error in transition: {e}\") from  │ │  
    2001:  │ │                e\n"                                                  │ │  
    2002:  │ │                │   cause {                                           │ │  
    2003:  │ │                │     message: "Activity task failed"                 │ │  
    ...
    
    2006:  │ │                attribute \'encode\'"                                 │ │  
    2007:  │ │                │   │   stack_trace: "  File                          │ │  
    2008:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2009:  │ │                line 453, in _run_activity\n    result = await        │ │  
    2010:  │ │                impl.execute_activity(input)\n                        │ │  
    2011:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File          │ │  
    2012:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    2013:  │ │                line 62, in execute_activity\n    raise               │ │  
    2014:  │ │                ApplicationError(\n"                                  │ │  
    ...
    
    2105:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2106:  │ │                line 78, in __init__\n    normalize_header_value(v,   │ │  
    2107:  │ │                encoding),\n                                          │ │  
    2108:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File         │ │  
    2109:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2110:  │ │                line 53, in normalize_header_value\n    return        │ │  
    2111:  │ │                value.encode(encoding or \"ascii\")\n                 │ │  
    2112:  │ │                ^^^^^^^^^^^^\n"                                       │ │  
    2113:  │ │                │   │     application_failure_info {                  │ │  
    2114:  │ │                │   │   │   type: "AttributeError"                    │ │  
    2115:  │ │                │   │     }                                           │ │  
    2116:  │ │                │   │   }                                             │ │  
    2117:  │ │                │   │   application_failure_info {                    │ │  
    2118:  │ │                │   │     type: "AttributeError"                      │ │  
    2119:  │ │                │   │     non_retryable: true                         │ │  
    2120:  │ │                │   │   }                                             │ │  
    2121:  │ │                │     }                                               │ │  
    2122:  │ │                │     activity_failure_info {                         │ │  
    2123:  │ │                │   │   scheduled_event_id: 5                         │ │  
    2124:  │ │                │   │   started_event_id: 6                           │ │  
    2125:  │ │                │   │   identity: "3972@fv-az1276-778"                │ │  
    2126:  │ │                │   │   activity_type {                               │ │  
    2127:  │ │                │   │     name: "transition_step"                     │ │  
    2128:  │ │                │   │   }                                             │ │  
    2129:  │ │                │   │   activity_id: "1"                              │ │  
    2130:  │ │                │   │   retry_state:                                  │ │  
    2131:  │ │                RETRY_STATE_NON_RETRYABLE_FAILURE                     │ │  
    2132:  │ │                │     }                                               │ │  
    2133:  │ │                │   }                                                 │ │  
    2134:  │ │                │   application_failure_info {                        │ │  
    2135:  │ │                │   }                                                 │ │  
    2136:  │ │                  }                                                   │ │  
    2137:  │ │                  workflow_task_completed_event_id: 9                 │ │  
    2138:  │ │                }                                                     │ │  
    2139:  │ │    fail_attr = failure {                                             │ │  
    2140:  │ │                  message: "Error in transition: Activity task        │ │  
    2141:  │ │                failed"                                               │ │  
    ...
    
    2166:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2167:  │ │                line 2140, in execute_workflow\n    return await      │ │  
    2168:  │ │                input.run_fn(*args)\n                                 │ │  
    2169:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File                   │ │  
    2170:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    2171:  │ │                line 154, in run\n    await transition(\n\n  File     │ │  
    2172:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    2173:  │ │                line 60, in transition\n    raise                     │ │  
    2174:  │ │                ApplicationError(f\"Error in transition: {e}\") from  │ │  
    2175:  │ │                e\n"                                                  │ │  
    2176:  │ │                  cause {                                             │ │  
    2177:  │ │                │   message: "Activity task failed"                   │ │  
    ...
    
    2180:  │ │                \'encode\'"                                           │ │  
    2181:  │ │                │     stack_trace: "  File                            │ │  
    2182:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2183:  │ │                line 453, in _run_activity\n    result = await        │ │  
    2184:  │ │                impl.execute_activity(input)\n                        │ │  
    2185:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File          │ │  
    2186:  │ │                \"/home/runner/work/julep/julep/agents-api/agents_ap… │ │  
    2187:  │ │                line 62, in execute_activity\n    raise               │ │  
    2188:  │ │                ApplicationError(\n"                                  │ │  
    ...
    
    2279:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2280:  │ │                line 78, in __init__\n    normalize_header_value(v,   │ │  
    2281:  │ │                encoding),\n                                          │ │  
    2282:  │ │                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n  File         │ │  
    2283:  │ │                \"/home/runner/work/julep/julep/agents-api/.venv/lib… │ │  
    2284:  │ │                line 53, in normalize_header_value\n    return        │ │  
    2285:  │ │                value.encode(encoding or \"ascii\")\n                 │ │  
    2286:  │ │                ^^^^^^^^^^^^\n"                                       │ │  
    2287:  │ │                │   │   application_failure_info {                    │ │  
    2288:  │ │                │   │     type: "AttributeError"                      │ │  
    2289:  │ │                │   │   }                                             │ │  
    2290:  │ │                │     }                                               │ │  
    2291:  │ │                │     application_failure_info {                      │ │  
    2292:  │ │                │   │   type: "AttributeError"                        │ │  
    2293:  │ │                │   │   non_retryable: true                           │ │  
    2294:  │ │                │     }                                               │ │  
    2295:  │ │                │   }                                                 │ │  
    2296:  │ │                │   activity_failure_info {                           │ │  
    2297:  │ │                │     scheduled_event_id: 5                           │ │  
    2298:  │ │                │     started_event_id: 6                             │ │  
    2299:  │ │                │     identity: "3972@fv-az1276-778"                  │ │  
    2300:  │ │                │     activity_type {                                 │ │  
    2301:  │ │                │   │   name: "transition_step"                       │ │  
    2302:  │ │                │     }                                               │ │  
    2303:  │ │                │     activity_id: "1"                                │ │  
    2304:  │ │                │     retry_state: RETRY_STATE_NON_RETRYABLE_FAILURE  │ │  
    2305:  │ │                │   }                                                 │ │  
    2306:  │ │                  }                                                   │ │  
    2307:  │ │                  application_failure_info {                          │ │  
    ...
    
    2311:  │ │  follow_runs = True                                                  │ │  
    2312:  │ │  hist_run_id = 'fc7198dc-f8e5-435a-a577-aa43e25a50ff'                │ │  
    2313:  │ │ rpc_metadata = {}                                                    │ │  
    2314:  │ │  rpc_timeout = None                                                  │ │  
    2315:  │ │         self = <temporalio.testing._workflow._TimeSkippingWorkflowH… │ │  
    2316:  │ │                object at 0x7f4e9634cda0>                             │ │  
    2317:  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
    2318:  ╰──────────────────────────────────────────────────────────────────────────╯  
    2319:  WorkflowFailureError: Workflow execution failed                               
    2320:  ────────────────────────────────────────────────────────────────────────────────
    2321:  ╭──────────── Results ─────────────╮
    2322:  │  63  Tests Encountered           │
    2323:  │  59  Passes             (93.7%)  │
    2324:  │   3  Failures           (4.8%)   │
    2325:  │   1  Skips              (1.6%)   │
    2326:  ╰──────────────────────────────────╯
    2327:  ─────────────────────────── FAILED in 20.32 seconds ────────────────────────────
    2328:  ##[error]Process completed with exit code 1.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    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 de88a33 in 22 seconds

    More details
    • Looked at 87 lines of code in 1 files
    • Skipped 0 files when reviewing.
    • Skipped posting 1 drafted comments based on config settings.
    1. agents-api/agents_api/activities/execute_system.py:145
    • Draft comment:
      Missing return statement for the asynchronous handler. Add return await handler() to ensure the result is returned.
    • Reason this comment was not posted:
      Comment looked like it was already resolved.

    Workflow ID: wflow_rfxETzEx7CYt01OD


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

    @HamadaSalhab HamadaSalhab merged commit 8946a09 into main Jan 3, 2025
    1 check passed
    @HamadaSalhab HamadaSalhab deleted the x/sessions-updated-at-precision branch January 3, 2025 11:21
    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