Agents as Functions

AIP Agents can be published as Functions, allowing them to be used anywhere in the platform where Functions can be executed. For example, builders can publish AIP Agents as Functions to evaluate them in AIP Evals, to automate agent workflows with Automate, or to use agents in Code Repositories. You can configure function versions to be published every time an agent is published, or every time an agent is saved.

Function inputs

The following are inputs taken by agents published as Functions:

  • userInput: The user input string that the agent will respond to.

  • sessionRid (Optional): A string identifier for the current session with the following format:

    ri.aip-agents..session.{uuid}
    
    • Leave the sessionRid empty to start a new session with the agent.
    • Provide a value to continue an existing session using that session's RID.
    • This RID is returned on all Function executions.
  • All application variables used for application state are added as optional inputs. These variables can be used to override default application state values.

    • For object set variables, the default value is the base object set of the object type, meaning that all objects in the object type will be included by default.
    • For string variables, the default value is displayed and configured in Agent Studio.

Function outputs

The following are outputs of agents published as Functions:

  • markdownResponse: The final text response generated by the agent, formatted using markdown.

  • sessionRid: A string identifier for the current session the the following format:

    ri.aip-agents..session.{uuid}
    
    • This RID is returned on all Function executions.
    • Provide this value to the next Function execution to continue the session.
  • All application variables used for application state are added as optional outputs.

    • Values will only be output for these variables if the value was updated. Variables that were not updated will be empty.

Publish an agent as a Function

  1. To publish an agent as a Function in Agent Studio, select the publish settings icon to the right of the Publish button in the top-right. This will open a Publish settings dialog.

    The publish settings icon.

  2. Toggle the Publish function from agent option on, which will display additional configuration options for the published Function.

    The 'Publish function from agent' toggle.
  3. In the extended Publish settings dialog, select an Ontology and fill in Function details such as the Function name, API name, and description. Optionally, you can choose to release minor Function versions when the agent is saved by selecting the checkbox under Version configuration.

    The extended publish settings dialog.
  4. Select Publish agent and function at the bottom of the dialog.

After publishing, a toast notification will inform you that the agent and Function have been published, with a link to view the published Function in Ontology Manager. You can also view the Function by opening Publish settings and selecting it under Published function.

Disable agent Function publishing

To disable Function publishing, open Publish settings and toggle the option to Publish function from agent off. If you disable this option, future published versions of your agent will not register your agent as a Function until the option is re-enabled. You can re-enable this option at any time. To publish a Function after re-enabling, publish the agent.

Evaluate Agents with AIP Evals

Publishing agents as Functions allows them to be evaluated with AIP Evals evaluation suites. To create an evaluation suite from Agent Studio, ensure that your agent has been published as a Function, then open the Evaluation tab on the left toolbar. Here, you can select Create evaluation suite, which will prompt you to name your suite and choose the same Project as the agent.

The option to create an evaluation suite in the "Evaluation" tab.

Note that the evaluation suite must be in the same Project as the agent. To open the evaluation suite in AIP Evals after creation, select the arrow icon to the right of the created suite.

The created suite and the arrow icon that can be selected to open the suite in AIP Evals.

Keep the following in mind when setting up your test cases in AIP Evals:

  • To start a new session with your agent, make sure that the sessionRid is set to null. If a session RID is provided, the agent will continue an existing session, which is likely not the intent during testing.

The option to set the sessionRid to null in an evaluation suite test case.

  • Object set variables must be set to null or contain a real value. Object set variables cannot be empty.

The option to select an object set in an evaluation suite test case.

For more information on evaluation suites, refer to the AIP Evals documentation.