You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to capture http requests from an agentic data retrieval tool running in an async loop. As you'll see from my logs below, it's largely communicating with the OpenAI API. I'm using llama_index which should be configured not to use streaming responses, but it looks like possibly something, somewhere in their stack is using a streaming response (I think, based on the response that's failing to capture having 'transfer-encoding': 'chunked' set - see below). If I can figure out how to turn that off, I will, but it looks like vcr.py has some kind of unhandled corner-case popping up for this type of response.
The crux of the error I'm seeing is:
2025-01-05 06:26:54,444 [DEBUG] openai._base_client - request_id: req_3466c5d3deca995ee9720bd9671ef41c
2025-01-05 06:26:54,450 [ERROR] asyncio - Task exception was never retrieved
future: <Task finished name='Task-13' coro=<_record_responses() done, defined at /usr/local/lib/python3.10/site-packages/vcr/stubs/httpx_stubs.py:129> exception=AssertionError()>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/vcr/stubs/httpx_stubs.py", line 139, in _record_responses
cassette.append(vcr_request, await _to_serialized_response(real_response, aread))
File "/usr/local/lib/python3.10/site-packages/vcr/stubs/httpx_stubs.py", line 41, in _to_serialized_response
assert not hasattr(resp, "_decoder")
AssertionError
I have a more complete log dump below, which includes details on the https requests that led up to this failure. Let me know if I can provide more info. I poked around the vcr.py codebase a bit to see if there was a quick fix, but I don't have the time to go too far down the rabbit hole. Happy to do additional investigation / grab logs / share configs if it would help.
Full log leading up to error
2025-01-05 06:26:52,641 [DEBUG] openai._base_client - Request options: {'method': 'post', 'url': '/chat/completions', 'files': None, 'json_data': {'messages': [{'role': 'user', 'content': 'Think step-by-step. Given a task and a set of tools, create a comprehesive, end-to-end plan to accomplish the task.\nKeep in mind not every task needs to be decomposed into multiple sub-tasks if it is simple enough.\nThe plan should end with a sub-task that can achieve the overall task.\n\nThe tools available are:\ndocument_parts: Provides semantic/hybrid search over this document to find relevant text.\ntext_search: Searches for text blocks containing provided raw_text in the current document.\nannotation_window: Retrieves contextual text around a specified Annotation.\n\n\nOverall Task: \nYou are an expert agent analyzing information in a legal or contractual document.\n1. Read the user\'s question below.\n2. Read the relevant extracted and combined context from the document below.\n3. Determine whether you have enough information to provide a succinct, accurate answer.\n4. IF more context is needed, use the following tools:\n- document_parts (for semantic/hybrid retrieval)\n- text_search (for substring matches in the doc\'s structural annotations)\n- page_retriever (to get full text from a 0-indexed page).\n5. Once your exploration is sufficient, craft a final short answer in plain text with\nno exposition, explanation, or other prose.\n\nUser\'s question:\nProvide a list of the defined terms \n\nContext provided (combined_text):\n========Contents of First Page (for intro/context)========\n\ncaption: TABLE SHOWING DISPOSITION OF ALL SECTIONS OF FORMER TITLE 1\nsection_header: STATUTORY NOTES AND RELATED SUBSIDIARIES\nsection_header: POSITIVE LAW; CITATION\ntext: (Release Point 117-285not263)\nsection_header: TITLE 1-GENERAL PROVISIONS\ntext: This title was enacted by act July 30, 1947, ch. 388, §1, 61 Stat. 633\ntext: This title has been made positive law by section 1 of act July 30, 1947, ch. 388, 61 Stat. 633, which provided in part that: "Title 1 of the United States Code entitled \'General Provisions\', is codified and enacted into positive law and may be cited as \'1 U. S. C., §--.\' "\nsection_header: REPEALS\ntext: Act July 30, 1947, ch. 388, §2, 61 Stat. 640, provided that the sections or parts thereof of the Statutes at Large or the Revised Statutes covering provisions codified in this Act are repealed insofar as the provisions appeared in former Title 1, and provided that any rights or liabilities now existing under the repealed sections or parts thereof shall not be affected by the repeal.\nsection_header: WRITS OF ERROR\ntext: Act June 25, 1948, ch. 646, §23, 62 Stat. 990, provided that: "All Acts of Congress referring to writs of error shall be construed as amended to the extent necessary to substitute appeal for writ of error."\ntext: (Release Point 117-285not263)\nsection_header: TITLE 1-GENERAL PROVISIONS\ntext: This title was enacted by act July 30, 1947, ch. 388, §1, 61 Stat. 633\ncaption: TABLE SHOWING DISPOSITION OF ALL SECTIONS OF FORMER TITLE 1\nsection_header: STATUTORY NOTES AND RELATED SUBSIDIARIES\nsection_header: POSITIVE LAW; CITATION\ntext: This title has been made positive law by section 1 of act July 30, 1947, ch. 388, 61 Stat. 633, which provided in part that: "Title 1 of the United States Code entitled \'General Provisions\', is codified and enacted into positive law and may be cited as \'1 U. S. C., §--.\' "\nsection_header: REPEALS\ntext: Act July 30, 1947, ch. 388, §2, 61 Stat. 640, provided that the sections or parts thereof of the Statutes at Large or the Revised Statutes covering provisions codified in this Act are repealed insofar as the provisions appeared in former Title 1, and provided that any rights or liabilities now existing under the repealed sections or parts thereof shall not be affected by the repeal.\nsection_header: WRITS OF ERROR\ntext: Act June 25, 1948, ch. 646, §23, 62 Stat. 990, provided that: "All Acts of Congress referring to writs of error shall be construed as amended to the extent necessary to substitute appeal for writ of error."\n\n========End of First Page========\n\n\n\n========== Retrieved Relevant Sections ==========\nThe following sections were identified as most relevant to your query:\n\n```Relevant Section:\n\n\n```\n```Relevant Section:\n\n\n```\n```Relevant Section:\n\n\n```\n```Relevant Section:\n\n\n```\n```Relevant Section:\n\n\n```\n==========End of Retrieved Sections==========\n\n\n'}], 'model': 'gpt-4o', 'stream': False, 'temperature': 0.1, 'tool_choice': 'required', 'tools': [{'type': 'function', 'function': {'name': 'Plan', 'description': 'A series of sub-tasks to accomplish an overall task.', 'parameters': {'$defs': {'SubTask': {'description': 'A single sub-task in a plan.', 'properties': {'name': {'description': 'The name of the sub-task.', 'title': 'Name', 'type': 'string'}, 'input': {'description': 'The input prompt for the sub-task.', 'title': 'Input', 'type': 'string'}, 'expected_output': {'description': 'The expected output of the sub-task.', 'title': 'Expected Output', 'type': 'string'}, 'dependencies': {'description': 'The sub-task names that must be completed before this sub-task.', 'items': {'type': 'string'}, 'title': 'Dependencies', 'type': 'array'}}, 'required': ['name', 'input', 'expected_output', 'dependencies'], 'title': 'SubTask', 'type': 'object'}}, 'properties': {'sub_tasks': {'description': 'The sub-tasks in the plan.', 'items': {'$ref': '#/$defs/SubTask'}, 'title': 'Sub Tasks', 'type': 'array'}}, 'required': ['sub_tasks'], 'type': 'object', 'additionalProperties': False}, 'strict': False}}]}}
2025-01-05 06:26:52,642 [DEBUG] openai._base_client - Sending HTTP Request: POST https://api.openai.com/v1/chat/completions
2025-01-05 06:26:52,642 [DEBUG] vcr.request - Invoking Request https://api.openai.com/v1/chat/completions
2025-01-05 06:26:52,643 [INFO] vcr.stubs.httpx_stubs - <Request (POST) https://api.openai.com/v1/chat/completions> not in cassette, sending to real server
2025-01-05 06:26:52,643 [DEBUG] httpcore.connection - connect_tcp.started host='api.openai.com' port=443 local_address=None timeout=60.0 socket_options=None
2025-01-05 06:26:52,679 [DEBUG] httpcore.connection - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f2ca8e4ff70>
2025-01-05 06:26:52,679 [DEBUG] httpcore.connection - start_tls.started ssl_context=<ssl.SSLContext object at 0x7f2ca7e58e40> server_hostname='api.openai.com' timeout=60.0
2025-01-05 06:26:52,692 [DEBUG] httpcore.connection - start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f2ca8e4e500>
2025-01-05 06:26:52,693 [DEBUG] httpcore.http11 - send_request_headers.started request=<Request [b'POST']>
2025-01-05 06:26:52,693 [DEBUG] httpcore.http11 - send_request_headers.complete
2025-01-05 06:26:52,694 [DEBUG] httpcore.http11 - send_request_body.started request=<Request [b'POST']>
2025-01-05 06:26:52,695 [DEBUG] httpcore.http11 - send_request_body.complete
2025-01-05 06:26:52,695 [DEBUG] httpcore.http11 - receive_response_headers.started request=<Request [b'POST']>
2025-01-05 06:26:54,441 [DEBUG] httpcore.http11 - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Sun, 05 Jan 2025 06:26:54 GMT'), (b'Content-Type', b'application/json'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'access-control-expose-headers', b'X-Request-ID'), (b'openai-organization', b'user-54labie7aicgek5urzpgydpm'), (b'openai-processing-ms', b'1663'), (b'openai-version', b'2020-10-01'), (b'x-ratelimit-limit-requests', b'5000'), (b'x-ratelimit-limit-tokens', b'800000'), (b'x-ratelimit-remaining-requests', b'4999'), (b'x-ratelimit-remaining-tokens', b'798918'), (b'x-ratelimit-reset-requests', b'12ms'), (b'x-ratelimit-reset-tokens', b'81ms'), (b'x-request-id', b'req_3466c5d3deca995ee9720bd9671ef41c'), (b'strict-transport-security', b'max-age=31536000; includeSubDomains; preload'), (b'CF-Cache-Status', b'DYNAMIC'), (b'Set-Cookie', b'__cf_bm=aGhR_WbK1v2fpfuRC.eYqxUulXGPNDhBdY6uEpmkvwU-1736058414-1.0.1.1-gBW.7_WD_Usm10o_cPpVs7RgjjDpr.tVVMBjtaG1HFmV5GLUNSo7FuNHUe3ii7TnN1vz1N2r8Qk1iunRuPaL4Q; path=/; expires=Sun, 05-Jan-25 06:56:54 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), (b'X-Content-Type-Options', b'nosniff'), (b'Set-Cookie', b'_cfuvid=RO5dlz9qPl5PDvpl0Nr.YMufVQy5vfpBjZpI3_1efjU-1736058414439-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), (b'Server', b'cloudflare'), (b'CF-RAY', b'8fd1663769fa2e5b-DFW'), (b'Content-Encoding', b'gzip'), (b'alt-svc', b'h3=":443"; ma=86400')])
2025-01-05 06:26:54,442 [INFO] httpx - HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
2025-01-05 06:26:54,442 [DEBUG] httpcore.http11 - receive_response_body.started request=<Request [b'POST']>
2025-01-05 06:26:54,443 [DEBUG] httpcore.http11 - receive_response_body.complete
2025-01-05 06:26:54,443 [DEBUG] httpcore.http11 - response_closed.started
2025-01-05 06:26:54,444 [DEBUG] httpcore.http11 - response_closed.complete
2025-01-05 06:26:54,444 [DEBUG] openai._base_client - HTTP Response: POST https://api.openai.com/v1/chat/completions "200 OK" Headers([('date', 'Sun, 05 Jan 2025 06:26:54 GMT'), ('content-type', 'application/json'), ('transfer-encoding', 'chunked'), ('connection', 'keep-alive'), ('access-control-expose-headers', 'X-Request-ID'), ('openai-organization', 'user-54labie7aicgek5urzpgydpm'), ('openai-processing-ms', '1663'), ('openai-version', '2020-10-01'), ('x-ratelimit-limit-requests', '5000'), ('x-ratelimit-limit-tokens', '800000'), ('x-ratelimit-remaining-requests', '4999'), ('x-ratelimit-remaining-tokens', '798918'), ('x-ratelimit-reset-requests', '12ms'), ('x-ratelimit-reset-tokens', '81ms'), ('x-request-id', 'req_3466c5d3deca995ee9720bd9671ef41c'), ('strict-transport-security', 'max-age=31536000; includeSubDomains; preload'), ('cf-cache-status', 'DYNAMIC'), ('set-cookie', '__cf_bm=aGhR_WbK1v2fpfuRC.eYqxUulXGPNDhBdY6uEpmkvwU-1736058414-1.0.1.1-gBW.7_WD_Usm10o_cPpVs7RgjjDpr.tVVMBjtaG1HFmV5GLUNSo7FuNHUe3ii7TnN1vz1N2r8Qk1iunRuPaL4Q; path=/; expires=Sun, 05-Jan-25 06:56:54 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), ('x-content-type-options', 'nosniff'), ('set-cookie', '_cfuvid=RO5dlz9qPl5PDvpl0Nr.YMufVQy5vfpBjZpI3_1efjU-1736058414439-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), ('server', 'cloudflare'), ('cf-ray', '8fd1663769fa2e5b-DFW'), ('content-encoding', 'gzip'), ('alt-svc', 'h3=":443"; ma=86400')])
2025-01-05 06:26:54,444 [DEBUG] openai._base_client - request_id: req_3466c5d3deca995ee9720bd9671ef41c
2025-01-05 06:26:54,450 [ERROR] asyncio - Task exception was never retrieved
future: <Task finished name='Task-13' coro=<_record_responses() done, defined at /usr/local/lib/python3.10/site-packages/vcr/stubs/httpx_stubs.py:129> exception=AssertionError()>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/vcr/stubs/httpx_stubs.py", line 139, in _record_responses
cassette.append(vcr_request, await _to_serialized_response(real_response, aread))
File "/usr/local/lib/python3.10/site-packages/vcr/stubs/httpx_stubs.py", line 41, in _to_serialized_response
assert not hasattr(resp, "_decoder")
AssertionError
The text was updated successfully, but these errors were encountered:
JSv4
changed the title
AssertionError in Async Env Stemming from Response Having _decoder ttr
AssertionError in Async Env Stemming from Response Having _decoder Attr
Jan 5, 2025
I am trying to capture http requests from an agentic data retrieval tool running in an async loop. As you'll see from my logs below, it's largely communicating with the OpenAI API. I'm using
llama_index
which should be configured not to use streaming responses, but it looks like possibly something, somewhere in their stack is using a streaming response (I think, based on the response that's failing to capture having'transfer-encoding': 'chunked'
set - see below). If I can figure out how to turn that off, I will, but it looks like vcr.py has some kind of unhandled corner-case popping up for this type of response.The crux of the error I'm seeing is:
I have a more complete log dump below, which includes details on the https requests that led up to this failure. Let me know if I can provide more info. I poked around the vcr.py codebase a bit to see if there was a quick fix, but I don't have the time to go too far down the rabbit hole. Happy to do additional investigation / grab logs / share configs if it would help.
Full log leading up to error
The text was updated successfully, but these errors were encountered: