Tasks that include a tool_call step of type api_call are throwing an HTTPException: 400: Object of type bytes is not JSON serializable error. This happens only on our dev server. I couldn't reproduce it locally (task ran fine locally).
π Reproduction steps
Run this task
name: Test Task
tools:
- name: api_tool_call
type: api_call
api_call:
method: GET
url: "https://jsonplaceholder.typicode.com/posts"
main:
- tool: api_tool_call
π Expected behavior
The task should perform the api call and successfully finish the execution.
π Actual Behavior with Screenshots
The task is stuck on init state, so there's no output from the tool_call step.
π» Operating system
Linux
What browsers are you seeing the problem on?
No response
π Provide any additional context for the Bug.
No response
π Relevant log output
worker-1 | Traceback (most recent call last):
worker-1 | File "/app/agents_api/models/utils.py", line 303, in wrapper
worker-1 | result: T = func(*args, **kwargs)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/app/agents_api/models/utils.py", line 262, in wrapper
worker-1 | df = func(*args, **kwargs)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/app/agents_api/models/utils.py", line 224, in wrapper
worker-1 | result = client.run(query, variables)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/pycozo/client.py", line 111, in run
worker-1 | return self._client_request(script, params, immutable)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/pycozo/client.py", line 76, in _client_request
worker-1 | r = requests.post(f'{self.host}/text-query', headers=self._headers(), json={
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 115, in post
worker-1 | return request("post", url, data=data, json=json, **kwargs)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/requests/api.py", line 59, in request
worker-1 | return session.request(method=method, url=url, **kwargs)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 575, in request
worker-1 | prep = self.prepare_request(req)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 484, in prepare_request
worker-1 | p.prepare(
worker-1 | File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 370, in prepare
worker-1 | self.prepare_body(data, files, json)
worker-1 | File "/usr/local/lib/python3.12/site-packages/requests/models.py", line 510, in prepare_body
worker-1 | body = complexjson.dumps(json, allow_nan=False)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/json/__init__.py", line 238, in dumps
worker-1 | **kw).encode(obj)
worker-1 | ^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/json/encoder.py", line 200, in encode
worker-1 | chunks = self.iterencode(o, _one_shot=True)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/json/encoder.py", line 258, in iterencode
worker-1 | return _iterencode(o, 0)
worker-1 | ^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/json/encoder.py", line 180, in default
worker-1 | raise TypeError(f'Object of type {o.__class__.__name__} '
worker-1 | TypeError: Object of type bytes is not JSON serializable
worker-1 |
worker-1 | The above exception was the direct cause of the following exception:
worker-1 |
worker-1 | Traceback (most recent call last):
worker-1 | File "/app/agents_api/common/interceptors.py", line 33, in execute_activity
worker-1 | return await super().execute_activity(input)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/temporalio/worker/_interceptor.py", line 119, in execute_activity
worker-1 | return await self.next.execute_activity(input)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/usr/local/lib/python3.12/site-packages/temporalio/worker/_activity.py", line 711, in execute_activity
worker-1 | return await input.fn(*input.args)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "<@beartype(agents_api.activities.task_steps.transition_step.transition_step) at 0x71f231fbac00>", line 53, in transition_step
worker-1 | File "/app/agents_api/activities/task_steps/transition_step.py", line 16, in transition_step
worker-1 | transition = create_execution_transition(
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/app/agents_api/models/utils.py", line 322, in wrapper
worker-1 | raise new_error from error
worker-1 | fastapi.exceptions.HTTPException: 400: Object of type bytes is not JSON serializable
worker-1 |
worker-1 | During handling of the above exception, another exception occurred:
worker-1 |
worker-1 | Traceback (most recent call last):
worker-1 | File "/usr/local/lib/python3.12/site-packages/temporalio/worker/_activity.py", line 453, in _run_activity
worker-1 | result = await impl.execute_activity(input)
worker-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worker-1 | File "/app/agents_api/common/interceptors.py", line 36, in execute_activity
worker-1 | raise ApplicationError(
worker-1 | temporalio.exceptions.ApplicationError: HTTPException: 400: Object of type bytes is not JSON serializable
worker-1 | ERROR:temporalio.workflow:Error in transition: Activity task failed ({'attempt': 1, 'namespace': 'default', 'run_id': '46d46cac-aba8-42d4-9298-4b085ad224c6', 'task_queue': 'memory-task-queue', 'workflow_id': '8ddf7a4c-c474-4edb-9d6f-03bb13050239', 'workflow_type': 'TaskExecutionWorkflow'})
π Have you spent some time to check if this bug has been raised before?
[X] I checked and didn't find similar issue
π Are you willing to submit PR?
None
π§ββοΈ Code of Conduct
[X] I agree to follow this project's Code of Conduct
π Description
Tasks that include a
tool_call
step of typeapi_call
are throwing anHTTPException: 400: Object of type bytes is not JSON serializable
error. This happens only on our dev server. I couldn't reproduce it locally (task ran fine locally).π Reproduction steps
Run this task
π Expected behavior
The task should perform the api call and successfully finish the execution.
π Actual Behavior with Screenshots
The task is stuck on
init
state, so there's no output from thetool_call
step.π» Operating system
Linux
What browsers are you seeing the problem on?
No response
π Provide any additional context for the Bug.
No response
π Relevant log output
π Have you spent some time to check if this bug has been raised before?
π Are you willing to submit PR?
None
π§ββοΈ Code of Conduct