> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# AI Agent

- Component: `appmixer.ai.foundry.AIAgent`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.ai.foundry 1.0.0](https://connectors.appmixer.com/connector/appmixer.ai.foundry/1.0.0.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.ai.foundry/1.0.0/component/appmixer.ai.foundry.AIAgent>

Build an AI agent responding with contextual answers or performing contextual actions. Connect a component to the 'tools' output port to let the agent call it as a tool, and mark the fields the model should fill with the 'Model Defined Parameter' variable; components connected behind it run as further steps of the same tool. For a tool with its own description and logic (branches, loops), connect a 'Tool Start' to the 'tools' port and end every branch with 'Tool Output'. An MCP server on the 'tools' port gives the agent all of its tools.

## Properties

| Field | Type | Description |
| --- | --- | --- |
| Stream Responses (`stream`) | toggle | Stream partial responses as they arrive from the model. Note that this only has an effect on the built-in chat utility. Responses are still sent as a complete answer to the output of the agent. Also note that for streaming to work, the 'Thread ID' configuration of the Agent must be set to the 'Thread ID' output of the 'Chat Trigger' component. |

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| Deployment (`model`) | text | Name of the model deployment in your Azure AI Foundry resource (Deployments in the Foundry portal), e.g. `gpt-4o-prod`. The list offers the models known to the resource; when your deployment name differs from the model name, type the deployment name. |
| Instructions (`instructions`) | textarea | The system instructions that the assistant uses. The maximum length is 256,000 characters. For example 'You are a personal math tutor.'. |
| Prompt (`prompt`) | textarea | - |
| Thread ID (`threadId`) | text | By setting a thread ID you can keep the context of the conversation. If you do not set a thread ID, the AI Agent will not use memory and will not keep the context of the conversation. This is useful e.g. if you want to use the AI Agent as a simple question and answer tool. |
| File ID (`fileId`) | filepicker | Optionally, you can select a file to be used as additional context for the AI Agent. File types PNG, JPEG, GIF, WEBP and PDF have a direct model support. Other file types will be parsed as text and sent as a regular prompt. This is useful for CSV, JSON, .js, .py or other textual content. You can either upload a file directly or map a file from a previous connected component. |
| Memory Data Store (`storeId`) | text | Select a data store to be used for storing the conversation context. This is useful if you want to preserve the context across different executions. Additionally, by saving the history to a data store, you can create other flows that export the history to your custom databases or external tools. Explore the Storage utilities to learn more about how to use the data store in your flows. |

## Output ports

### Port `out`

| Field | Type | Description |
| --- | --- | --- |
| Answer (`answer`) | string | - |
| Prompt (`prompt`) | string | - |
| Time (ms) (`time`) | integer | - |
| Usage (`usage`) | object | - |

### Port `tools`

| Field | Type | Description |
| --- | --- | --- |
| Prompt (`prompt`) | string | - |
| Model Defined Parameter (`modelDefinedParameter`) | string | - |

### Port `mcp`

_No fields defined for this port._

## Full metadata (component.json)

```json
{
  "name": "appmixer.ai.foundry.AIAgent",
  "label": "AI Agent",
  "author": "Appmixer <info@appmixer.com>",
  "description": "Build an AI agent responding with contextual answers or performing contextual actions. Connect a component to the 'tools' output port to let the agent call it as a tool, and mark the fields the model should fill with the 'Model Defined Parameter' variable; components connected behind it run as further steps of the same tool. For a tool with its own description and logic (branches, loops), connect a 'Tool Start' to the 'tools' port and end every branch with 'Tool Output'. An MCP server on the 'tools' port gives the agent all of its tools.",
  "auth": {
    "service": "appmixer:ai:foundry"
  },
  "version": "1.0.0",
  "properties": {
    "schema": {
      "type": "object",
      "properties": {
        "stream": {
          "type": "boolean"
        }
      }
    },
    "inspector": {
      "inputs": {
        "stream": {
          "type": "toggle",
          "label": "Stream Responses",
          "defaultValue": false,
          "index": 1,
          "tooltip": "Stream partial responses as they arrive from the model. Note that this only has an effect on the built-in chat utility. Responses are still sent as a complete answer to the output of the agent. Also note that for streaming to work, the 'Thread ID' configuration of the Agent must be set to the 'Thread ID' output of the 'Chat Trigger' component."
        }
      }
    }
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string"
          },
          "instructions": {
            "type": "string",
            "maxLength": 256000
          },
          "prompt": {
            "type": "string"
          },
          "threadId": {
            "type": "string"
          },
          "storeId": {
            "type": "string"
          },
          "fileId": {
            "type": "string"
          }
        },
        "required": [
          "model",
          "prompt"
        ]
      },
      "inspector": {
        "inputs": {
          "model": {
            "type": "text",
            "index": 1,
            "label": "Deployment",
            "tooltip": "Name of the model deployment in your Azure AI Foundry resource (Deployments in the Foundry portal), e.g. <code>gpt-4o-prod</code>. The list offers the models known to the resource; when your deployment name differs from the model name, type the deployment name.",
            "source": {
              "url": "/component/appmixer/ai/foundry/ListModels?outPort=out",
              "data": {
                "properties": {
                  "isSource": true
                },
                "transform": "./ListModels#toSelectOptions"
              }
            }
          },
          "instructions": {
            "type": "textarea",
            "label": "Instructions",
            "index": 2,
            "tooltip": "The system instructions that the assistant uses. The maximum length is 256,000 characters. For example 'You are a personal math tutor.'."
          },
          "prompt": {
            "label": "Prompt",
            "type": "textarea",
            "index": 3
          },
          "threadId": {
            "label": "Thread ID",
            "type": "text",
            "index": 4,
            "tooltip": "By setting a thread ID you can keep the context of the conversation. If you do not set a thread ID, the AI Agent will not use memory and will not keep the context of the conversation. This is useful e.g. if you want to use the AI Agent as a simple question and answer tool."
          },
          "fileId": {
            "label": "File ID",
            "type": "filepicker",
            "index": 5,
            "tooltip": "Optionally, you can select a file to be used as additional context for the AI Agent. File types PNG, JPEG, GIF, WEBP and PDF have a direct model support. Other file types will be parsed as text and sent as a regular prompt. This is useful for CSV, JSON, .js, .py or other textual content. You can either upload a file directly or map a file from a previous connected component."
          },
          "storeId": {
            "label": "Memory Data Store",
            "type": "text",
            "index": 6,
            "source": {
              "url": "/component/appmixer/utils/storage/ListStores?outPort=out",
              "data": {
                "transform": "./ListStores#toSelectArray"
              }
            },
            "tooltip": "Select a data store to be used for storing the conversation context. This is useful if you want to preserve the context across different executions. Additionally, by saving the history to a data store, you can create other flows that export the history to your custom databases or external tools. Explore the Storage utilities to learn more about how to use the data store in your flows."
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "options": [
        {
          "label": "Answer",
          "value": "answer",
          "schema": {
            "type": "string",
            "example": "The capital of France is Paris."
          }
        },
        {
          "label": "Prompt",
          "value": "prompt",
          "schema": {
            "type": "string",
            "example": "What is the capital of France?"
          }
        },
        {
          "label": "Time (ms)",
          "value": "time",
          "schema": {
            "type": "integer",
            "example": 1834
          }
        },
        {
          "label": "Usage",
          "value": "usage",
          "schema": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "integer",
                "title": "Prompt Tokens",
                "example": 42
              },
              "completion_tokens": {
                "type": "integer",
                "title": "Completion Tokens",
                "example": 18
              },
              "total_tokens": {
                "type": "integer",
                "title": "Total Tokens",
                "example": 60
              },
              "prompt_tokens_details": {
                "type": "object",
                "title": "Prompt Tokens Details",
                "properties": {
                  "cached_tokens": {
                    "type": "integer",
                    "title": "Cached Tokens",
                    "example": 0
                  },
                  "audio_tokens": {
                    "type": "integer",
                    "title": "Audio Tokens",
                    "example": 0
                  }
                }
              },
              "completion_tokens_details": {
                "type": "object",
                "title": "Completion Tokens Details",
                "properties": {
                  "reasoning_tokens": {
                    "type": "integer",
                    "title": "Reasoning Tokens",
                    "example": 0
                  },
                  "audio_tokens": {
                    "type": "integer",
                    "title": "Audio Tokens",
                    "example": 0
                  },
                  "accepted_prediction_tokens": {
                    "type": "integer",
                    "title": "Accepted Prediction Tokens",
                    "example": 0
                  },
                  "rejected_prediction_tokens": {
                    "type": "integer",
                    "title": "Rejected Prediction Tokens",
                    "example": 0
                  }
                }
              }
            },
            "example": {
              "prompt_tokens": 42,
              "completion_tokens": 18,
              "total_tokens": 60
            }
          }
        }
      ]
    },
    {
      "name": "tools",
      "options": [
        {
          "label": "Prompt",
          "value": "prompt",
          "schema": {
            "type": "string",
            "example": "What is the capital of France?"
          }
        },
        {
          "label": "Model Defined Parameter",
          "value": "modelDefinedParameter",
          "schema": {
            "type": "string",
            "example": "Paris"
          }
        }
      ]
    },
    {
      "name": "mcp"
    }
  ],
  "icon": "(data URI omitted)"
}
```
