External agents and agent reviews¶
For supported providers, a monitored agent can be represented as a DSS external agent in a local project. Agent reviews in local projects can also be linked to a monitored agent and used by review alerts.
In the following examples, client is an AgentManagementClient created as described in The main AgentManagementClient class.
Creating an external agent¶
The caller needs agent administration rights and permission to write the target project configuration. The provider and agent type must support external-agent creation.
agent = client.get_agent("production", "support-agent")
reference = agent.create_external_agent(
project_key="AGENTMONITORING",
name="Support agent for reviews",
)
print(reference["projectKey"], reference["id"], reference["type"])
The returned dictionary identifies the created DSS saved model. Use the underlying DSSClient to access project objects on this Agent Management instance.
dss_client = client.get_dssclient()
project = dss_client.get_project(reference["projectKey"])
external_agent = project.get_saved_model(reference["id"])
Linking an existing agent review¶
The review must already exist in a local project and be configured for the intended agent. The following example adds it to the monitored agent without replacing other linked reviews.
settings = agent.get_settings()
reviews = settings.get_raw()["configuration"]["agentReviews"]
review_reference = {
"projectKey": "AGENTMONITORING",
"agentReviewId": "review-id",
}
if review_reference not in reviews:
reviews.append(review_reference)
settings.save()
Use dss_client.get_project("AGENTMONITORING").get_agent_review("review-id") to work with the review itself. See Agents Review for its tests, runs, and results.
Alerting on review failures¶
Once the review is linked, create a configuration on that agent.
configuration = (
agent.new_alert_configuration(type="agent_review", name="Review failures")
.with_agent_review("AGENTMONITORING", "review-id")
.with_consecutive_failed_runs(2)
.create()
)
For alert evaluation and lifecycle, see Working with triggered alerts.
Reference documentation¶
Classes¶
The settings of a monitored agent. |
|
A handle to interact with an agent review on the DSS instance. |
Functions¶
|
Creates the alert configuration on this builder's owner. |
|
Creates a DSS external agent backed by this monitored agent. |
|
Returns a handle to an agent. |
|
Get a handle to interact with a specific agent review. |
Creates a DSSClient targeting the same Agent Management instance with the same authentication context. |
|
|
Get a handle to interact with a specific project. |
|
Returns the raw settings of this agent. |
|
Get a handle to interact with a specific saved model |
Returns the settings of this agent. |
|
|
Initializes a new alert configuration builder owned by this agent. |
|
Saves the settings of this agent, checking |
|
Selects the agent review linked to this agent. |
|
Requires consecutive completed failed runs before opening an alert. |
