Skip to content

Handle requires_action status #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kohei3110
Copy link

Purpose

  • Executing this sample, run.status is always in requires_action and users cannot get any response. In order to get a response, we need to add a function that handles the requires_action status.
  • Also, AgentsOperations object does not have an attribute get_messages but has a method list_messages.

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone https://github.com/kohei3110/azure-functions-ai-services-agent-python.git
cd azure-functions-ai-services-agent-python
git checkout feature/handle-requires-action
  • Create local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "STORAGE_CONNECTION__queueServiceUri": "https://<storageaccount>.queue.core.windows.net",
    "PROJECT_CONNECTION_STRING": "<project connnection for AI Project>",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true"
    }
}
  • Run the code
cd ./app
func start
  • Test the code

execute requests directly from the test.http project file.

image

What to Check

Verify that the following are valid

  • N/A

Other Information

  • N/A

@kohei3110 kohei3110 changed the title Feature/handle requires action Handle requires_action status Jan 5, 2025
@eamonoreilly
Copy link
Contributor

@kohei3110 Thanks for looking at the sample and providing feedback. This sample demonstrates using Azure Functions to process the action through the use of Azure storage queues where the agent service orchestrates the function calling and not the client. The agent service puts the information about the function to call on a queue that is picked up by an Azure Function queue trigger and processes the function call. When the Azure function queue trigger finishes, it puts the results of the call back on a different storage queue that the agent service picks up.
This moves the function orchestration to the agent service and not requiring the client to perform this action as described on https://learn.microsoft.com/en-us/azure/ai-services/agents/how-to/tools/azure-functions?pivots=overview

The solution you highlight above having the client code (Azure function) perform the function call (https://learn.microsoft.com/en-us/azure/ai-services/agents/how-to/tools/function-calling?tabs=python&pivots=overview) is still a valid scenario but is not the one highlighted in this sample.

The status will stay in 'requires_action' until the queue message is processed by the Azure Queue trigger as well as the agent service picking up the result on the storage queue specified. This can take a couple of minutes right now which is what the loop is waiting on.

Please let me know if this makes sense or there is another issue you are seeing when you run this code on your machine.
Thanks,
Eamon

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

Successfully merging this pull request may close these issues.

2 participants