Foundry Agent Run Job

The Foundry Agent Run job type invokes an Azure AI Foundry Project agent (an OpenAI-style assistant) by creating a thread, posting a user message, and starting a run. The agent is identified by its agent ID — Polysync stores that in the External Id.

This job type is supported on the Azure AI Foundry Project platform.

Required job fields

  • External Id — the agent's id (e.g., asst_…).
  • Job TypeFoundry Agent Run (set automatically on import).

Job discovery

GET /api/projects/{project}/assistants?api-version=v1

(scope: https://ai.azure.com/.default). Each agent's id, name, and model becomes a Polysync Job.

Parameter handling

Two well-known parameter names drive the interaction:

Polysync parameter Direction Role
user_message Input Body of the user message posted to the thread.
thread_id Input&Output If supplied → reuse that thread. After run → set to the thread id actually used.
response Output Populated with the latest assistant message after the run completes.

The request sequence:

  1. POST /threads — create a thread (skipped if thread_id was supplied).
  2. POST /threads/{threadId}/messages with { "role": "user", "content": <user_message> }.
  3. POST /threads/{threadId}/runs with { "assistant_id": "<external-id>" }.

The composite RunId is "agent#{threadId}#{runId}".

Output parameters

On run completion, Polysync fetches the latest assistant message via GET /threads/{threadId}/messages?order=desc&limit=1 and writes content[0].text.value to the response parameter (and the thread_id parameter to the thread used).

Execution flow

  1. Submit the user message + start the run as described above.

  2. Status is polled via GET /threads/{threadId}/runs/{agentRunId} and status is decoded:

    Foundry agent run status Polysync status
    queued / in_progress / requires_action / cancelling Running
    completed Success
    failed / expired Failed
    cancelled Cancelled
  3. Cancel is supported via POST /threads/{threadId}/runs/{agentRunId}/cancel.

Monitor URL

https://portal.azure.com/#@/resource/subscriptions/{subId}/resourceGroups/{rg}
  /providers/Microsoft.CognitiveServices/accounts/{accountName}/overview

(Foundry has no per-run deep-link; this is the generic account overview.)

Best practices

  • Reuse a thread across Polysync Jobs in the same Task chain by exposing thread_id as an Input&Output parameter and binding the downstream Task's thread_id input to the upstream Task's output.
  • For agents with tool calls (requires_action), implement the tool inside the agent itself — Polysync does not currently submit tool outputs.

Troubleshooting

  • Run sits in requires_action — the agent expects a tool-output submission Polysync cannot provide. Wrap the tool inside the agent definition so it runs server-side.
  • 401 Unauthorized — Foundry agent endpoints require AAD; API Key auth is rejected for /threads/* operations. Use Service Principal, Certificate, or Polysync SPN.