Azure Function not working with Azure Agent Service #70
-
|
As posted in this issue I created an Azure function and connected it to my agent. When I run this code: thread = agent_client.threads.create()
message = agent_client.messages.create(
thread_id=thread.id,
role="user",
content="XYZ",
)
run = agent_client.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)I can see the request being queued in the input queue, processed and moved to the output queue, where it is eventually consumed from. However, the # We need tool set only if we are executing local function. In case if
# the tool is azure_function we just need to wait when it will be finished.Is there anything I am missing? Since the response is consumed, is there anything else I need to do? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Potential Gotchas to Investigate further Function Completion Signal Not Emitted: The create_and_process() loop internally waits for the function call to complete and it polls the run status. If the Azure Function completes but doesn't return a proper payload (or returns an empty or malformed tool response), the agent thread may stall waiting for a signal that never arrives. Ensure your Azure Function posts a valid See https://learn.microsoft.com/en-us/azure/ai-services/openai/agents-reference#tool-call-response-format, especially with correct tool_call_id. Tool Call Expectation vs Reality: Check that the tool name registered in the agent matches exactly what the function identifies as (especially if you used openai_tools.azure_function or a custom name). If you haven't explicitly mapped the tool back to the function output with tool_choice or equivalent, the SDK might assume it still needs to run. SDK Polling Timeout Configuration: create_and_process() has an internal loop with a default timeout, sometimes set to 10 minutes or more. If your Function runs slower, it's worth checking the agent run.status manually and inspecting run.steps for clues (agent_client.runs.retrieve(...)). Alternatively, consider using the lower-level .create() followed by your own poll/check logic for finer control. Missing or Misparsed Output Format: Did your Azure Function return a tool result in exactly the expected format? Even one level of JSON nesting off can be enough to derail the parser. Sometimes a {"output": "result string"} vs {"output": {"message": "result string"}} matters depending on how the agent tool expects it. If you've already gone down these paths, feel free to share your function’s response payload structure. |
Beta Was this translation helpful? Give feedback.
-
|
Solved, see issue. |
Beta Was this translation helpful? Give feedback.
Solved, see issue.